Reputation: 2739
I want to set a release version for my project. I use an aggregate pom for all modules. Each module parent is not the aggregate pom mentioned before.
My question differs from Updating version numbers of modules in a multi-module Maven project question, there the aggregate pom is a parent pom as well.
The aggregate pom.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>aggregate</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<modules>
<module>module1</module>
</modules>
</project>
Where the module1 pom.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>module-1</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>com.example</groupId>
<artifactId>parent1</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../parent1/pom.xml</relativePath>
</parent>
</project>
When I execute:
mvn versions:set -DnewVersion=0.0.1
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] module-1
[INFO] aggregate
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building aggregate 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.3:set (default-cli) @ aggregate ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: C:\Users\maxim.kirilov\workspace\maven-games\aggregate
[INFO] Processing change of com.example:aggregate:0.0.1 -> 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] module-1 ........................................... SKIPPED
[INFO] aggregate .......................................... SUCCESS [ 0.962 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
Why module-1 is skipped? I read some articles that suggests to invoke the maven set version command for each module separately, does maven support for cleaner solution?
Upvotes: 0
Views: 1555
Reputation: 2739
Recently (23/09/2017) a documentation was added to Versions Maven Plugin. In order to update all project under aggregate project you need to add supplemental command line parameters:
mvn versions:set -DnewVersion=0.0.1 -DoldVersion=* -DgroupId=* -DartifactId=*
This is needed otherwise the filter for the versions (via -DoldVersion=) would have filtered out that module cause it has a different version than the rest of modules. Furthermore you need to add the -DgroupId= and -DartifactId=* otherwise the module-1 will also filtered out based on the differences in groupId and artifactId.
Upvotes: 4
Reputation: 29
You may need to include Versions Maven Plugin in your aggregate pom xml. http://www.mojohaus.org/versions-maven-plugin/ http://www.mojohaus.org/versions-maven-plugin/usage.html
something like this i do:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
</plugins>
Upvotes: 0