Maven update POM and all the POM's that have dependencies to the changed POM

228 views Asked by At

I have a project with the following structure.

D:\PROJECT\Services

and inside the services I have multiple maven projects, like this:

D:\PROJECT\Services\DTO
D:\PROJECT\Services\PERSON
...

And I want to update the POM version of the DTO project.

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.hijat2</groupId>
        <artifactId>Hijat2-root-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>hijat2-dto</artifactId>
    <version>0.6.0-EPIC-6312-SNAPSHOT</version>
    <name>hijat2-dto</name>
    <description>Data transfer object library for P.</description>
    <dependencies>
        <dependency>
            <groupId>com.hijat2</groupId>
            <artifactId>hijat2-enum</artifactId>
            <version>0.6.0-EPIC-6312-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

if I run this line:

mvn versions:set -DnewVersion=$RELEASE_VERSION -DautoVersionSubmodules=true

this will be changed:

...
<parent>
<groupId>com.hijat2</groupId>
<artifactId>Hijat2-root-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>hijat2-dto</artifactId>
<version>NEW VERSION</version>
<name>hijat2-dto</name>
...

The question that I have is, how can I update all the POM files that have this POM file as a dependecy?

like this example for this project

D:\PROJECT\Services\PERSON

this is the POM with the DTO dependecy

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>com.hijat2</groupId>
    <artifactId>Hijat2-root-parent</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>
<artifactId>hijat2-ansiotiedot-service-if</artifactId>
<version>0.2.0-EPIC-6312-SNAPSHOT</version>
<packaging>jar</packaging>
<name>hijat2-ansiotiedot-service-if</name>
<dependencies>
    <dependency>
        <groupId>com.hijat2</groupId>
        <artifactId>hijat2-dto</artifactId>
        <version>0.6.0-EPIC-6312-SNAPSHOT</version> <------This version should be updated
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-rs-client</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Both files are in different folders, Is this possible to do?

Thanks in advance.

0

There are 0 answers