views:

31

answers:

3

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).

+3  A: 

1) Use maven dependency plugin

Create a simple project with pom.xml only. Add your dependency and run:

mvn dependency:tree

Unfortunately dependency mojo must use pom.xml or you get following error:

Cannot execute mojo: tree. It requires a project with an existing pom.xml, but the build is not using one.

2) Find pom.xml of your artifact

In pom.xml of your artifact are dependencies described. See a example for a org.springframework:spring-core

3) Use maven dependency plugin against your artifact

Part of dependency artifact is a pom.xml. That specifies it's dependency. And you can execute mvn dependency:tree on this pom.

amra
Like I said, I want to avoid the need to create a project
IttayD
you're not 'creating' a project, you're just downloading a POM file.
seanizer
You don't have to create a new project. Just take a look into your local repository and find the atifact's pom.xml
amra
+1  A: 

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 :-) )

seanizer
I use Intellij Idea
IttayD
OK, then this answer is for other users :-)
seanizer
+1  A: 

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.

Pascal Thivent
the artifacts i'm interested in are part of a company product
IttayD
then amra's answer is your best bet, I am afraid.
seanizer
@IttayD: Why don't you mention this kind of *important* detail in your question? This would help to get better answers IMHO (and might also help readers to not waste their time).
Pascal Thivent