Is there an easier way to get the dependency tree of a Maven plugin, other than to checkout its sources and run a mvn dependency:tree
against them?

- 31,231
- 29
- 115
- 197
-
http://maven.apache.org/plugins/maven-dependency-plugin/list-mojo.html – Indra Uprade Jul 20 '16 at 14:20
-
@IndraUprade: This is not what I need. This is a flat representation of the current `pom.xml`'s dependencies. – carlspring Jul 20 '16 at 14:30
-
1See this http://stackoverflow.com/questions/7074590/how-can-you-display-the-maven-dependency-tree-for-the-plugins-in-your-project. There is no real built-in ways I'm afraid. – Tunaki Jul 20 '16 at 14:35
2 Answers
Instead of checking out the concerned plugin' sources, you can still add it as a dependency of your project and then check its dependency tree as any other maven dependency.
A maven plugin is a jar
file afterall and could be added as any other maven dependency (not really meaningful, unless in the context of maven plugin development).
For instance, we could had the maven-dependency-plugin
as a dependency:
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<scope>test</scope>
</dependency>
Note the scope
for purity, even though you would probably remove the dependency from your project after the required checks.
Now you can run on this project dependency:tree
and check the dependencies of this plugin, narrowing down its output via the includes
property is required.

- 26,902
- 7
- 94
- 128
-
A neat hack! Although... if you do it this way, you should also better use `-Dverbose=true` (because some of the project's dependencies my cause the dependencies of the plugin to be replaced in the dependency tree). Not the most elegant solution, but I suppose it will do the trick. – carlspring Jul 20 '16 at 15:42
-
2Also, in my example I should have used a different plugin as dependency: here you are using the dependency plugin to check dependencies of the dependency plugin, this could break the Internet – A_Di-Matteo Jul 20 '16 at 15:43
This is not the exact thing you want but little closer to that, at least it will analyze the dependencies and list out all the warnings upfront.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>Dependency-Analyzer</id>
<phase>package</phase>
<goals>
<goal>analyze-only</goal>
</goals>
</execution>
</executions>
</plugin>

- 773
- 5
- 12