Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shade (relocate) one version of a transitive dependency, but not the other

I've got a Maven project that contains two dependencies, A and B. Each of these depends transitively on C, but they depend on different versions of C. Let's say that A depends on C version 1, and B depends on C version 2.

Unfortunately, A is not bytecode-compatible with version 2, nor B with version 1. (As it happens, A is source-compatible with version 2, but I don't think that will help us here.)

This means that I need both versions of the transitive dependency in my project, and I need A to use version 1, and B to use version 2.

Is there a way of doing this?

I had assumed that I would need to use the shade plugin to relocate the package name of A and all its dependencies, but this doesn't seem to be possible. If I shade A, its dependencies don't get shaded, and it still picks up version 2, and fails to run.

like image 964
chiastic-security Avatar asked Jun 01 '15 14:06

chiastic-security


1 Answers

Create another project wrapper A named A-wrapper. Relocate C in A-wrapper. Then in your main project, depends on A-wrapper and B.

I've met a similar problem on pb2 and pb3 and it is resolved using this way. https://stackoverflow.com/a/41394239/1395722

like image 111
a.l. Avatar answered Oct 04 '22 05:10

a.l.