I have a dependency structure similar to this:
A:compile
com.jolbox:bonecp:jar:0.7.1.RELEASE:compile
com.google.guava:guava:jar:r06:compile
com.google.guava:guava:jar:13.0:compile
That is, my project depends on A, which depends on Guava 13.0 and BoneCP (which depends on Guava r06).
When I run mvn clean dependency:tree | grep guava
I see:
[INFO] | | \- com.google.guava:guava:jar:13.0:compile
Which, as far as I understand Maven's dependency resolution, is what is supposed to happen.
However, when I run mvn clean package
and unpack the resulting jar, it seems Guava r06 has been included. In A, I am relying on functionality that is in Guava 13.0 but not r06, so I get a runtime failure (java.lang.NoClassDefFoundError: com/google/common/collect/Table
).
I am using the shade plugin (1.4) to create the jar with all dependencies included. Here is the result of mvn --version
(on our build server, where I am having this problem):
Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)
Maven home: /opt/apache/apache-maven-3.0.4
Java version: 1.6.0_26, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/java-6-sun-1.6.0.26/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-5-amd64", arch: "amd64", family: "unix"
On a different machine (my local workstation), the packaged jar contains Guava 13.0 as I expected. The version info on that machine is:
/usr/java/default
Apache Maven 2.2.1 (rNON-CANONICAL_2011-06-28_14-50_mockbuild; 2011-06-28 10:50:25-0400)
Java version: 1.6.0_27
Java home: /usr/java/jdk1.6.0_27/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.43.8-1.fc15.x86_64" arch: "amd64" Family: "unix"
Did the change from Maven 2.2.1 to 3.0.4 change the dependency resolution strategy? What is going on here?