0

i have project structured as shown below.

project pom.xml
<parent>
  <groupId>group</groupId>
  <artifactId>parent</artifactId>
  <version>v1</version>
</parent>
<artifactId>project</artifactId>
<modules>
  <module>mod1</module>
  <module>mode2</module>
</modules>

mod 1 pom.xml
<parent>
  <groupId>group</groupId>
  <artifactId>project</artifactId>
  <version>v1</version>
</parent>
<artifactId>mod1</artifactId>

mod 2 pom.xml
<parent>
  <groupId>group</groupId>
  <artifactId>project</artifactId>
  <version>v1</version>
</parent>
<artifactId>mod2</artifactId>
<modules>
    <module>submod1</module>
    <module>submod2</module>
  </modules>

sumod1|submod2 pom.xml
<parent>
  <groupId>group</groupId>
  <artifactId>mod2</artifactId>
  <version>v1</version>
</parent>
<artifactId>sumod1|submod2</artifactId>

Everytime a new parent (say v2) is available, i need to build the project with new version ( v2, since it inherits the version from parent ).

I've tried the following :-

Approach 1

  1. mvn versions:update-parent -DskipResolution -DparentVersion=v2
  2. mvn -N versions:update-child-modules

issues :- it doesn't update versions ( in the parent tag ) of submod1 and submod2, unless i run step 2 again ( in automations, i wouldn't know how many times i have to repeat step 2, until versions are resolved in all submodules ) workaround ( seems very dirty ) :- loop through step 2 until this string is found in o/p - All child modules are up to date.

Approach 2

  1. mvn versions:update-parent -DskipResolution -DparentVersion=v2
  2. mvn versions:set -DnewVersion=v2 -DprocessAllModules

issues :- i get an error as follows

[ERROR] Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.13.0:set (default-cli) on project common-utils-core-parent: Project version is inherited from parent. -> [Help 1]

workaround - added the version tag manually in the project pom.xml, then ran step 2, weirdly version ( in parent tag ) of mod1 is not getting updated.

Pls let me know what i'm missing here and if there is any other cleaner approach.

user127167
  • 11
  • 2

0 Answers0