I have a pom with the following GAV
com.company.services
test-branch-2
1.0
If you really don't want to use the Maven Release Plugin (for whatever reason), here is how I succeed on dropping the SNAPSHOT suffix (hanbdled as a classifier) from a maven POM in a standard way (that is, no scripting, no custom maven plugin).
Given the following profile:
drop-snapshot
org.codehaus.mojo
build-helper-maven-plugin
1.11
parse-version
validate
parse-version
org.codehaus.mojo
versions-maven-plugin
2.2
set-version
validate
set
${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}
upgrade-pom
validate
commit
And simply executing: mvn validate -Pdrop-snapshot
The version of an example pom passed from 0.0.1-SNAPSHOT
to 0.0.1
.
How it actually works:
build-helper-maven-plugin
, parse-version goal, will parse the current version of the POM and set it in a set of properties having by default parsedVersion
as a prefix and majorVersion
, minorVersion
, incrementalVersion
as suffixes (check the documentation, you will also have classifier
and buildNumber
). Hence, after its execution we can then use in our POM the properties like ${parsedVersion.majorVersion}
and so on.versions-maven-plugin
, set goal, will then use these properties to build the new version you actually want (in this case dropping the SNAPSHOT, because we excluded the ${parsedVersion.classifier}
property).versions-maven-plugin
, commit goal, will make these changes effective.