versions icon indicating copy to clipboard operation
versions copied to clipboard

Updating parent-pom version in a multimodule project updates more than just the parent-pom version

Open olivierpaul opened this issue 1 year ago • 2 comments

Project structure ├───module1 │ └───pom.xml ├───parent-pom │ └───pom.xml └───pom.xml

When updating the version in the parent-pom, it updates also the parent pom in the module1 But when the version in the module1 is the same as the version of the parent pom, the version of the module1 is also updated

A proof of concept is attached

cd parent-pom
mvn versions:set -DnewVersion=2.0.0
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< test:parent-pom >---------------------------
[INFO] Building parent-pom 1.0.0
[INFO]   from pom.xml
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- versions:2.15.0:set (default-cli) @ parent-pom ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: e:\Projects\SFC2021FO\poc
[INFO] Processing change of test:parent-pom:1.0.0 -> 2.0.0
[INFO] Processing test:parent-pom
[INFO]     Updating project test:parent-pom
[INFO]         from version 1.0.0 to 2.0.0
[INFO]
[INFO] Processing test:module1
[INFO]     Updating parent test:parent-pom
[INFO]         from version 1.0.0 to 2.0.0
mvn versions:set -DnewVersion=3.0.0
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< test:parent-pom >---------------------------
[INFO] Building parent-pom 2.0.0
[INFO]   from pom.xml
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- versions:2.15.0:set (default-cli) @ parent-pom ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: e:\Projects\SFC2021FO\poc
[INFO] Processing change of test:parent-pom:2.0.0 -> 3.0.0
[INFO] Processing test:parent-pom
[INFO]     Updating project test:parent-pom
[INFO]         from version 2.0.0 to 3.0.0
[INFO]
[INFO] Processing test:module1
[INFO]     Updating parent test:parent-pom
[INFO]         from version 2.0.0 to 3.0.0
[INFO]     Updating project test:module1
[INFO]         from version 2.0.0 to 3.0.0

olivierpaul avatar May 24 '23 12:05 olivierpaul

poc.zip

olivierpaul avatar May 24 '23 12:05 olivierpaul

Sets the current project's version and based on that change propagates that change onto any child modules as necessary.

That's because this is a very simple mojo which is checking for all sub-modules matching <groupId>:*:<version> of the root project. So, because after the first update your module1 matched that pattern, it got updated. I don't really see a bug there to be honest.

I invite you to check the source code of the mojo yourself and maybe you could come up with ideas to improve upon it.

jarmoniuk avatar May 27 '23 06:05 jarmoniuk

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar May 27 '24 02:05 github-actions[bot]