api / org.gradle.api.tasks.compile / GroovyCompileOptions

GroovyCompileOptions

open class GroovyCompileOptions : AbstractOptions

Compilation options to be passed to the Groovy compiler.

Constructors

<init>

GroovyCompileOptions()

Compilation options to be passed to the Groovy compiler.

Functions

fork

open fun fork(forkArgs: MutableMap<String, Any>): GroovyCompileOptions

Convenience method to set GroovyForkOptions with named parameter syntax. Calling this method will set fork to true.

getConfigurationScript

open fun getConfigurationScript(): File

A Groovy script file that configures the compiler, allowing extensive control over how the code is compiled.

The script is executed as Groovy code, with the following context:

This facilitates the following pattern:

 withConfig(configuration) { // use compiler configuration DSL here } 

For example, to activate type checking for all Groovy classes…

 import groovy.transform.TypeChecked withConfig(configuration) { ast(TypeChecked) } 

Please see the Groovy compiler customization builder documentation for more information about the compiler configuration DSL.

This feature is only available if compiling with Groovy 2.1 or later.

getEncoding

open fun getEncoding(): String

Tells the source encoding. Defaults to UTF-8.

getFileExtensions

open fun getFileExtensions(): MutableList<String>

Returns the list of acceptable source file extensions. Only takes effect when compiling against Groovy 1.7 or higher. Defaults to ImmutableList.of("java", "groovy").

getForkOptions

open fun getForkOptions(): GroovyForkOptions

Returns options for running the Groovy compiler in a separate process. These options only take effect if fork is set to true.

getOptimizationOptions

open fun getOptimizationOptions(): MutableMap<String, Boolean>

Returns optimization options for the Groovy compiler. Allowed values for an option are true and false. Only takes effect when compiling against Groovy 1.8 or higher.

Known options are:

indy Use the invokedynamic bytecode instruction. Requires JDK7 or higher and Groovy 2.0 or higher. Disabled by default. int Optimize operations on primitive types (e.g. integers). Enabled by default. all Enable or disable all optimizations. Note that some optimizations might be mutually exclusive.

getStubDir

open fun getStubDir(): File

Returns the directory where Java stubs for Groovy classes will be stored during Java/Groovy joint compilation. Defaults to null, in which case a temporary directory will be used.

isFailOnError

open fun isFailOnError(): Boolean

Tells whether the compilation task should fail if compile errors occurred. Defaults to true.

isFork

open fun isFork(): Boolean

Tells whether to run the Groovy compiler in a separate process. Defaults to true.

isJavaAnnotationProcessing

open fun isJavaAnnotationProcessing(): Boolean

Whether the Groovy code should be subject to Java annotation processing.

Annotation processing of Groovy code works by having annotation processors visit the Java stubs generated by the Groovy compiler in order to support joint compilation of Groovy and Java source.

When set to true, stubs will be unconditionally generated for all Groovy sources, and Java annotations processors will be executed on those stubs.

When this option is set to false (the default), Groovy code will not be subject to annotation processing, but any joint compiled Java code will be. If the compiler argument "-proc:none" was specified as part of the Java compile options, the value of this flag will be ignored. No annotation processing will be performed regardless, on Java or Groovy source.

isKeepStubs

open fun isKeepStubs(): Boolean

Tells whether Java stubs for Groovy classes generated during Java/Groovy joint compilation should be kept after compilation has completed. Useful for joint compilation debugging purposes. Defaults to false.

isListFiles

open fun isListFiles(): Boolean

Tells whether to print which source files are to be compiled. Defaults to false.

isVerbose

open fun isVerbose(): Boolean

Tells whether to turn on verbose output. Defaults to false.

optionMap

open fun optionMap(): MutableMap<String, Any>

Internal method.

setConfigurationScript

open fun setConfigurationScript(configurationFile: File): Unit

Sets the path to the groovy configuration file.

setEncoding

open fun setEncoding(encoding: String): Unit

Sets the source encoding. Defaults to UTF-8.

setFailOnError

open fun setFailOnError(failOnError: Boolean): Unit

Sets whether the compilation task should fail if compile errors occurred. Defaults to true.

setFileExtensions

open fun setFileExtensions(fileExtensions: MutableList<String>): Unit

Sets the list of acceptable source file extensions. Only takes effect when compiling against Groovy 1.7 or higher. Defaults to ImmutableList.of("java", "groovy").

setFork

open fun setFork(fork: Boolean): Unit

Sets whether to run the Groovy compiler in a separate process. Defaults to true.

setForkOptions

open fun setForkOptions(forkOptions: GroovyForkOptions): Unit

Sets options for running the Groovy compiler in a separate process. These options only take effect if fork is set to true.

setJavaAnnotationProcessing

open fun setJavaAnnotationProcessing(javaAnnotationProcessing: Boolean): Unit

Sets whether Java annotation processors should process annotations on stubs. Defaults to false.

setKeepStubs

open fun setKeepStubs(keepStubs: Boolean): Unit

Sets whether Java stubs for Groovy classes generated during Java/Groovy joint compilation should be kept after compilation has completed. Useful for joint compilation debugging purposes. Defaults to false.

setListFiles

open fun setListFiles(listFiles: Boolean): Unit

Sets whether to print which source files are to be compiled. Defaults to false.

setOptimizationOptions

open fun setOptimizationOptions(optimizationOptions: MutableMap<String, Boolean>): Unit

Sets optimization options for the Groovy compiler. Allowed values for an option are true and false. Only takes effect when compiling against Groovy 1.8 or higher.

setStubDir

open fun setStubDir(stubDir: File): Unit

Sets the directory where Java stubs for Groovy classes will be stored during Java/Groovy joint compilation. Defaults to null, in which case a temporary directory will be used.

setVerbose

open fun setVerbose(verbose: Boolean): Unit

Sets whether to turn on verbose output. Defaults to false.

Inherited Functions

define

open fun define(args: MutableMap<String, Any>): Unit