maven versions plugin does not fetch releases with build number

375 views Asked by At

I have a library with version 1.0.0-19 (19 is the Jenkins build number), on next jenkins build the version 1.0.0-20 will be assigend to the library and the artifact will be deployed to a maven repository. Another artifact which is referencing the library in the pom dependency section does not get the last version if I execute versions:use-latest-versions, the dependency version is still 1.0.0-19 instead of 1.0.0-20. Maybe it has to do with the allow* system parameters, there is no property for the build number part.

Any ideas how it could be achieved to get always the last build (1.0.0-19 -> 1.0.0-20)?

1

There are 1 answers

1
Naman On

Within your pom make sure you are using -

<dependencies>
    <dependency>
        <groupId>some.artifactory.group</groupId>
        <artifactId>artifact-name</artifactId>
        <version>1.0.0-19</version>
    </dependency>
</dependencies>
<!-- please use the appropriate artifact and groupId -->


<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>versions-maven-plugin</artifactId>
            <version>2.3</version>
        </plugin>
    </plugins>
</build>

and you are executing the command -

mvn versions:use-latest-releases    

Source - http://www.mojohaus.org/versions-maven-plugin/use-latest-releases-mojo.html

Note - Just in case this also involves SNAPSHOTS, do take care of allowSnapshots and use the command as -

mvn versions:use-latest-releases -DallowSnapshots=true