Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven version:set does not update child modules

Tags:

maven

After finally getting tired of maven release plugin I deceided to move on to something more simpler.

I have a project, with a couple of modules.

When I do

mvn versions:set -DnewVersion=1.0.2-SNAPSHOT

it just changes the parent and skips all child modules?

what am I doing wrong? do I need to set another parameter as well?

like image 918
User123456 Avatar asked Jan 26 '13 12:01

User123456


4 Answers

I had the same problem of submodules referencing external parents.

If the child's parent version matches the parent's local version, then it updates the versions of the parent and child (it might say SKIPPED but still work, bizarrely). If they don't match then it seems to only update the parent's version and update the children to point to the new parent, it doesn't change the children's versions at all.

Finally i found that wildcards could resolve this problem (requires a new'ish version of the versions plugin):

mvn org.codehaus.mojo:versions-maven-plugin:2.2:set -DnewVersion=1.5.0a   -DartifactId=*  -DgroupId=*
like image 134
Cédric Levasseur Avatar answered Oct 22 '22 18:10

Cédric Levasseur


Alternatively you can also use the processAllModules parameter.

$ mvn versions:set -DnewVersion=2.0.0 -DprocessAllModules
like image 21
Marco Avatar answered Oct 22 '22 19:10

Marco


If you're like me with a project whose child modules don't match the parent's version, another option is to adjust them to match first:

$ mvn versions:update-child-modules

then versions:set (and versions:replace-snapshot etc.) will now work as expected, without needing a newer version of the plugin :)

$ mvn versions:set -DnewVersion=1.0.2-SNAPSHOT
like image 3
rogerdpack Avatar answered Oct 22 '22 17:10

rogerdpack


I'm assuming that your project structure is like this:

parent/pom.xml
child/pom.xml

Then you have to run mvn versions:set -DnewVersion=1.0.2-SNAPSHOT from parent/ directory.

like image 2
yihtserns Avatar answered Oct 22 '22 18:10

yihtserns