Package org.gradle.api.tasks.compile

# Class GroovyCompileOptions

java.lang.Object
org.gradle.api.tasks.compile.GroovyCompileOptions

All Implemented Interfaces:
  `Serializable`

public abstract class GroovyCompileOptions extends Object implements Serializable
Compilation options to be passed to the Groovy compiler.

See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GroovyCompileOptions()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `forkOptions(Action<? super GroovyForkOptions> action)`
  Execute the given action against `getForkOptions()`.
  `@Nullable File`
  `getConfigurationScript()`
  A Groovy script file that configures the compiler, allowing extensive control over how the code is compiled.
  `abstract SetProperty<String>`
  `getDisabledGlobalASTTransformations()`
  Returns the set of global AST transformations which should not be loaded into the Groovy compiler.
  `String`
  `getEncoding()`
  Tells the source encoding.
  `List<String>`
  `getFileExtensions()`
  Returns the list of acceptable source file extensions.
  `abstract GroovyForkOptions`
  `getForkOptions()`
  Returns options for running the Groovy compiler in a separate process.
  `protected abstract ObjectFactory`
  `getObjectFactory()`
  `@Nullable Map<String,Boolean>`
  `getOptimizationOptions()`
  Returns optimization options for the Groovy compiler.
  `File`
  `getStubDir()`
  Returns the directory where Java stubs for Groovy classes will be stored during Java/Groovy joint compilation.
  `boolean`
  `isFailOnError()`
  Tells whether the compilation task should fail if compile errors occurred.
  `boolean`
  `isFork()`
  Tells whether to run the Groovy compiler in a separate process.
  `boolean`
  `isJavaAnnotationProcessing()`
  Whether the Groovy code should be subject to Java annotation processing.
  `boolean`
  `isKeepStubs()`
  Tells whether Java stubs for Groovy classes generated during Java/Groovy joint compilation should be kept after compilation has completed.
  `boolean`
  `isListFiles()`
  Tells whether to print which source files are to be compiled.
  `boolean`
  `isParameters()`
  Whether the Groovy compiler generate metadata for reflection on method parameter names on JDK 8 and above.
  `boolean`
  `isVerbose()`
  Tells whether to turn on verbose output.
  `void`
  `setConfigurationScript(@Nullable File configurationFile)`
  Sets the path to the groovy configuration file.
  `void`
  `setEncoding(String encoding)`
  Sets the source encoding.
  `void`
  `setFailOnError(boolean failOnError)`
  Sets whether the compilation task should fail if compile errors occurred.
  `void`
  `setFileExtensions(List<String> fileExtensions)`
  Sets the list of acceptable source file extensions.
  `void`
  `setFork(boolean fork)`
  Sets whether to run the Groovy compiler in a separate process.
  `void`
  `setJavaAnnotationProcessing(boolean javaAnnotationProcessing)`
  Sets whether Java annotation processors should process annotations on stubs.
  `void`
  `setKeepStubs(boolean keepStubs)`
  Sets whether Java stubs for Groovy classes generated during Java/Groovy joint compilation should be kept after compilation has completed.
  `void`
  `setListFiles(boolean listFiles)`
  Sets whether to print which source files are to be compiled.
  `void`
  `setOptimizationOptions(@Nullable Map<String,Boolean> optimizationOptions)`
  Sets optimization options for the Groovy compiler.
  `void`
  `setParameters(boolean parameters)`
  Sets whether metadata for reflection on method parameter names should be generated.
  `void`
  `setStubDir(File stubDir)`
  Sets the directory where Java stubs for Groovy classes will be stored during Java/Groovy joint compilation.
  `void`
  `setVerbose(boolean verbose)`
  Sets whether to turn on verbose output.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### GroovyCompileOptions

    public GroovyCompileOptions()

- ## Method Details

  - ### getObjectFactory

    @Inject protected abstract ObjectFactory getObjectFactory()

  - ### isFailOnError

    @Input public boolean isFailOnError()
    Tells whether the compilation task should fail if compile errors occurred. Defaults to `true`.

  - ### setFailOnError

    public void setFailOnError(boolean failOnError)
    Sets whether the compilation task should fail if compile errors occurred. Defaults to `true`.

  - ### isVerbose

    @Console public boolean isVerbose()
    Tells whether to turn on verbose output. Defaults to `false`.

  - ### setVerbose

    public void setVerbose(boolean verbose)
    Sets whether to turn on verbose output. Defaults to `false`.

  - ### isListFiles

    @Console public boolean isListFiles()
    Tells whether to print which source files are to be compiled. Defaults to `false`.

  - ### setListFiles

    public void setListFiles(boolean listFiles)
    Sets whether to print which source files are to be compiled. Defaults to `false`.

  - ### getEncoding

    @Input public String getEncoding()
    Tells the source encoding. Defaults to `UTF-8`.

  - ### setEncoding

    public void setEncoding(String encoding)
    Sets the source encoding. Defaults to `UTF-8`.

  - ### isFork

    @Input public boolean isFork()
    Tells whether to run the Groovy compiler in a separate process. Defaults to `true`.

  - ### setFork

    public void setFork(boolean fork)
    Sets whether to run the Groovy compiler in a separate process. Defaults to `true`.

  - ### getConfigurationScript

    @Optional @PathSensitive(NONE) @InputFile public @Nullable File getConfigurationScript()
    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:

    - The instance of CompilerConfiguration available as the `configuration` variable.
    - All static members of CompilerCustomizationBuilder pre imported.

    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.

    See Also:
      - CompilerConfiguration
      - CompilerCustomizationBuilder

  - ### setConfigurationScript

    public void setConfigurationScript(@Nullable File configurationFile)
    Sets the path to the groovy configuration file.
    See Also:
      - `getConfigurationScript()`

  - ### isJavaAnnotationProcessing

    @Input public boolean isJavaAnnotationProcessing()
    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.

  - ### setJavaAnnotationProcessing

    public void setJavaAnnotationProcessing(boolean javaAnnotationProcessing)
    Sets whether Java annotation processors should process annotations on stubs. Defaults to `false`.

  - ### isParameters

    @Input public boolean isParameters()
    Whether the Groovy compiler generate metadata for reflection on method parameter names on JDK 8 and above.
    Since:
      6.1

  - ### setParameters

    public void setParameters(boolean parameters)
    Sets whether metadata for reflection on method parameter names should be generated. Defaults to `false`
    Since:
      6.1

  - ### getForkOptions

    public abstract GroovyForkOptions getForkOptions()
    Returns options for running the Groovy compiler in a separate process. These options only take effect if `fork` is set to `true`.

  - ### forkOptions

    public void forkOptions(Action<? super GroovyForkOptions> action)
    Execute the given action against `getForkOptions()`.
    Since:
      8.11

  - ### getOptimizationOptions

    @Optional @Input public @Nullable Map<String,Boolean> getOptimizationOptions()
    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.

  - ### setOptimizationOptions

    public void setOptimizationOptions(@Nullable Map<String,Boolean> optimizationOptions)
    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.

  - ### getDisabledGlobalASTTransformations

    @Input public abstract SetProperty<String> getDisabledGlobalASTTransformations()
    Returns the set of global AST transformations which should not be loaded into the Groovy compiler.
    Since:
      7.4
    See Also:
      - CompilerConfiguration

  - ### getStubDir

    @Internal public File getStubDir()
    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.

  - ### setStubDir

    public void setStubDir(File stubDir)
    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.

  - ### getFileExtensions

    @Input public List<String> getFileExtensions()
    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")`.

  - ### setFileExtensions

    public void setFileExtensions(List<String> fileExtensions)
    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")`.

  - ### isKeepStubs

    @Input public boolean isKeepStubs()
    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`.

  - ### setKeepStubs

    public void setKeepStubs(boolean keepStubs)
    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`.