Reputation: 35
It is possible to include a local file in your pom.xml by either installing the jar-File in your local repository or provide a link to the local jar and set the scope to "system". What would happen if I include a fat jar (= a jar containing all transitive dependencies)? Would Maven still be able to detect dependency conflicts correctly and would I still be able to exclude some of the transitive dependencies of my "fat jar dependency"?
The thing is that I am working on a legacy software project, which did not use any built tool / dependency management tool before (so all the needed jars were just downloaded and added to the classpath). I am trying to convert it to a Maven project. This is not very difficult for all open source dependencies (as nearly all of them are available in Maven Central or in other repositories). In some cases, we have proprietary libraries that were acquired a long time ago and are available as fat jar.
Would the maven shade plugin help in this case?
Upvotes: 0
Views: 871
Reputation: 35805
Fat JARs as dependencies are dangerous because if a fat jar contains the contents of x.jar
and x.jar
is also present on the classpath, then you usually get a conflict. Maven will not resolve the conflict because Maven has no knowledge which JARs are included in your fat JAR.
So when you have a fat JAR dependency you need to make sure that everything inside the fat JAR is not a dependency elsewhere in the project, and if so, you should exclude it.
If you shade the content, you might get away without such conflicts.
Upvotes: 0