Maven Versions Plugin, update parent recursively in multi-module project

2k views Asked by At

I have following maven project structure

pom.xml (parent)  

pom.xml (extends parent, aggregates modules)
|
|--pom.xml (extends aggregate)

Now, when I mvn install upgraded parent version and run mvn versions:update-parent on the aggregate project, I would except first the aggregate parent is updated and aggregate inherits the version, and sequently it's module's parents are updated for upgraded aggregate, again inheriting the version. That would make perfect sense with the fact aggregate projects just sequently builds all modules with same maven command.

However, this isn't the case with Maven Versions Plugin. The example just upgrades the aggregate parent, but leaves it's modules (inheriting it) untouched. Is this bug in the plugin? How to scope around with this issue?

I know I could run mvn versions:set in the aggregate to successfully update modules too, but in this case I have to specify the version (versus using latest parent). I know I could also make a script to figure this out, but that's dirty.

So, how do I correctly upgrade version with Maven Version Plugin, where project utilizes inheritance, aggregation and is spanned across multiple repositories, and using parent POM as single source of version declaration?

1

There are 1 answers

1
jashan On

After the

mvn versions:2.1:update-parent

you can try the command to update the child-versions (as given here)

mvn versions:update-child-modules