3

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.

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
Troy Daniels
  • 3,270
  • 2
  • 25
  • 57
  • Perhaps you'll need to write your own [transformer](https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html)? – Kedar Mhaswade Jun 01 '16 at 19:26

0 Answers0