compileTestGroovy returning COMPARABLE_TYPE error with @CompileStatic

(dev) #1

I’m seeing a not very useful error from Gradle, I just need to understand why. I’m adding Groovy tests to a Java project. The test compiles without using @CompileStatic. When i add the @CompileStatic it errors, why?

  Caused by: java.lang.NoSuchFieldError: COMPARABLE_TYPE

at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(

at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(  

My config is fairly basic:

  apply plugin: ‘groovy’

dependencies {

testCompile “org.codehaus.groovy:groovy-all:2.1.6” }

Any help would be much appreciated

(Peter Niederwieser) #2

We’d need to see the full stack trace (’-S’) and the code that you are trying to compile (ideally a self-contained reproducible example).

(dev) #3

Stacktrace is here:

  Gradle 1.7  ------------------------------------------------------------

 Build time:

2013-08-06 11:19:56 UTC  Build number: none  Revision:



 1.8.6  Ant:

 Apache Ant(TM) version 1.8.4 compiled on May 22 2012  Ivy:

 2.2.0  JVM:

 1.7.0_21 (Oracle Corporation 23.21-b01)  OS:

  Mac OS X 10.8.3 x86_64


There’s not much to the test class. The class is annotated with a @CompileStatic annotation. It compiles and runs fine in STS.

(Peter Niederwieser) #4

Looks like the Groovy compiler is blowing up with ‘java.lang.NoSuchFieldError: COMPARABLE_TYPE’. However, I don’t understand why parts of the stack trace are missing. Can you confirm that you ran with ‘–full-stacktrace’?

STS is hard to compare because it uses a forked version of the Groovy compiler.

(dev) #5

Hi, i ran --full-strackrace and updated the gist. Any ideas?

(Peter Niederwieser) #6

Not sure what’s going on there. Maybe you effectively have multiple Groovy versions on the test compile class path? A self-contained reproducible example would be appreciated.

(dev) #7

You were right, it looks like I had another version of Groovy in the classpath.

So my JUnit test now attempts to compile statically. Unfortunately GROOVY-6155 is blocking me making progress.

(Peter Niederwieser) #8

This bug is marked as fixed in Groovy 2.1.7/2.2.0-beta-2, which are scheduled to be released tomorrow.