2

I have a (long) list of what should not be included in my uber-jar, and I would like the list of what is included, so that I can work on the configuration and remove duplicates.

I looked at the output printed by mvn package that lists a lot of

[INFO] Including aaa.bbb:ccc.ddd:jar:x.y.z in the shaded jar

but I am pretty sure some of those were not included when I used the minimizeJar option. And looking into the output jar only allows to know the included classes (very difficult to track w.r.t the dependencies)

Question: Which ever configuration I use, how can I get a list of the dependencies that are actually merged into the uberjar?

Juh_
  • 14,628
  • 8
  • 59
  • 92
  • Already the list of what is *not* included will give you hints about where you tweak the configuration or remove dependencies from the project? – khmarbaise Jun 18 '20 at 06:20
  • All information can be good, but not really. What I am looking for is an easy way to check whether all dep present in a deployment cluster are not included in the fat-jar, but there are tones of dep in the project I am working on. – Juh_ Jun 18 '20 at 07:19

2 Answers2

0

I'm not familiar with the maven-shade-plugin, but have you tried out mvn dependency:tree? It should list all dependencies and its subdependencies of your project.

Edit: I re-read your question and it seems that you need a full dependency tree of your final uber-jar. A quick look at the maven-shade-plugin page told me that any dependency will be packed into the uber-jar. This should be what mvn dependency:tree outputs, but you can list the jar's contents aswell with jar tf <uber-jar>.jar. You may have to filter out parent dirs (e. g. com/) and the manifest file.

Crude Code
  • 137
  • 1
  • 9
0

This is not the answer I am looking for, but for the sake of information sharing, here is what I did to find which dependency to remove from the shaded-jar:

  • use mvn dependency:list > dep.list
    • then manually remove lines that are not dependencies
    • and sort it
  • visually make a diff with the list of jar present on the deployment cluster
  • use mvn dependency:tree and my head to find the parent most dependencies that can be removed
  • mark them as <scope>provided<scope/>
  • use <keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope> in the shade plugin configuration

Tedious...

Juh_
  • 14,628
  • 8
  • 59
  • 92