123

I would like to know which dependency described in my pom.xml brings a transitive dependency in my target directory.

To be more precise, I have the library "poi-2.5.1-final-20040804.jar" in my WEB-INF/lib directory and I would like to know which dependency in my pom.xml brings that.

Rich Seller
  • 83,208
  • 23
  • 172
  • 177
paulgreg
  • 18,493
  • 18
  • 46
  • 56

6 Answers6

162

To add to @David Crow, here's a dependency:tree example from the Maven site:

mvn dependency:tree -Dincludes=velocity:velocity

might output

[INFO] [dependency:tree]
[INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT
[INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile
[INFO]    \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile
[INFO]       \- velocity:velocity:jar:1.4:compile
A. Rex
  • 31,633
  • 21
  • 89
  • 96
  • 1
    This didn't work for me; all I got was errors about unsupported 'legacy' values. Running @David Crow's version (i.e. without the velocity flag) worked fine though. – Vlad Schnakovszki Feb 28 '17 at 13:51
58

Using the Maven Dependency Plugin:

mvn dependency:tree
David Crow
  • 16,077
  • 8
  • 42
  • 34
8

If you use eclipse and the m2eclipse plugin then there is a graphical version of dependency tree where you can filter by scope etc.

Koray Tugay
  • 22,894
  • 45
  • 188
  • 319
Brian Fox
  • 6,782
  • 4
  • 27
  • 31
2

If you run maven with "-X" switch, it will print out plenty of diagnostics. I guess the relevant dependency path can be picked up from there.

Edit: Fixed switch to uppercase.

gotomanners
  • 7,808
  • 1
  • 24
  • 39
Valters Vingolds
  • 1,271
  • 10
  • 16
  • 2
    In fact, this answer is useful. I was facing the well known [aether class undefined bug caused by upgrading my Maven from 3.0 to 3.3](https://cwiki.apache.org/confluence/display/MAVEN/AetherClassNotFound) and the following command revealed that another maven plugin was still sourcing version 3.0.5 of org.apache.maven:maven-core: `mvn -X dependency:tree -Dverbose |grep -C20 sonatype.aether` – ekarak May 05 '16 at 16:48
  • 2
    While "-X" (uppercase, alternate name "--debug") is often useful, it does not tell you the origin of a version number. Not on Maven 3.6.0 anyway. – toolforger Nov 01 '19 at 18:05
2

You can have many reports by

mvn site

One of them is the dependency report.

Bang
  • 21
  • 1
1

The dependency information is also included in the Project Information/Dependencies report if you have maven generate a site for the project, using mvn site.

Filip Korling
  • 615
  • 3
  • 7