Islam Khabibullin
Islam Khabibullin

Reputation: 23

Maven replaces the properties dynamically during the build

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

Upvotes: 0

Views: 47

Answers (0)

Related Questions