api / org.gradle.api.tasks.compile / JavaCompile

JavaCompile

@CacheableTask open class JavaCompile : AbstractCompile

Compiles Java source files.

 apply plugin: 'java' tasks.withType(JavaCompile) { //enable compilation in a separate daemon process options.fork = true //enable incremental compilation options.incremental = true } 

Constructors

<init>

JavaCompile()

Functions

getClasspath

open fun getClasspath(): FileCollection

getEffectiveAnnotationProcessorPath

open fun getEffectiveAnnotationProcessorPath(): FileCollection

Returns the path to use for annotation processor discovery. Returns an empty collection when no processing should be performed, for example when no annotation processors are present in the compile classpath or annotation processing has been disabled.

You can specify this path using CompileOptions#setAnnotationProcessorPath(FileCollection) or CompileOptions#setCompilerArgs(java.util.List). When not explicitly set using one of the methods on CompileOptions, the compile classpath will be used when there are annotation processors present in the compile classpath. Otherwise this path will be empty.

This path is always empty when annotation processing is disabled.

getOptions

open fun getOptions(): CompileOptions

Returns the compilation options.

getSource

open fun getSource(): FileTree

{@inheritDoc}

getToolChain

open fun getToolChain(): JavaToolChain

Returns the tool chain that will be used to compile the Java source.

setToolChain

open fun setToolChain(toolChain: JavaToolChain): Unit

Sets the tool chain that should be used to compile the Java source.

Inherited Functions

getDestinationDir

open fun getDestinationDir(): File

Returns the directory to generate the .class files into.

getSourceCompatibility

open fun getSourceCompatibility(): String

Returns the Java language level to use to compile the source files.

getTargetCompatibility

open fun getTargetCompatibility(): String

Returns the target JVM to generate the .class files for.

setClasspath

open fun setClasspath(configuration: FileCollection): Unit

Sets the classpath to use to compile the source files.

setDestinationDir

open fun setDestinationDir(destinationDir: File): Unit
open fun setDestinationDir(destinationDir: Provider<File>): Unit

Sets the directory to generate the .class files into.

setSourceCompatibility

open fun setSourceCompatibility(sourceCompatibility: String): Unit

Sets the Java language level to use to compile the source files.

setTargetCompatibility

open fun setTargetCompatibility(targetCompatibility: String): Unit

Sets the target JVM to generate the .class files for.

Inheritors

PlatformJavaCompile

open class PlatformJavaCompile : JavaCompile

A platform-aware Java compile task.