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:
- Using "snapshot" profile. See below pom.xml snapshot profile configuration and Artifactory repo configuration
- Command used to update version:
mvn -P snapshot -B versions:use-latest-versions versions:update-properties -Dincludes=com.example* -DexcludeReactor=false -DallowSnapshots=true ...
Trunk version update:
- Using "production" profile. See below pom.xml production profile configuration and Artifactory configuration
- Command used to update version:
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:
- libs-snapshot has "com.example:myLib:1.1.10-SNAPSHOT", "com.example:myLib:1.1.11-SNAPSHOT"
- libs-release has "com.example:myLib:1.1.9", "com.example:myLib:1.1.12"
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:
- Local repos: libs-snapshot-local (development repository); libs-release-local (release repository)
- Virtual repos: libs-snapshot (includes libs-snapshot-local, libs-release-local and remote-repos); libs-release (includes libs-release-local and remote repos)
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>
...