Home > Enterprise >  Maven property overriding conflict between parent/bom
Maven property overriding conflict between parent/bom

Time:02-01

I am currently facing an issue with my maven configuration. I was thinking it will work in a way where versions in MyBom will have higher priority on the grand-grand-parent defined versions.

This is the setup :

enter image description here

In spring-dependencies, I have this version <atomikos.version>4.0.6</atomikos.version>. In myBom, I have this version <atomikos.version>5.0.106</atomikos.version>.

Both spring-dependencies and MyBom have the

<dependency>
        <groupId>com.atomikos</groupId>
        <artifactId>transactions-jta</artifactId>
        <version>${atomikos.version}</version>
</dependency>

I have imported the bom as usual in "MyParent":

<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.test</groupId>
        <artifactId>myBom</artifactId>
        <version>${myBom.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

Finally, in "MyProject", when I am showing the effective pom, it uses the version 4.0.6 coming from the spring-dependencies.

I was expecting the version to be 5.0.106 as the bom redefine it in a sublayer.

Note that it can work with any dependency which is common between bom and parent.

So, currently, my only viable solution is to manually set the the version in "MyParent" which is making the creation of "MyBom" useless...

Can you confirm what is correct ? My assumption (meaning I have a misconfiguration somewhere) or the current behavior, meaning "MyBom" is worthless.

CodePudding user response:

As far as I know, "direct" entries in the dependencyManagement always take precedent over BOMs, not matter what the inheritance level is.

You should probably just override the <atomikos.version> property.

CodePudding user response:

The dependencyManagement is just a declaration of what the version of the dependency should be when really used as a project dependency. Thus you still should declare (use) the myBom dependency. Also, the scope "import" is invalid. See the documentation

  • Related