1

My application is defined with an external library jar dependency

<dependency>
    <groupId>com.lib</groupId>
    <artifactId>Encoder</artifactId>
</dependency>

It has two versions 1.0 and 2.0. A class owned in the library got updated in its package structure between these versions as below.

1.0 -- a.b.c.Template

2.0 -- x.y.z.Template

Another dependency called 'Helper' used in my application also contains the above stated Encoder library, but with version 1.0.

Now, my application is defined with 'Encoder' library version 2.0 along with 'Helper' dependency.

My application usage of Encoder library

import x.y.z.Template
..

The 'Helper' dependency usage of Encoder library

import a.b.c.Template
..

The code build is failing with class file not found error as like below.

cannot access a.b.c.Template class file for a.b.c.Template not found

Appreciate your help on finding a solution for the same. Thanks in advance!

Community
  • 1
  • 1
Sats
  • 1,061
  • 9
  • 12

1 Answers1

1

The best is to avoid above situation by carefully picking dependency versions until everything runs smoothly.

If this is too difficult, you can have a look at the maven-shade-plugin, which allows you to relocate packages that are merged into a dependency.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • Thanks for your comment. I have tried shader plugin as like below, but went in vain. Please correct. ``` com.lib:Encoder x/y/z/** a/b/c/** ``` – Sats Feb 25 '20 at 14:45
  • 1
    Sorry, if you have a question about the usage of the Maven shade plugin, please ask a separate question and put your configuration there. I cannot read XML in the comments. – J Fabian Meier Feb 25 '20 at 14:59
  • Here is separate question on shade - https://stackoverflow.com/questions/60399179 – Sats Feb 25 '20 at 16:29