I tried to determine the algorithm that the maven release plugin uses to update the release number for one of my projects. I didn’t have much luck with google to find out how the update works. I didn’t want to experiement with by build server since release process also created source control tags, and publishes the build to a maven repo.
Turns out with a little groovy script you can get at the versioning implementation the plugin uses. You can give it a version, and get back what the next release version is, and what the next snapshot version will be. This can all be done outside of the build process and outside of running the plugin. Here is the script
@Grapes( @Grab(group='org.apache.maven.release', module='maven-release-manager', version='2.5.3') ) import org.apache.maven.shared.release.versions.DefaultVersionInfo check('1.2.3-qualifier-1-SNAPSHOT') def check(versionStr) { def version = new DefaultVersionInfo(versionStr) def nextVersion = version.getNextVersion() println "" println "Current ${version} digits=${version.digits} ann=${version.annotation} annrev=${version.annotationRevision}" println " getReleaseVersionString ${version.getReleaseVersionString()}" println " getNextVersion ${version.getNextVersion()}" println " getReleaseVersionString ${nextVersion.getReleaseVersionString()}" println " getNextVersion ${nextVersion.getNextVersion()}" }
Which results in
Current 1.2.3-qualifier-1-SNAPSHOT digits=[1, 2, 3] ann=qualifier annrev=1 getReleaseVersionString 1.2.3-qualifier-1 getNextVersion 1.2.3-qualifier-2-SNAPSHOT getReleaseVersionString 1.2.3-qualifier-2 getNextVersion 1.2.3-qualifier-3-SNAPSHOT