api / org.gradle.api.tasks.compile / CompileOptions

CompileOptions

open class CompileOptions : AbstractOptions

Main options for Java compilation.

Constructors

<init>

CompileOptions(objectFactory: ObjectFactory)

Functions

debug

open fun debug(debugArgs: MutableMap<String, Any>): CompileOptions

Convenience method to set DebugOptions with named parameter syntax. Calling this method will set debug to true.

fork

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

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

getAllCompilerArgs

open fun getAllCompilerArgs(): MutableList<String>

Returns all compiler arguments, added to the #getCompilerArgs() or the #getCompilerArgumentProviders() property.

getAnnotationProcessorGeneratedSourcesDirectory

open fun getAnnotationProcessorGeneratedSourcesDirectory(): File

Returns the directory to place source files generated by annotation compilers.

getAnnotationProcessorPath

open fun getAnnotationProcessorPath(): FileCollection

Returns the classpath to use to load annotation processors. This path is also used for annotation processor discovery. If set to null, it means use the compile classpath.

getBootClasspath

open fun getBootClasspath(): String

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

getBootstrapClasspath

open fun getBootstrapClasspath(): FileCollection

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

getCompilerArgs

open fun getCompilerArgs(): MutableList<String>

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 --release option of JDK 9:

compilerArgs.addAll(['--release', '7'])
Note that if --release is added then -target and -source are ignored.

getCompilerArgumentProviders

open fun getCompilerArgumentProviders(): MutableList<CommandLineArgumentProvider>

Compiler argument providers.

getDebugOptions

open fun getDebugOptions(): DebugOptions

Returns options for generating debugging information.

getEncoding

open fun getEncoding(): String

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

getExtensionDirs

open fun getExtensionDirs(): String

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

getForkOptions

open fun getForkOptions(): ForkOptions

Returns options for running the compiler in a child process.

getSourcepath

open fun getSourcepath(): FileCollection

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.

isDebug

open fun isDebug(): Boolean

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

isDeprecation

open fun isDeprecation(): Boolean

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

isFailOnError

open fun isFailOnError(): Boolean

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

isFork

open fun isFork(): Boolean

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.

isIncremental

open fun isIncremental(): Boolean

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

isListFiles

open fun isListFiles(): Boolean

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

isVerbose

open fun isVerbose(): Boolean

Tells whether to produce verbose output. Defaults to false.

isWarnings

open fun isWarnings(): Boolean

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

optionMap

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

Internal method.

setAnnotationProcessorGeneratedSourcesDirectory

open fun setAnnotationProcessorGeneratedSourcesDirectory(file: File): Unit
open fun setAnnotationProcessorGeneratedSourcesDirectory(file: Provider<File>): Unit

Sets the directory to place source files generated by annotation compilers.

setAnnotationProcessorPath

open fun setAnnotationProcessorPath(annotationProcessorPath: FileCollection): Unit

Set the classpath to use to load annotation processors. This path is also used for annotation processor discovery. The value can be null, which means use the compile classpath.

setBootClasspath

open fun setBootClasspath(bootClasspath: String): Unit

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

setBootstrapClasspath

open fun setBootstrapClasspath(bootstrapClasspath: FileCollection): Unit

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

setCompilerArgs

open fun setCompilerArgs(compilerArgs: MutableList<String>): Unit

Sets any additional arguments to be passed to the compiler. Defaults to the empty list.

setDebug

open fun setDebug(debug: Boolean): Unit

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

setDebugOptions

open fun setDebugOptions(debugOptions: DebugOptions): Unit

Sets options for generating debugging information.

setDeprecation

open fun setDeprecation(deprecation: Boolean): Unit

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

setEncoding

open fun setEncoding(encoding: String): Unit

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

setExtensionDirs

open fun setExtensionDirs(extensionDirs: String): Unit

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

setFailOnError

open fun setFailOnError(failOnError: Boolean): Unit

Sets whether to fail the build when compilation fails. Defaults to true.

setFork

open fun setFork(fork: Boolean): Unit

Sets 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.

setForkOptions

open fun setForkOptions(forkOptions: ForkOptions): Unit

Sets options for running the compiler in a child process.

setIncremental

open fun setIncremental(incremental: Boolean): CompileOptions

Configure the java compilation to be incremental (e.g. compiles only those java classes that were changed or that are dependencies to the changed classes).

setListFiles

open fun setListFiles(listFiles: Boolean): Unit

Sets whether to log the files to be compiled. Defaults to false.

setSourcepath

open fun setSourcepath(sourcepath: FileCollection): Unit

Sets the source path to use for the compilation.

setVerbose

open fun setVerbose(verbose: Boolean): Unit

Sets whether to produce verbose output. Defaults to false.

setWarnings

open fun setWarnings(warnings: Boolean): Unit

Sets whether to log warning messages. The default is true.

Inherited Functions

define

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