How do I filter dependencies when I run mvn dependency:tree?

I just ran into this link and thought I would share it with you.

This gives you the ability to filter out maven dependencies when you run mvn dependency:tree

  • Just want the SNAPSHOT dependencies, do this:
    mvn dependency:tree -Dincludes=:::*-SNAPSHOT
  • Looking for conflicts on your commons-collections projects:
    mvn dependency:tree -Dverbose -Dincludes=commons-collections
    • Notice in this example two different version appear……
      [INFO] [dependency:tree]
      [INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT
      [INFO] +- org.apache.maven.reporting:maven-reporting-impl:jar:2.0.4:compile
      [INFO] |  \- commons-validator:commons-validator:jar:1.2.0:compile
      [INFO] |     \- commons-digester:commons-digester:jar:1.6:compile
      [INFO] |        \- (commons-collections:commons-collections:jar:2.1:compile - omitted for conflict with 2.0)
      [INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile
      [INFO]    \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile
      [INFO]       \- commons-collections:commons-collections:jar:2.0:compile

Hope it helps

It's only fair to share...
Share on Facebook
Tweet about this on Twitter
Share on LinkedIn

Leave a Reply