Suppose I have a multi-module maven project, with a parent pom:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-parent</artifactId>
<version>0.1.0</version>
<modules>
<module>module1</module>
<module>module2</module>
<!-- etc. -->
</modules>
</project>
and several modules like:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>module1</artifactId>
<version>0.1.0</version>
<parent>
<groupId>com.example</groupId>
<artifactId>my-parent</artifactId>
<version>0.1.0</version>
</parent>
</project>
Now I am trying to update the version of the parent pom using the versions maven plugin, without updating the corresponding parent section in the child modules. That is, I want the parent to get a version of e.g. 0.2.0-SNAPSHOT
, while the child modules still refer to the 0.1.0
parent version in this example, i.e.:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>module1</artifactId>
<version>0.1.0</version>
<parent>
<groupId>com.example</groupId>
<artifactId>my-parent</artifactId>
<version>0.1.0</version>
</parent>
</project>
How can I do this?
I have tried just about every optional parameter for the mvn versions:set
command that seemed like it could affect this behavior, including the maven -N
flag, in various combinations, but none of them worked.
Is it possible to do this with the versions maven plugin? Is there some other way?
It seems like I am having the opposite problem as described in these questions:
Versions plugin not updating child modules, just parent being updated
versions-maven-plugin on mutli module project with aggregator pom does not set versions on modules
Note that I am trying to automate this task, which is why I would to run some plugin/command to achieve the desired result (manually you can obviously just edit the relevant line in the parent pom).