2014-03-27 21 views
5

我使用buildnumber-maven-plugin,我需要从svn获取项目的内部版本号。我的pom.xml:如何使用SVN和Maven构建编号?

<scm> 
    <connection> 
     scm:svn:https://username:[email protected]_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构建编号?

回答

7

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

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

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

另外,还有更新版本的buildnumber-maven-plugin可用:版本1.2。确保svnkit和buildnumber-maven-plugin版本都是最新的。 –

+0

感谢大家的回答!有用! – RuF

+0

@ user3186861随时可以接受答案;) – Thomas