0
votes

I am trying to use a Maven Versions Plugin to upgrade all the child POM's to parent version and execute the build of all child modules in the parent pom.The Pom Files look like this

Parent POM

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.build.pom</groupId>
    <artifactId>basepom</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <modules>
        <module>
            <module>../Common</module>
        <module>
    <modules>

    <!-- . . . -->
</project>

Child Pom

<parent>
    <artifactId>basepom</artifactId>
    <groupId>com.build.pom</groupId>
    <version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.child.common</groupId>
<artifactId>common</artifactId>
<packaging>jar</packaging>
<name>Common</name>
<description>Common Jar</description>

Now if I run a Maven build on the base POM using the command from Eclipse

mvn clean install 

The child module is getting build properly however if I update the basepom version to 2.0 and use version plugin command

mvn clean -N versions:update-child-modules install

The versions are getting updated however the child modules are not getting built. Only the base pom gets build.

Do I have to explicitly specify to build the child modules in some Phase? What am I missing?.

1

1 Answers

0
votes

Instead of setting the version of the parent manually you can use the set-goal like this:

versions:set -DnewVersion=XXX -DgenerateBackupPoms=false install

This updates the version of the parent and all childs and should execute the install afterwards.


EDIT:

To move parameters and execution to the pom, try sth like this (not tested):

  <plugin>
   <artifactId>maven-versions-plugin</artifactId>
   <executions>
    <execution>
     <goals>
      <goal>set</goal>
     </goals>
     <configuration>
       <newVersion>XXX</newVersion>
       <generateBackupPoms>false</generateBackupPoms>
     </configuration>
    </execution>
   </executions>
 </plugin>

(If the version doesn't change the set goal should be ignored.)