In Eclipse, when I go to the Maven Dependency Hierarchy page, I get output that states what conflicts caused versions to be omitted:
However, if I use dependency:tree, that's omitted and I only see the evrsions which are actually used:
| +- commons-httpclient:commons-httpclient:jar:3.1:compile
| +- commons-codec:commons-codec:jar:1.4:compile
| +- commons-io:commons-io:jar:2.4:compile
| +- commons-net:commons-net:jar:3.1:compile
| +- javax.servlet:servlet-api:jar:2.5:compile
And later on the actually referenced versions...
+- commons-collections:commons-collections:jar:3.1:compile
Is there any way to get dependency:tree to output the versions omitted for conflict?
Thanks!
A project's dependency tree can be filtered to locate specific dependencies. For example, to find out why Velocity is being used by the Maven Dependency Plugin, we can execute the following in the project's directory: mvn dependency:tree -Dincludes=velocity:velocity.
Multiple transitive dependencies can be excluded by using the <exclusion> tag for each of the dependency you want to exclude and placing all these exclusion tags inside the <exclusions> tag in pom. xml. You will need to mention the group id and artifact id of the dependency you wish to exclude in the exclusion tag.
How to get the Maven Dependency Tree of a Project. We can run mvn dependency:tree command in the terminal to print the project dependency tree. For our example, I will be using the Mockito Tutorial project. You can download the project from the GitHub repository.
Yes, you can have the omitted artifacts by setting the verbose
attribute to true
:
Whether to include omitted nodes in the serialized dependency tree.
This attribute defaults to false
. On the command line, you would have
mvn dependency:tree -Dverbose=true
According to this, the -Dverbose=true
argument is ignored in versions 3.0 of the plugin and above. You need to use an older version; the above link suggests the following (works for me):
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree -Dverbose=true
I suggest to use the depgraph-maven-plugin.
showDuplicates
to true
dependency:tree
would show with verbose
optionshowConflicts
to trueExample config:
<plugin>
<groupId>com.github.ferstl</groupId>
<artifactId>depgraph-maven-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<showDuplicates>true</showDuplicates>
<showConflicts>true</showConflicts>
<includes>
<!-- groupId:artifactId:type:classifier -->
<include>com.mycompany*:*</include>
</includes>
</configuration>
</plugin>
Then run mvn depgraph:graph
in your project to find a new file in target/dependency-graph.dot
.
Note that you can include the plugin with scope provided
such that it will not be included in any build artifact.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With