dependency:tree
can be used to see the dependency tree for a given project. But what I need is to see the dependency tree for a 3rd party artifact.
I guess I can create an empty project, but I'm looking for something easier (I need to do this for several artifacts).
This question is related to
maven-2
build-process
dependencies
The solution is to call dependency:tree with the artifact's pom.xml file:
mvn -f "$HOME/.m2/repository/$POM_PATH" dependency:tree
See also How to list the transitive dependencies of an artifact from a repository?
If you bother creating a sample project and adding your 3rd party dependency to that, then you can run the following in order to see the full hierarchy of the dependencies.
You can search for a specific artifact using this maven command:
mvn dependency:tree -Dverbose -Dincludes=[groupId]:[artifactId]:[type]:[version]
According to the documentation:
where each pattern segment is optional and supports full and partial * wildcards. An empty pattern segment is treated as an implicit wildcard.
Imagine you are trying to find 'log4j-1.2-api' jar file among different modules of your project:
mvn dependency:tree -Dverbose -Dincludes=org.apache.logging.log4j:log4j-1.2-api
more information can be found here.
Edit: Please note that despite the advantages of using verbose parameter, it might not be so accurate in some conditions. Because it uses Maven 2 algorithm and may give wrong results when used with Maven 3.
I created an online tool to do this. Simply paste any dependency in pom file format, and the dependency tree for that artifact is generated, based on the central maven repository.
If your artifact is not a dependency of a given project, your best bet is to use a repository search engine. Many of them describes the dependencies of a given artifact.
If you'd like to get a graphical, searchable representation of the dependency tree (including all modules from your project, transitive dependencies and eviction information), check out UpdateImpact: https://app.updateimpact.com (free service).
Disclaimer: I'm one of the developers of the site
I know this post is quite old, but still, if anyone using IntelliJ any want to see dependency tree directly in IDE then they can install Maven Helper Plugin plugin.
Once installed open pom.xml and you would able to see Dependency Analyze tab like below. It also provides option to see dependency that is conflicted only and also as a tree structure.
If you use a current version of m2eclipse (which you should if you use eclipse and maven):
Select the menu entry
Navigate -> Open Maven POM
and enter the artifact you are looking for.
The pom will open in the pom editor, from which you can select the tab Dependency Hierarchy
to view the dependency hierarchy (as the name suggests :-) )
Source: Stackoverflow.com