How can I view transitive dependencies of a Maven pom.xml file?

60,283

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.

Share:
60,283
ryan
Author by

ryan

Updated on July 08, 2022

Comments

  • ryan
    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
    Sridhar Sarnobat over 6 years
    That'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
    kisna about 6 years
    Also, 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/exa‌​mples/resolving-conf‌​licts-using-the-depe‌​ndency-tree.html
  • flow2k
    flow2k almost 5 years
    I think the verbose option suggested by @kisna is essential - otherwise, repeated transitive dependencies will not be drawn.
  • flow2k
    flow2k almost 5 years
    Another caveat: if a project uses the Shade plugin, dependency:tree may not be able to draw its transitive dependencies.