[英]I want to automatically update artifact version with the latest svn revision number using maven release plugin
My artifact version looks like this: 我的工件版本如下所示:
1.0.0-SNAPSHOT 1.0.0-SNAPSHOT
I want to use the maven release plugin to deploy the artifact to the releases repository, using the following version: 1.0.0.1234, where 1234 is the latest svn revision number. 我想使用以下版本的maven版本插件将工件部署到版本存储库:1.0.0.1234,其中1234是最新的svn修订版号。
Is this possible? 这可能吗?
I tried to retrieve the svn revision number using org.codehaus.mojo:buildnumber-maven-plugin and adding the following section: 我尝试使用org.codehaus.mojo:buildnumber-maven-plugin并添加以下部分来检索svn版本号:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<releaseVersion>1.0.0.${buildNumber}</releaseVersion>
</configuration>
</plugin>
But when I run the following command: 但是当我运行以下命令时:
mvn -DdryRun=true -Dresume=false -B release:prepare
It looks like the version is set to 1.0.0.${buildNumber} in the tag instead. 看起来该版本已在标记中设置为1.0.0。$ {buildNumber}。
The problem is that you have associated the goal buildnumber-maven-plugin:create
associated with the phase validate
. 问题是您已将目标buildnumber-maven-plugin:create
与阶段validate
相关联。 If you want that it is executed and thus, the variable ${buildNumber}
is given value by the time you are executing release:prepare
, you have to execute the phase beforehand. 如果要执行该${buildNumber}
,则在执行release:prepare
时将给变量${buildNumber}
赋值,您必须事先执行该阶段。 That said, in order to make it work, you have to change your command for this one: mvn validate -DdryRun=true -Dresume=false -B release:prepare
就是说,为了使其工作,您必须为此更改命令: mvn validate -DdryRun=true -Dresume=false -B release:prepare
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.