Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Version propagation in Maven

I have a multi module maven project and I would like to use versions in such a way that the developer has to touch only the root project pom to change the version of all modules.

For example

ProjA contains

  • Module1

  • Module2

  • Module3

All the modules contain their own Poms and have ProjA's pom as their parent. Once I run the build I get a jar created for each module. Now For building a newer version of ProjA, I just have to change the version of the ProjA's pom and all the poms of the modules should pick up this new version from the parent. This works if I harcode the parent version in all the module's pom. But this will also force me to update the poms of all modules for every version change in the parent pom which defeats it purpose. Is there a way to avoid this and still achieve the stated behaviour?

like image 885
Manoj Avatar asked Jun 28 '10 10:06

Manoj


1 Answers

Use the Maven Versions Plugin and its versions:update-child-modules goal:

  • versions:update-child-modules updates the parent section of the child modules of a project so the version matches the version of the current project. For example, if you have an aggregator pom that is also the parent for the projects that it aggregates and the children and parent versions get out of sync, this mojo can help fix the versions of the child modules. (Note you may need to invoke Maven with the -N option in order to run this goal if your project is broken so badly that it cannot build because of the version mis-match).
like image 63
Pascal Thivent Avatar answered Sep 28 '22 05:09

Pascal Thivent