[GRADLE-2962] Test execution failure when duplicate Guava classes on test classpath Created: 26/Nov/13 Updated: 25/Mar/14 Resolved: 21/Mar/14 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | 1.12-rc-1 |
Type: | Bug | ||
Reporter: | Gradle Forums | Assignee: | Luke Daley |
Resolution: | Fixed | Votes: | 11 |
Description |
I have a project that pulls in a shaded jar that contains guava (and without relocating the guava classes to a package of their own). When running gradle test I get an exception |
Comments |
Comment by Gradle Forums [ 26/Nov/13 ] |
There shouldn't be any conflict between your and Gradle's Guava classes when running tests. Would you be able to provide a self-contained reproducible example? |
Comment by Gradle Forums [ 26/Nov/13 ] |
Yes, actually the interaction is a bit more complex. We pull in guava and hive-exec is the shaded jar containing guava. It occurs with a simple module with the following dependencies { |
Comment by Gradle Forums [ 26/Nov/13 ] |
Does your (main or test) code make use of `org.gradle.internal.SystemProperties`? |
Comment by Gradle Forums [ 26/Nov/13 ] |
The problem shows up even with a simple empty test when running gradle test in combination with this build file apply plugin: 'java' sourceCompatibility = 1.7 repositories { dependencies { import org.junit.Test; public class TestCase { |
Comment by Konrad Jamrozik [ 30/Nov/13 ] |
I had a the same exception when running the test task of groovy plugin. Removing guava 15.0 from the classpath of the test task solved the problem for me as a temporary workaround. My workaround snippet project(":projectName") { apply plugin: 'groovy' (...) /* Workaround for: http://issues.gradle.org/browse/GRADLE-2962 Last reviewed on 1 Dec 2013. */ test.doFirst { classpath -= fileTree(dir: "$dirWithGuavaJar", include: "guava*.jar") } } Please note that the workaround causes fallback to guava used by gradle 1.9, that is, 14.0.1 (source: Gradle Forums topic; link above). You cannot use newer version of Guava using this workaround. |
Comment by Sebastien Tardif [ 19/Feb/14 ] |
This bug was confirmed as a regression: Should this issue be fixed faster than others because it's a regression? I see that it's not assigned to anyone. I think the bug tracker should have the flag "regression" and mention version introducing issues. |
Comment by Jasdeep Hundal [ 10/Mar/14 ] |
I've noticed issues with duplicate guava classes in versions prior to 1.10 as well (for example: this function being present in Guava 12 and onwards, which causes exceptions when gradle 1.8 loads guava 11: https://code.google.com/p/guava-libraries/source/browse/guava/src/com/google/common/base/Objects.java#219). This issue could just be manifesting in more ways with the update to guava-jdk5. That being said, I'm currently running off gradle 1.10 and hurting everywhere when trying to use libraries that depend on the latest versions of Guava. If there's a good way to exclude specific versions of packages at runtime, I would love to know it. A quick peek into the source code suggests this might not be the case: https://github.com/gradle/gradle/blob/master/subprojects/core/src/main/groovy/org/gradle/process/internal/child/WorkerProcessClassPathProvider.java#L69 |