Add the following to your POM:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.11</version>
<configuration>
<name>newVersion</name>
<value>${project.version}</value>
<regex>-SNAPSHOT</regex>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
You can now remove the -SNAPSHOT
part of your project's version with:
mvn build-helper:regex-property versions:set -N
The -N
tells Maven to only proces the root project in case you have modules defined in your POM. This is not strictly necessary but prevents the build-helper
plugin from running unnecessarily against the submodules. The versions
plugin runs only on the root project in any case, and traverses all modules automatically. Consider using the reactorModuleConvergence
rule of the maven-enforcer
plugin to make sure multi-module projects are handled correctly.
You can run mvn versions:commit
to remove the backup POM(s) generated by versions:set
. Alternatively you can add <generateBackupPoms>false</generateBackupPoms>
to the configuration of the versions
plugin.