182

A common Maven debugging technique is to use mvn dependency:tree to view the graph of project dependencies.

However, this list shows the project dependencies, not the plugin dependency tree for each plugin. Is there some way to do this from a project?

Alex Miller
  • 69,183
  • 25
  • 122
  • 167
  • 3
    Have you tried to run mvn -X ... – khmarbaise Aug 16 '11 at 07:00
  • 1
    Yes, and that is helpful for certain problems but not what I'm asking for. – Alex Miller Aug 16 '11 at 13:01
  • It contains the dependencies of a plugin otherwise there is not such thing available. – khmarbaise Aug 16 '11 at 13:02
  • @khmarbaise is correct. The dependency tree of a plugin is available in Maven's debugging output. I don't know of another way to get it, either. (If you turn this into an answer, I'll upvote it.) – Ryan Stewart Aug 16 '11 at 14:26
  • See also http://stackoverflow.com/q/312767/32453 – rogerdpack Jan 28 '14 at 23:54
  • Have you tried to create a separate pom for the purpose, where the plugin is specified as a project dependency? Then `mvn dependency:tree` should work. – George Apr 19 '16 at 00:09
  • See also http://stackoverflow.com/a/3518674 [Maven Versions Plugin](http://www.mojohaus.org/versions-maven-plugin/display-plugin-updates-mojo.html) `mvn versions:display-dependency-updates` – zloster Apr 24 '17 at 16:49

2 Answers2

151

The output via mvn -X will printout the information indirectly. Currently there is no other option to get the dependencies of a Maven-Plugin.

Update You can use the following command to get a list of plugin dependencies (resolve-plugin goal from dependencies plugin):

mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:resolve-plugins

The shorter version is (and it is a bad habit to specify plugin versions)

mvn dependency:resolve-plugins
Gonzalo Matheu
  • 8,984
  • 5
  • 35
  • 58
khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • 23
    resolve-plugins doesn't just output the dependency tree... it seems to re-download all of the packages. Not ideal. – Reinderien May 30 '15 at 07:58
  • 11
    The plugin doesn't respect overriding plugin dependencies in pom.xml (tag ``) – amra Sep 30 '15 at 11:54
  • to use of last plugin version : mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:resolve-plugins – Stéphane B. Mar 17 '16 at 09:09
  • By default maven loads dependency plugin version 2.something. Personally I managed to get better results when using 3.x version. – Dragas Jan 07 '20 at 15:18
  • 3
    It seems to resolve direct dependencies only, not transitive. – agad Feb 20 '23 at 15:10
  • @agad To get transitive dependencies, I just added the plugin as project dependency and rerun the command. – Martin P. Mar 17 '23 at 18:44
-10

If you are using any IDE like IDEA IntelliJ or Eclipse:

  • You can add this below plugin in your pom.xml
  • Once done, On the Maven window (on the right of IDE), you will find a new plugin called as Dependencies
  • Expand that and you will see the dependency:tree goal, double click on it and run it, you should see the full dependency tree

Plugin to be added in POM:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
Dean Jain
  • 1,959
  • 19
  • 15