0

I have a project of this type:

.
|--- pom.xml (A)
     |--- pom.xml (B)
     |    `--- pom.xml (C)
     `--- pom.xml (D)

A:

<artifactId>A</artifactId>
<version>1.0</version>

B:

<parent>
  <artifactId>A</artifactId>
  <version>1.0</version>
</parent>

<artifactId>B</artifactId>
<version>1.1</version>

<dependencyManagement>
  <dependencies>
    <dependency>
      <artifactId>D</artifactId>
      <version>${project.parent.version}</version>
    </dependency>
    ...

C:

<parent>
  <artifactId>B</artifactId>
  <version>1.1</version>
</parent>

<artifactId>C</artifactId>

<dependencies>
  <dependency>
    <artifactId>D</artifactId>
  </dependency>
  ...

And I expect artifact D will be used version 1.0, because in B in dependencyManagement I specified the version ${project.parent.version} (1.0 for B). But in practice, artifact C uses D version 1.1, because for C ${project.parent.version} it's 1.1. So how can I solve this problem so that the artifact is used exactly version 1.0, not 1.1. I would not like to resort to using a hardcode and specify specifically version 1.0. Maybe some plugin can help?

I wanted to use the maven resources plugin to replace ${project.parent.version} in pom before the build, but attempts failed

  • In general you should not use different versions for different modules within a multi module build. It will make release process later harder. – khmarbaise Nov 22 '22 at 10:30
  • In reality, I don't release different versions. I just want to create a custom snapshot version of just one module which I will deploy and test. If I update the version in the whole project, then there will be a lot of unnecessary artifacts in the repository – Islam Khabibullin Nov 22 '22 at 11:23

0 Answers0