25

In Eclipse, when I go to the Maven Dependency Hierarchy page, I get output that states what conflicts caused versions to be omitted:

eclipse maven version

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!

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Robert Fraser
  • 10,649
  • 8
  • 69
  • 93

3 Answers3

25

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
Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • 6
    This only works until dependency plugin version 3.0. With 3.1, you have to use option -X. But then you still do not see omitted dependencies. What do I need to do then? – Kathi Jul 12 '18 at 08:30
  • 2
    The only option I've found is to use an older version of dependency plugin: `mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree -Dverbose=true`. There's a warning though: `Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution`. It's still better than nothing. – Gediminas Rimsa Nov 27 '18 at 12:40
  • For me, `-Dverbose` does work in Maven 3.6. But it does not work together with `-DoutputType=dot` – mihca Jun 23 '21 at 14:13
4

I suggest to use the depgraph-maven-plugin.

  • to see all dependencies, set showDuplicates to true
    • this will include dependencies that dependency:tree would show with verbose option
  • to see conflicts, set showConflicts to true
  • has various filters to include/exclude projects
  • can export to various formats, including dot file that can be rendered with GraphViz

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

mihca
  • 997
  • 1
  • 10
  • 29
  • 5
    Just a little addition: If you want to quickly analyse your module dependencies (without adding the plugin to your project), just run `mvn com.github.ferstl:depgraph-maven-plugin:3.3.0:graph -DrepeatTransitiveDependenciesInTextGraph -DshowVersions -DgraphFormat=text -DshowGroupIds -DshowConflicts -DshowDuplicates` in the folder of your module. – David Georg Reichelt Sep 28 '21 at 11:07
3

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
Nat Ritmeyer
  • 5,634
  • 8
  • 45
  • 58