I am using the Version Maven Plugin plugin use-latest-versions functionality to update groupID=com.example* internal dependency versions to the latest version. This is executed as part of our CI system using Jenkins.
When developers start working on a new feature they branch the code, work on the branch and when the new feature is implemented (or partially implemented) the code is merged back to trunk (usually multiple times a week).
Branches version update:
mvn -P snapshot -B versions:use-latest-versions versions:update-properties -Dincludes=com.example* -DexcludeReactor=false -DallowSnapshots=true ...
Trunk version update:
mvn -P production -B versions:use-latest-versions versions:update-properties -Dincludes=com.example* -DexcludeReactor=false ...
Sometimes branch builds update com.example* dependency versions to "...-SNAPSHOT" version (this is normal because libs-snapshot Artifactory repo is used as the dependency repository which can have -SNAPSHOT dependency versions). These version updates are checked back to source control (svn).
When the code (including the pom.xml version update changes) are merged back from branches to trunk and the trunk build is executed, all com.example* internal dependency versions should be changed/updated to the latest release versions. But because of some reason when dependency versions have "-SNAPSHOT" in it versions:use-latest-versions is not changing/updating the version to the latest release (none -SNAPSHOT) version.
Example:
Artifactory repos have the flowing versions:
Making myApp branches build will get dependency versions from libs-snapshot and update com.example:myLib version to 1.1.11-SNAPSHOT and check this update back to SVN
...
<dependency>
<groupId>com.example</groupId>
<artifactId>myLib</artifactId>
<version>1.1.11-SNAPSHOT</version>
</dependency>
...
Merging code back to trunk including the above dependency version changes and running the trunk build (including version update) mvn -P production -B versions:use-latest-versions...
does not change the com.example:myLib version to 1.1.12
Artifactory configuration:
pom.xml configuration:
...
<profiles>
<profile>
<id>snapshot</id>
<distributionManagement>
<repository>
<id>libs-snapshot-local</id>
<name>Internal Applications Snapshot Repository</name>
<url>http://example.com/artifactory/libs-snapshot-local</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
<id>libs-snapshot</id>
<name>libs-snapshot</name>
<url>http://example.com/artifactory/libs-snapshot</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>libs-release</id>
<name>libs-release</name>
<url>http://example.com/artifactory/libs-release</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
</repositories>
<build>
...
</build>
</profile>
<profile>
<id>production</id>
<distributionManagement>
<repository>
<id>libs-release-local</id>
<name>Internal Applications Snapshot Repository</name>
<!-- Artifacts are promoted to libs-release-local not deployed directly -->
<url>http://example.com/artifactory/libs-snapshot-local</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>libs-release</id>
<name>libs-release</name>
<url>http://example.com/artifactory/libs-release</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
</repositories>
<build>
...
</build>
</profile>
</profiles>
...
You should make sure you are using the latest versions plugin (2.3
). I believe 2.3
fixed some issues (that being said it is still an incredibly buggy plugin).
The other issue I have found with the version plugin is combining with other version goals or even other maven goals. Don't do that. For example your code above you are running versions:use-latest-versions versions:update-properties
at the same time. Instead execute mvn
once for each one of those goal. Yes this is a pain and slows down the build process but I found it far more reliable particularly if you use versions:update-parent (2.3 may have fixed these issues though).
I also think excludeReactor
is generally broken. If you are running a version update on aggregate project I don't recommend it. Instead go to each submodule and run the command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With