0

I'm trying to package my project using Maven Shade Plugin.

I've configured it in POM xml and run 'package' goal to get executable jar.

When i checked the console after running package goal, I found that I've duplication of the jars in my pom and the shade plugin is keeping just the first dependency and not both.

I tried running it and it fails because of that dependency.

Is there any configuration in Maven shade through which I can keep both the original and duplicate dependency in the executable jar.

TIA

Edit: I've included the console which states duplicate dependency.

[WARNING] maven-shade-plugin has detected that some .class files
[WARNING] are present in two or more JARs. When this happens, only
[WARNING] one single version of the class is copied in the uberjar.
[WARNING] Usually this is not harmful and you can skip these
[WARNING] warnings, otherwise try to manually exclude artifacts
[WARNING] based on mvn dependency:tree -Ddetail=true and the above

I'm trying to create a executable jar from spring+hibernate project

Edit#2: Failure was not because of dependency, it was because I had missed out on transformers for spring resources. However I'm still curious if we can configure Maven Shade to have duplicate classes. Thanks.

BadumTsch
  • 3
  • 4
  • 1
    Add relevant sections from your pom.xml and describe in more detail what happens with your dependencies and then maybe it will be possible to answer your question. – Oleg Aug 03 '17 at 08:37
  • Hi I've edited to provide the error details – BadumTsch Aug 03 '17 at 10:34
  • This is not helpful. You can't just keep both, maven shade can't put 2 different classes that have the same name and the same package in the same place. Try to make it use the other version and see if your program works. – Oleg Aug 03 '17 at 11:45
  • Hi, Thanks for suggestions, I was able to package it into jar. I had missed out on configuring transformers for resources (spring schemas). However I'm still curious if we can have duplicate classes in maven shade – BadumTsch Aug 04 '17 at 06:23
  • If you already have duplicates in your current project shade can't help you. It can help you prevent those problems as explained nicely in [this answer](https://stackoverflow.com/a/13620420/1398418) – Oleg Aug 04 '17 at 06:37
  • That was helpful. Thanks – BadumTsch Aug 04 '17 at 06:46

0 Answers0