How to use maven-plugin versions to install child module versions?

I have a multi-module project with a common parent pom for all modules and the / build pom aggregator. I am trying to use the maven-versions-plugin to update / install versions of all my modules, but it continues to skip child modules.

Project layout: - common / pom.xml (build pom) - common / superpom / pom.xml (parent pom) - module1 / pom.xml (module1 pom) - module2 / pom.xml (module2 pom)

common / pom.xml:

<project> <modelVersion>4.0.0</modelVersion> <groupId>com.bic</groupId> <artifactId>builder</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> <name>Builder</name> <modules> <module>../module1</module> <!-- POM Component Versionning --> <module>../module2</module> </modules> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>versions-maven-plugin</artifactId> <version>2.1</version> </plugin> </plugins> </build> </project> 

I tried adding a plugin to the pom assembly (common / pom.xml) and then called:

 mvn versions:set -DnewVersion=999999 

Maven lists all the details found in child modules, so I know that it parses them correctly:

 Props: {project.version=50, project.parent.version=1.0-SNAPSHOT, project.parent.groupId=com.bic, project.artifactId=module1, project.groupId=com.bic, project.parent.artifactId=common} Props: {project.version=50, project.parent.version=1.0-SNAPSHOT, project.parent.groupId=com.bic, project.artifactId=module2, project.groupId=com.bic, project.parent.artifactId=common} 

but in fact it does not update the versions of any of the poms modules, which I do.

 [INFO] Reactor Summary: [INFO] [INFO] Module1 ........................................ SKIPPED [INFO] Module2 ........................................ SKIPPED [INFO] Builder ........................................ SUCCESS [ 2.037 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.975 s [INFO] Finished at: 2015-01-26T11:48:11-05:00 [INFO] Final Memory: 24M/44M [INFO] ------------------------------------------------------------------------ 

And the goal of update-child-modules does not allow me to explicitly set the version number for child modules.

Am I using the plugin incorrectly?

+7
java maven version
source share
3 answers

It was not possible to figure out how to do this using the-maven-plugin version directly, so I ended it manually.

 find . -name "pom.xml" -exec mvn versions:set -DnewVersion=1.0.3-SNAPSHOT -f {} \; 

This ended up finding all the pumps of my child modules and updating the version number in each. Definitely slower than using the plugin on the parent object, as it was intended to be executed, but functional.

+2
source share

It's a bit late for the party, but I found the answer. You need to run the versions: set the target in the parent project directly. It will take care of copying the POM aggregator side by side (maybe it is only looking at one directory, but I'm not sure) and will update the parent, aggregator, and all child modules as you expect.

The root POM is an aggregator and lists the parent, module1 and module2 as modules:

 DANIJOH2-M-V0MA:test danijoh2$ ls module1 module2 parent pom.xml 

The POM root aggregator, module1 and module2 all refer to parent / pom.xml as the parent POM. Go to the parent element and run the versions: set goal:

 DANIJOH2-M-V0MA:test danijoh2$ cd parent DANIJOH2-M-V0MA:parent danijoh2$ ls pom.xml DANIJOH2-M-V0MA:parent danijoh2$ mvn org.codehaus.mojo:versions-maven-plugin:2.1:set -DnewVersion=1.0.0 -DgenerateBackupPoms=false [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building parent 1.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- versions-maven-plugin:2.1:set (default-cli) @ parent --- [INFO] Searching for local aggregator root... [INFO] Local aggregation root: /Users/danijoh2/Desktop/test [INFO] Processing com.cisco.dan.test:parent [INFO] Updating project com.cisco.dan.test:parent [INFO] from version 1.0.0-SNAPSHOT to 1.0.0 [INFO] [INFO] Processing com.cisco.dan.test:aggregator [INFO] Updating parent com.cisco.dan.test:parent [INFO] from version 1.0.0-SNAPSHOT to 1.0.0 [INFO] Updating project com.cisco.dan.test:aggregator [INFO] from version 1.0.0-SNAPSHOT to 1.0.0 [INFO] [INFO] Processing com.cisco.dan.test:module1 [INFO] Updating parent com.cisco.dan.test:parent [INFO] from version 1.0.0-SNAPSHOT to 1.0.0 [INFO] Updating project com.cisco.dan.test:module1 [INFO] from version 1.0.0-SNAPSHOT to 1.0.0 [INFO] [INFO] Processing com.cisco.dan.test:module2 [INFO] Updating parent com.cisco.dan.test:parent [INFO] from version 1.0.0-SNAPSHOT to 1.0.0 [INFO] Updating project com.cisco.dan.test:module2 [INFO] from version 1.0.0-SNAPSHOT to 1.0.0 
0
source share

The solution was introduced in version 2.5 of the plugin-maven-plugin

 mvn versions:set -DnewVersion=1.6-SNAPSHOT -DprocessAllModules=true 

or, like me, you need to force the version:

 mvn org.codehaus.mojo:versions-maven-plugin:2.5:set -DnewVersion=1.6-SNAPSHOT -DprocessAllModules=true 
0
source share

All Articles