Listing Artifact Conflicts with Maven
Posted by danielmeyer on August 28, 2008
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] | | | +- javax.xml.stream:stax-api:jar:1.0-2:compile [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] +- org.hibernate:hibernate:jar:3.2.6.ga:compile [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] BUILD SUCCESSFUL [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.