TheKara
TheKara

Reputation: 3

Maven's set version plugin doesn't set parent version in child module

While I was trying to automate the version updates of all the poms in the project, I couldn't fix this issue. The versions:set plugin/command does replace almost every version of a pom but not the versions of the parent pom (another project) defined in the parent part of the pom.xml itself.

<parent>
    <groupId>com.test.app</groupId>
    <artifactId>helloWorld</artifactId>
    <version>3.19.0-SNAPSHOT</version>
    <relativePath />
</parent>

<groupId>com.test.app.child</groupId>
<version>3.21.0-SNAPSHOT</version>
<artifactId>helloWorldChild</artifactId>
<name>${project.groupId}::${project.artifactId}</name>
<packaging>pom</packaging>

As you can see the two versions are different. This is after I executed the following command:

mvn versions:set -DgroupId=com.test.app.* -DartifactId=* -DoldVersion=* -DnewVersion=3.21.0-SNAPSHOT

The expected result is, that both, an all versions versions are 3.21.0-SNAPSHOT instead of 3.19.0-SNAPSHOT. Is there any possibility to fix this?

Upvotes: 0

Views: 499

Answers (1)

Essex Boy
Essex Boy

Reputation: 7950

Your version and group should come from the parent, they should not be set in the child, only the artifact should be set in the child.

<parent>
    <groupId>com.test.app</groupId>
    <artifactId>helloWorld</artifactId>
    <version>3.19.0-SNAPSHOT</version>
    <relativePath />
</parent>

<artifactId>helloWorldChild</artifactId>
<name>${project.groupId}::${project.artifactId}</name>
<packaging>pom</packaging>

Upvotes: 1

Related Questions