【问题标题】:How can I take build number using SVN and Maven?如何使用 SVN 和 Maven 获取内部版本号?
【发布时间】:2014-05-06 16:47:02
【问题描述】:

我使用buildnumber-maven-plugin,我需要从 svn 获取项目的内部版本号。我的 pom.xml:

<scm>
    <connection>
        scm:svn:https://username:password@path_to_repositiry
    </connection>
</scm>

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>buildnumber-maven-plugin</artifactId>
    <version>1.1</version>
    <executions>
        <execution>
            <phase>validate</phase>
            <goals>
                <goal>create</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <doCheck>false</doCheck>
        <doUpdate>false</doUpdate>
        <providerImplementations>
            <svn>javasvn</svn>
        </providerImplementations>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
            <artifactId>maven-scm-provider-svnjava</artifactId>
            <version>2.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.tmatesoft.svnkit</groupId>
            <artifactId>svnkit</artifactId>
            <version>1.7.4-v1</version>
        </dependency>
    </dependencies>
</plugin>

但我打包项目时出错:

[ERROR] Failed to execute goal org.codehaus.mojo:buildnumber-maven-plugin:1.1:create (default)on project myproject: Cannot get the revision information from the scm repository : [ERROR] Exception while executing SCM command. svn: E155021: This client is too old to work with the working copy at [ERROR] 'D:\projects\myproject' (format {1}).

虽然我使用的是 TortoiseSVN 1.8.2!

我读到buildnumber-maven-plugin 在 TortoiseSVN 1.7 及更早版本中的行为如此。 如何使用 SVN 和 Maven 获取内部版本号?

【问题讨论】:

    标签: java maven svn buildnumber-maven-plugin


    【解决方案1】:

    buildnumber 插件将访问您的工作副本以获取修订版,并且由于您使用 TortoiseSVN 1.8.x,您的工作副本是 svn 1.8.x 格式。因此,buildnumber 插件使用的 svnkit 也需要支持 svn 1.8.x,而您使用的版本(1.7.4-v1)很可能不支持。

    因此您需要更新版本的 svnkit,例如

    <dependency>
      <groupId>org.tmatesoft.svnkit</groupId>
      <artifactId>svnkit</artifactId>
      <version>1.8.3-1</version>
    </dependency>
    

    【讨论】:

    • 此外,还有一个更新版本的 buildnumber-maven-plugin 可用:1.2 版。确保 svnkit 和 buildnumber-maven-plugin 版本都是最新的。
    • @user3186861 随时接受答案 ;)
    • 添加一些额外信息,我正在使用一个框架,其中正确声明了此依赖项,但我的父 POM 在没有此依赖项的情况下覆盖它(以 &lt;plugin&gt; &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;... 开头)所以它没有找到正确的版本,当我扩展 Thomas 的依赖项时,它运行良好。
    猜你喜欢
    • 2014-10-28
    • 2014-11-15
    • 2012-08-06
    • 2017-05-05
    • 1970-01-01
    • 2020-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多