Once upon a time there was the release plugin and it was the only tool we had to manage POM versions: release:prepare and a text editor were all we had in our toolbox.
A new hero has come to save us from the evil of POM version management and its name is versions plugin.
I decided to practice a little bit with this champion and I’m now confident it is THE tool, but still a few tricks can be helpful.
First of all, if you want to manage a set of related projects you want to have an aggregating (aka multi-module) POM, something like:
<project> <modelVersion>4.0.0</modelVersion> <groupId>org.agileware.project</groupId> <artifactId>aggregator</artifactId> <version>1.0.0</version> <packaging>pom</packaging> <modules> <module>application</module> <module>library1</module> <module>library2</module> </modules> </project>
Please note this is not a parent POM because the sub modules will not specify it as their parent, or at least it’s not mandatory!
Let’s say that all sub modules start at version 0.1.0-SNAPSHOT and after a while you want to release library1.
You will need to update all the POMs that have library1 as a dependency to refer to the new 0.2.0-SNAPSHOT version and you can do this witha simple Maven command:
mvn versions:use-latest-versions -DexcludeReactor=false -DallowSnapshots=true
Obviously there are many other goals and options for you to use, providing a lot of control over what is going to be updated and which versions should be considered as target: releases only, snapshots only, no major version updates and so forth.