Listing Artifact Conflicts with Maven

As we discussed yesterday, something I lack at the moment is a quick way of finding out if my project’s dependencies include the same artifact twice — for instance, two different versions of the same artifact.  (I think Maven already has rules to deal with this type of situation, but because the app server can be finicky about this type of thing, I’d still like an easy way to find out if I have two transitive dependencies on the same artifactId.)

Well…the Maven website has a great little article titled Resolving conflicts using the dependency tree that demonstrates using the verbose option to dependency:tree.  Let’s see what happens if we use that on our same project as before (arguments to Maven: dependency:tree -Dverbose):

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ------------------------------------------------------------------------
[INFO] Building JNDI via Bitronix Transaction Manager
[INFO]    task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] [dependency:tree]
[INFO] com.ontsys.research.jndi.jndi-bitronix:jndi-bitronix:jar:1-SNAPSHOT
[INFO] +- log4j:log4j:jar:1.2.15:compile
[INFO] +- org.apache.activemq:activemq-core:jar:5.1.0:compile
[INFO] |  +- commons-logging:commons-logging-api:jar:1.1:compile
[INFO] |  +- org.apache.camel:camel-core:jar:1.3.0:compile
[INFO] |  |  +- (commons-logging:commons-logging-api:jar:1.0.4:compile - omitted for conflict with 1.1)
[INFO] |  |  +- javax.xml.bind:jaxb-api:jar:2.1:compile
[INFO] |  |  |  +-
[INFO] |  |  |  - javax.activation:activation:jar:1.1:compile
[INFO] |  |  - com.sun.xml.bind:jaxb-impl:jar:2.1.3:compile
[INFO] |  |     - (javax.xml.bind:jaxb-api:jar:2.1:compile - omitted for duplicate)
[INFO] |  +- org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1.1:compile
[INFO] |  - org.apache.geronimo.specs:geronimo-j2ee-management_1.0_spec:jar:1.0:compile
[INFO] |  - (org.springframework:spring-beans:jar:2.5.5:compile - omitted for duplicate)
[INFO] +-
[INFO] |  +- net.sf.ehcache:ehcache:jar:1.2.3:compile
[INFO] |  |  +- (commons-logging:commons-logging:jar:1.0.4:compile - omitted for conflict with 1.1.1)
[INFO] |  |  - (commons-collections:commons-collections:jar:2.1:compile - omitted for conflict with 2.1.1)
[INFO] |  +- (commons-logging:commons-logging:jar:1.0.4:compile - omitted for conflict with 1.1.1)
[INFO] |  +- asm:asm-attrs:jar:1.5.3:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Wed Aug 27 13:20:13 EDT 2008
[INFO] Final Memory: 12M/23M
[INFO] ------------------------------------------------------------------------

I think the “omitted for conflict” lines would be the ones we’d be most interested in analyzing.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.