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


(Ewan Dawson) #1

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


(Peter Niederwieser) #2
tasks.withType(GroovyCompile) {
    groovyOptions.optimizationOptions.indy = true
}

See GroovyCompile and GroovyCompileOptions in the DSL reference.


(Ewan Dawson) #3

Great, thanks Peter.