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
- Declaring a
<dependency>
inLibrary B
with ES7.15.1
- Declaring a
<dependency>
inParent
's dependency management section with ES7.15.1
and including this in children - Excluding ES from
spring-boot-dependencies
=> exclusion functionality not yet implemented in dependency management
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