I am trying to use the Maven Shade plugin to build an uber-jar
. Two of my dependencies include classes with the same name, in the same package, which have different implementations. I know this is a bad idea, but I do not have control over those depedencies. I know that, if a class shows up in A.jar
and in B.jar
, then the version in B.jar
is the one I want to use.
Is there a way to tell the Shade plugin which jar
to use when there is a conflict?
I am currently manually building a list of the conflicts and using a filter to exclude them from A.jar
. That should work, but an having Shade pick the correct one would be simpler and future proof.
The dependency is a transitive dependency, so it is not obvious that "list B
before A
in your POM" will work. It might work if you list the dependencies explicitly, although I was unable to find any information about how it picks when there are duplicates.