# CompileOptions

API Documentation: | `CompileOptions`

Main options for Java compilation.

### Properties

Property | Description
`annotationProcessorPath` | The classpath to use to load annotation processors. This path is also used for annotation processor discovery.
`bootstrapClasspath` | The bootstrap classpath to be used for the compiler process. Defaults to `null`.
`compilerArgs` | Returns any additional arguments to be passed to the compiler. Defaults to the empty list. Compiler arguments not supported by the DSL can be added here. For example, it is possible to pass the `--enable-preview` option that was added in newer Java versions:
`compilerArgumentProviders` | Compiler argument providers.
`debug` | Tells whether to include debugging information in the generated class files. Defaults to `true`. See `DebugOptions.getDebugLevel()` for which debugging information will be generated.
`debugOptions` | Returns options for generating debugging information.
`deprecation` | Tells whether to log details of usage of deprecated members or classes. Defaults to `false`.
`encoding` | The character encoding to be used when reading source files. Defaults to `null`, in which case the platform default encoding will be used.
`extensionDirs` | The extension dirs to be used for the compiler process. Defaults to `null`.
`failOnError` | Tells whether to fail the build when compilation fails. Defaults to `true`.
`fork` | Tells whether to run the compiler in its own process. Note that this does not necessarily mean that a new process will be created for each compile task. Defaults to `false`.
`forkOptions` | Returns options for running the compiler in a child process.
`generatedSourceOutputDirectory` | The directory to place source files generated by annotation processors.
`headerOutputDirectory` | If this option is set to a non-null directory, it will be passed to the Java compiler's `-h` option, prompting it to generate native headers to that directory.
`incremental` | informs whether to use incremental compilation feature. See `CompileOptions.setIncremental(boolean)`
`incrementalAfterFailure` | Incubating Used to enable or disable incremental compilation after a failure.
`javaModuleMainClass` | Set the main class of the Java module, if the module is supposed to be executable.
`javaModuleVersion` | Set the version of the Java module.
`listFiles` | Tells whether to log the files to be compiled. Defaults to `false`.
`release` | Configures the Java language version for this compile task (`--release` compiler flag).
`sourcepath` | The source path to use for the compilation.
`verbose` | Tells whether to produce verbose output. Defaults to `false`.
`warnings` | Tells whether to log warning messages. The default is `true`.

### Methods

No methods

### Script blocks

No script blocks

### Property details

#### `FileCollection` `annotationProcessorPath`

The classpath to use to load annotation processors. This path is also used for annotation processor discovery.

Default with `java` plugin:
  ``sourceSet`.annotationProcessorPath`

#### `FileCollection` `bootstrapClasspath`

The bootstrap classpath to be used for the compiler process. Defaults to `null`.

Default with `java` plugin:
  `null`

#### ``List`<`String`>` `compilerArgs`

Returns any additional arguments to be passed to the compiler. Defaults to the empty list. Compiler arguments not supported by the DSL can be added here. For example, it is possible to pass the `--enable-preview` option that was added in newer Java versions:

    compilerArgs.add("--enable-preview")

Note that if `--release` is added then `-target` and `-source` are ignored.

Default with `java` plugin:
  `[]`

#### ``List`<`CommandLineArgumentProvider`>` `compilerArgumentProviders` (read-only)

Compiler argument providers.

Default with `java` plugin:
  `[]`

#### `boolean` `debug`

Tells whether to include debugging information in the generated class files. Defaults to `true`. See `DebugOptions.getDebugLevel()` for which debugging information will be generated.

Default with `java` plugin:
  `true`

#### `DebugOptions` `debugOptions` (read-only)

Returns options for generating debugging information.

#### `boolean` `deprecation`

Tells whether to log details of usage of deprecated members or classes. Defaults to `false`.

Default with `java` plugin:
  `false`

#### `String` `encoding`

The character encoding to be used when reading source files. Defaults to `null`, in which case the platform default encoding will be used.

Default with `java` plugin:
  `null`

#### `String` `extensionDirs`

The extension dirs to be used for the compiler process. Defaults to `null`.

Default with `java` plugin:
  `null`

#### `boolean` `failOnError`

Tells whether to fail the build when compilation fails. Defaults to `true`.

Default with `java` plugin:
  `true`

#### `boolean` `fork`

Tells whether to run the compiler in its own process. Note that this does not necessarily mean that a new process will be created for each compile task. Defaults to `false`.

Default with `java` plugin:
  `false`

#### `ForkOptions` `forkOptions` (read-only)

Returns options for running the compiler in a child process.

#### `DirectoryProperty` `generatedSourceOutputDirectory`

The directory to place source files generated by annotation processors.

Default with `java` plugin:
  ``${project.layout.buildDirectory}`/generated/sources/annotationProcessor/`${sourceDirectorySet.name}`/`${sourceSet.name}``

#### `DirectoryProperty` `headerOutputDirectory`

If this option is set to a non-null directory, it will be passed to the Java compiler's `-h` option, prompting it to generate native headers to that directory.

Default with `java` plugin:
  ``${project.layout.buildDirectory}`/generated/sources/headers/`${sourceDirectorySet.name}`/`${sourceSet.name}``

#### `boolean` `incremental`

informs whether to use incremental compilation feature. See `CompileOptions.setIncremental(boolean)`

Default with `java` plugin:
  `true`

#### ``Property`<`Boolean`>` `incrementalAfterFailure`

Note: This property is incubating and may change in a future version of Gradle.

Used to enable or disable incremental compilation after a failure.

By default, incremental compilation after a failure is enabled for Java and Groovy. It has no effect for Scala. It has no effect if incremental compilation is not enabled.

When the Java command line compiler is used, i.e. when a custom java home is passed to forkOptions.javaHome or javac is passed to forkOptions.executable, this optimization is automatically disabled, since the compiler is not invoked via the compiler API.

Default with `java` plugin:
  `true`

#### ``Property`<`String`>` `javaModuleMainClass`

Set the main class of the Java module, if the module is supposed to be executable.

#### ``Property`<`String`>` `javaModuleVersion`

Set the version of the Java module.

#### `boolean` `listFiles`

Tells whether to log the files to be compiled. Defaults to `false`.

Default with `java` plugin:
  `false`

#### ``Property`<`Integer`>` `release`

Configures the Java language version for this compile task (`--release` compiler flag).

If set, it will take precedences over the `AbstractCompile.getSourceCompatibility()` and `AbstractCompile.getTargetCompatibility()` settings.

This option is only taken into account by the `JavaCompile` task.

#### `FileCollection` `sourcepath`

The source path to use for the compilation.

The source path indicates the location of source files that may be compiled if necessary. It is effectively a complement to the class path, where the classes to be compiled against are in source form. It does not indicate the actual primary source being compiled.

The source path feature of the Java compiler is rarely needed for modern builds that use dependency management.

The default value for the source path is `null`, which indicates an empty source path. Note that this is different to the default value for the `-sourcepath` option for `javac`, which is to use the value specified by `-classpath`. If you wish to use any source path, it must be explicitly set.

Default with `java` plugin:
  `null`

#### `boolean` `verbose`

Tells whether to produce verbose output. Defaults to `false`.

Default with `java` plugin:
  `false`

#### `boolean` `warnings`

Tells whether to log warning messages. The default is `true`.

Default with `java` plugin:
  `true`