简体   繁体   中英

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

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.

Is this possible?

I tried to retrieve the svn revision number using org.codehaus.mojo:buildnumber-maven-plugin and adding the following section:

<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.

The problem is that you have associated the goal buildnumber-maven-plugin:create associated with the phase 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM