How do I instruct Gradle to use the "--indy" flag when compiling my Groovy classes?

I’m using the groovy plugin, and have added the relevant groovy jar as a project dependency:

dependencies {
  compile 'org.codehaus.groovy:groovy-all:2.1.4:indy'
}

I tried to instruct the compile to use the --indy flag with:

compileGroovy.options.compilerArgs = ['--indy']

However, compilation fails with the following error:

Execution failed for task ‘:compileGroovy’. > invalid flag: --indy

tasks.withType(GroovyCompile) {
    groovyOptions.optimizationOptions.indy = true
}

See GroovyCompile and GroovyCompileOptions in the DSL reference.

1 Like

Great, thanks Peter.