Wednesday, September 7, 2011

Quickly update your project version with Maven

When you want to update the version of your project, you can edit the pom.xml file and change the version by hand. When you have a project with multiple sub projects, this is time consuming and error prone.
Maven has a very useful utility to quickly update the version of your project, you can just run this Maven command:
mvn versions:set -DnewVersion=1.2.0-SNAPSHOT

This will update the version of your current project and its sub projects to "1.2.0-SNAPSHOT". This will save the previous version in backup files so you can revert back with this command:
mvn versions:revert

If you are happy with the results and want to get rid of the backup files, just do a commit with:
mvn versions:commit

No comments: