1

I have the following app structure:

+- Parent
   +- Service
   +- Library A
   +- Library B

where [Library A] depends on [Library B]
and [Service] only includes [Library A]

POM files

Parent

<artifactId>parent</artifactId>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <!-- This brings in ES 7.12.1 which I'm trying to exclude or override in children -->
            <version>2.5.5</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Library A

<parent>
    <groupId>com.app</groupId>
    <artifactId>parent</artifactId>
</parent>
<dependencies>
    <dependency>
        <groupId>com.app</groupId>
        <artifactId>library-b</artifactId>
    </dependency>  
</dependencies>  

Library B

<parent>
    <groupId>com.app</groupId>
    <artifactId>parent</artifactId>
</parent>
<dependencies>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <!-- This version is in conflict with 7.12.1 brought in by spring-boot-dependencies -->
        <version>7.15.1</version>
    </dependency> 
</dependencies>

What I want

To upgrade elastic search in Library B to 7.15.1 and override the version in Parent (which is 7.12.1, given by spring-boot-dependencies).

I want this newer version to show up in all places using this library (Service, in my example)

Why

ES 7.12.1 has some fixes resolved in latter versions; spring-boot-dependencies was not yet upgraded with newer ES

What I've tried

Why it doesn't work

Running mvn dependency:tree -Dverbose -Dincludes=org.elasticsearch on Library A still looks like:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ eventer ---
[INFO] com.app:library-a:jar:1.0.0
[INFO] \- com.app:library-b:jar:1.0.0
[INFO]    +- org.elasticsearch.client:elasticsearch-rest-high-level-client:jar:7.12.1:compile (version managed from 7.15.1)
[INFO]    |  \- (org.elasticsearch:elasticsearch:jar:7.12.1:compile - version managed from 7.15.1; omitted for duplicate)
[INFO]    \- org.elasticsearch:elasticsearch:jar:7.12.1:compile
[INFO]       +- org.elasticsearch:elasticsearch-core:jar:7.12.1:compile
[INFO]       +- org.elasticsearch:elasticsearch-secure-sm:jar:7.12.1:compile
[INFO]       +- org.elasticsearch:elasticsearch-x-content:jar:7.12.1:compile
[INFO]       |  \- (org.elasticsearch:elasticsearch-core:jar:7.12.1:compile - omitted for duplicate)
[INFO]       +- org.elasticsearch:elasticsearch-geo:jar:7.12.1:compile
[INFO]       +- org.elasticsearch:elasticsearch-cli:jar:7.12.1:compile
[INFO]       |  \- (org.elasticsearch:elasticsearch-core:jar:7.12.1:compile - omitted for duplicate)
[INFO]       +- org.elasticsearch:jna:jar:5.7.0-1:compile
[INFO]       \- org.elasticsearch:elasticsearch-plugin-classloader:jar:7.12.1:runtime

Possible ugly workaround

Declare ES 7.15.1 in Library B, Library A, AND Service... lots of duplicate information, hard to maintain.

References

Georgian
  • 8,795
  • 8
  • 46
  • 87
  • 1
    Do `Project A` and `Project B` have `pom.xml` files? If so it would be very helpful to see them... furthermore do you use the `Parent` having a `pom.xml` with `dependencyManagement` ? (btw. Deleting `.m2/` will never help because it's cache. The issue is related to the pom files... – khmarbaise Nov 08 '21 at 16:57
  • can you run `mvn depdency:tree -Dverbose` on project A and add the location to the answer where ES `7.12.1` not ignored? – Ruwanka De Silva Nov 09 '21 at 02:53
  • @khmarbaise @Ruwanka Madhushan I've changed my question around a bit. Figured out this lower version is indeed coming from `parent`'s dependency management, but now I can't really override it. – Georgian Nov 09 '21 at 09:15

0 Answers0