I want to automatically update artifact version with the latest svn revision number using maven release plugin

445 views Asked by At

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.

1

There are 1 answers

0
lopezvit On

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