Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn dependency:tree doesn't really show all dependencies [duplicate]

Tags:

java

tree

maven

I ran into an issue compile a jar with many dependencies, in particular overlapping versions of snakeyaml (we need 1.11, some dependency was pulling in 1.9). We ran mvn dependency:tree but we did not see the offending secondary version in any of the output. On further inspection, is was jruby-complete that was then pulling in snakeyaml. Why didn't mvn dependency:tree show us this level of drill down:

[INFO] |     |  +- org.apache.hbase:hbase-it:jar:0.98.6-cdh5.2.5:compile
[INFO] |     |  |  +- (org.apache.hbase:hbase-common:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  |  +- (org.apache.hbase:hbase-protocol:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  |  +- (org.apache.hbase:hbase-client:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  |  +- org.apache.hbase:hbase-shell:jar:0.98.6-cdh5.2.5:compile
[INFO] |     |  |  |  +- (org.apache.hbase:hbase-common:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  |  |  +- (org.apache.hbase:hbase-protocol:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  |  |  +- (org.apache.hbase:hbase-client:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  |  |  +- (org.apache.hbase:hbase-prefix-tree:jar:0.98.6-cdh5.2.5:runtime - omitted for duplicate)
[INFO] |     |  |  |  +- (org.apache.hbase:hbase-server:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  |  |  +- (org.apache.hbase:hbase-hadoop-compat:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  |  |  +- (org.apache.hbase:hbase-hadoop2-compat:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  |  |  +- (com.yammer.metrics:metrics-core:jar:2.2.0:compile - omitted for duplicate)
[INFO] |     |  |  |  +- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.2)
[INFO] |     |  |  |  +- org.jruby:jruby-complete:jar:1.6.8:compile
                              >>>>>>> WHY ARE THERE NO DEPENDENCIES HERE? >>>>>>>>>
[INFO] |     |  |  |  +- (org.cloudera.htrace:htrace-core:jar:2.04:compile - omitted for duplicate)
[INFO] |     |  |  |  +- (org.apache.hadoop:hadoop-common:jar:2.5.0-cdh5.2.5:compile - omitted for duplicate)

Why wasn't the dependencies of jruby-complete listed in the tree? Does mvn dependency:tree only gfo to a certain depth? What are the rules here? If mvn dependency:tree had simply shown us its snakeyaml dependency we could have saved a couple hours of complex debugging.

like image 653
David Williams Avatar asked Mar 16 '16 23:03

David Williams


People also ask

How do you analyze a dependency tree in Maven?

A project's dependency tree can be filtered to locate specific dependencies. For example, to find out why Velocity is being used by the Maven Dependency Plugin, we can execute the following in the project's directory: mvn dependency:tree -Dincludes=velocity:velocity.

Does maven override dependency version?

By taking advantage of Maven's nearest definition logic, developers can override the version of a dependency by declaring it on the root pom. xml file.

How do I run a dependency tree in Maven?

How to get the Maven Dependency Tree of a Project. We can run mvn dependency:tree command in the terminal to print the project dependency tree. For our example, I will be using the Mockito Tutorial project. You can download the project from the GitHub repository.

How do I delete and redownload Maven dependencies?

In Maven, you can use Apache Maven Dependency Plugin, goal dependency:purge-local-repository to remove the project dependencies from the local repository, and re-download it again.


1 Answers

I believe this forum topic would answer your question. The dependency tree mojo prunes lower level dependencies if the dependency is already present higher in the tree. That means that all of jruby-complete's dependencies (if it has any) are listed at a shallower depth in the tree. You can use the verbose flag (-Dverbose) to show the ommitted dependencies.

like image 199
Samuel Avatar answered Oct 25 '22 23:10

Samuel