Unless I add exclusions for asm, my tests always fail with:
“java.lang.IncompatibleClassChangeError: Found interface org.objectweb.asm.MethodVisitor, but class was expected”
From other posts, it seems that the conflict is between older versions of asm and the newer 4.0 version used by Gradle 1.2. I have to add exclusions to each of my dependencies that themselves have a dependency on asm < 4.0. If I remove the exclusions in the file below, I get the errors; it works as is.
Am I doing something wrong? Can I get isolation between the Gradle classpath and my project’s classpath?
— My build.gradle -----------------
apply plugin: ‘groovy’ apply plugin: ‘war’ apply plugin: ‘jetty’
repositories {
mavenCentral() }
dependencies {
groovy ‘org.codehaus.groovy:groovy:2.0.5’
testCompile ‘junit:junit:4.10’
compile “com.google.inject:guice:3.0” exclude group: ‘asm’, module: ‘asm’
compile “com.google.guava:guava:13.0.1”
compile “com.sun.jersey:jersey-core:1.14”
compile “com.sun.jersey:jersey-server:1.14” exclude group: ‘asm’, module: ‘asm’
compile “com.sun.jersey:jersey-servlet:1.14”
compile “com.sun.jersey:jersey-json:1.14”
compile “com.sun.jersey.contribs:jersey-guice:1.14” exclude group: ‘asm’, module: ‘asm’
compile “javax.servlet:javax.servlet-api:3.0.1” }
— My test case: ------------------ import org.junit.Test
import static org.junit.Assert.* import static org.hamcrest.CoreMatchers.*
class SimpleTest {
@Test
public void testSomething() {
assertThat 1, is(1)
} } -------------------------------------------