How can I view transitive dependencies of a Maven pom.xml file?
On the CLI, use mvn dependency:tree
(Here are some additional Usage notes)
When running dependency:tree
on multi-module maven project, use mvn compile dependency:tree
instead1.
Otherwise, the POM Editor in M2Eclipse (Maven integration for Eclipse) is very good, and it includes a hierarchical dependency view.
1If you don't compile, you might get error Failed to execute goal on project baseproject: Could not resolve dependencies for project com.company:childproject:jar:1.0.0: Could not find artifact
. This might happen because dependency:tree
command doesn't build projects and doesn't resolve dependencies, and your projects are not installed in maven repository.
ryan
Updated on July 08, 2022Comments
-
ryan almost 2 years
Is there a CLI tool I can use to quickly view the transitive dependencies of a Maven pom.xml file?
-
Sridhar Sarnobat over 6 yearsThat's not really practical if you're trying to identify which transitive dependencies you are relying on at compile time. It just gives you a giant list of all transitive dependencies, used or not.
-
kisna about 6 yearsAlso, to see conflict resolution among transitive dependencies, you will need to add verbose: mvn dependency:tree -Dverbose
https://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html
-
flow2k almost 5 yearsI think the verbose option suggested by @kisna is essential - otherwise, repeated transitive dependencies will not be drawn.
-
flow2k almost 5 yearsAnother caveat: if a project uses the Shade plugin,
dependency:tree
may not be able to draw its transitive dependencies.