Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn versions:set not updating child poms

I did much research on this but could not resolve it so far.

I've following structure,

root folder
parent/pom.xml (parent pom)
artifact1/pom.xml
artifact2/pom.xml
pom.xml (aggregator pom)

root/pom.xml
------------

<parent>
    <groupId>releasetest2</groupId>
    <artifactId>root</artifactId>
    <version>1.0.4</version>
    <relativePath>parent</relativePath>
</parent>

<artifactId>aggregator</artifactId>
<packaging>pom</packaging>


artifact1/pom.xml
-----------------

<parent>
    <groupId>releasetest2</groupId>
<artifactId>root</artifactId>
<version>1.0.4</version>
<relativePath>../parent</relativePath>
</parent>

<groupId>releasetest</groupId>
<artifactId>artifact1</artifactId>
<packaging>jar</packaging>


artifact2/pom.xml
-----------------

<parent>
<groupId>releasetest2</groupId>
<artifactId>root</artifactId>
<version>1.0.4</version>
<relativePath>../parent</relativePath>
</parent>

<groupId>releasetest</groupId>
<artifactId>artifact2</artifactId>
<packaging>jar</packaging>


parent/pom.xml
--------------

<groupId>releasetest2</groupId>
<artifactId>root</artifactId>
<version>1.0.4</version>
<packaging>pom</packaging>

<properties>
    <MAIN.version>${project.version}</MAIN.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
              <groupId>releasetest</groupId>
              <artifactId>artifact1</artifactId>
            <version>${MAIN.version}</version>
        </dependency>
        <dependency>
            <groupId>releasetest</groupId>
            <artifactId>artifact2</artifactId>
            <version>${MAIN.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

When I use mvn versions:set while being in parent folder it only updates the parent/pom.xml. I expected it to update root/pom.xml artifact1/pom.xml and artifact2/pom.xml

Is there a way to resolve this?

like image 848
Maulin Vasavada Avatar asked Feb 15 '23 20:02

Maulin Vasavada


1 Answers

First please revert version number in the parent pom and make sure that all child poms have the same version.

Then navigate to parent pom directory and execute this command :

mvn versions:set versions:update-child-modules -DnewVersion=<New_Version_Number> -DprocessAllModules
like image 189
Mohamed AbdElRazek Avatar answered Feb 17 '23 09:02

Mohamed AbdElRazek