0

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?

Maxim Kirilov
  • 2,639
  • 24
  • 49

2 Answers2

4

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.

Maxim Kirilov
  • 2,639
  • 24
  • 49
0

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>
LNP
  • 31
  • 4
  • I don't find any kind of configuration like `autoVersionSubmodules` in the docs? This is only available in [maven-release-plugin](http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html) but not in [versions-maven-plugin](http://www.mojohaus.org/versions-maven-plugin/) – khmarbaise Feb 04 '17 at 12:12
  • Suggest you to read further on the second link, something like mvn -N versions:update-child-modules may help you. As of now you can ignore autoVersionSubmodule, but i have used both plugins : releasr and version with above code, it works cool – LNP Feb 04 '17 at 12:16
  • autoVersionSubmodule is not a configuration item which is in versions-maven-plugin available. It is only available in maven-release-plugin. From versions-maven-plugin it will simply being ignored. – khmarbaise Feb 04 '17 at 13:12
  • Yes..it is part of release plugin and i have written to ignore it as of now if you don't want to use it..but i gave you other hint i.e. mvn -N version update-child-moduldes..did you try this? – LNP Feb 04 '17 at 13:40
  • No its not useless, rather depends on use case. You need to understand whole maven release process. – LNP Feb 04 '17 at 15:29
  • Maxim Kirilov,Could you please remove down/negative voting – LNP Feb 15 '17 at 12:38
  • This configuration option is simply not supprted by versions-maven-plugin at all. So you can simply remove it. – khmarbaise Feb 17 '17 at 08:11
  • thanks. this fixed my issue. this way it set the version for all the modules as opposed to just the parent before – Zanas Tumasonis Apr 13 '22 at 15:40