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.
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.
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 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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With