The new @Builder annotation in Groovy 2.3.0 will occur compilation error if build with Gradle(both 1.11 and 1.12)

(digitarts) #1

However, I can generate the .class file with groovyc in Groovy 2.3.0, this below is the error log:

E:\dev\content\test-ws\ii-13-groovy230-test\hello-groovy230-gradle\src\main\groovy\ClassA.groovy: 8: Can’t load builderStrategy ‘groovy.transform.builder.DefaultStrategy’ java.lang.ClassCastException: groovy.transform.builder.DefaultStrategy cannot be cast to org.codehaus.groovy.transform.BuilderASTTransformation$BuilderStrategy

@ line 8, column 1.



And this is my build.gradle as below: apply plugin: ‘groovy’

repositories {


mavenCentral() }

dependencies {


‘org.codehaus.groovy:groovy-all:2.3.0’ }


(Peter Niederwieser) #2

It’s a bug in the ‘@Builder’ implementation (‘org.codehaus.groovy.transform.BuilderASTTransformation’). It needs to load the strategy classes from the transform loader, like for example ‘org.codehaus.groovy.transform.trait.TraitASTTransformation’ does. Can you raise an issue at

(Peter Niederwieser) #3

I’ve filed for this. Thanks for the report.

(digitarts) #4

Thanks a lot.