I have a multi-module maven project in Kubernates. We intend to version all these modules together. But as of now, I end up hard-coding version in each of the module pom.xml as below
<parent>
<artifactId>xyz-application</artifactId>
<groupId>com.xyz</groupId>
<version>2.50.0.g</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.xyz</groupId>
<artifactId>xyz-Library</artifactId>
<version>2.50.0.g</version>
The main parent module has the below configuration
<modelVersion>4.0.0</modelVersion>
<groupId>com.xyz</groupId>
<artifactId>xyz-application</artifactId>
<version>2.50.0.g</version>
<packaging>pom</packaging>
Currently, I'm using the mvn release plugin in the pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<tagNameFormat>${product_label}-@{project.version}</tagNameFormat>
<releaseProfiles>releases</releaseProfiles>
<preparationGoals>clean deploy</preparationGoals>
<arguments>-s settings.xml</arguments>
</configuration>
</plugin>
Since the project is in Kubernetes, here is the Jenkins file content I'm using while the release
def MVN_RELEASE = "release:clean release:prepare release:perform -Dmaven.source.skip=true"
stage('Release artifacts to artifactory') {
steps {
container('maven') {
withCredentials() {
sh "mvn ${MVN_RELEASE} -Dresume=false"
}
}
}
}
Now, during release, I need to update the parent pom and all sub-modules poms version by a new version of my choice, I can use a mvn version plugin, something like
mvn versions:set -DnewVersion=3.00.0-SNAPSHOT -DprocessAllModules -DgenerateBackupPoms=false
and thenmvn versions:commit -DprocessAllModules
At what stage in Jenkins/pom.xml should I add this? Now, this plugin is useful only when I want to bump to a specific version of my choice (like 3.00.0-Snapshot
), otherwise, the mvn release plugin should bump the version automatically to something like 2.50.1-SNAPSHOT
. Is that correct understanding?
How can I gracefully handle this pom version update issue?
Thanks in advance!