Class JavaCompile

  • All Implemented Interfaces:
    Comparable<Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, ExtensionAware, Task, PatternFilterable, org.gradle.util.Configurable<Task>
    Direct Known Subclasses:
    PlatformJavaCompile

    @CacheableTask
    public class JavaCompile
    extends 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
         }
     
    • Constructor Detail

      • JavaCompile

        public JavaCompile()
    • Method Detail

      • getSource

        @PathSensitive(NAME_ONLY)
        public FileTree getSource()
        Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.
        Overrides:
        getSource in class SourceTask
        Returns:
        The source.
      • getToolChain

        @Incubating
        public JavaToolChain getToolChain()
        Returns the tool chain that will be used to compile the Java source.
        Returns:
        The tool chain.
      • setToolChain

        @Incubating
        public void setToolChain​(JavaToolChain toolChain)
        Sets the tool chain that should be used to compile the Java source.
        Parameters:
        toolChain - The tool chain.
      • getStreamHasher

        @Inject
        protected org.gradle.internal.hash.StreamHasher getStreamHasher()
      • getCachingFileHasher

        @Inject
        protected org.gradle.internal.hash.FileHasher getCachingFileHasher()
      • getFileOperations

        @Inject
        protected org.gradle.api.internal.file.FileOperations getFileOperations()
      • getGeneralCompileCaches

        @Inject
        protected org.gradle.api.internal.tasks.compile.incremental.cache.GeneralCompileCaches getGeneralCompileCaches()
      • getCacheRepository

        @Inject
        protected org.gradle.cache.CacheRepository getCacheRepository()
      • getJavaToolChainFactory

        @Inject
        protected org.gradle.api.internal.tasks.JavaToolChainFactory getJavaToolChainFactory()
      • getOptions

        public CompileOptions getOptions()
        Returns the compilation options.
        Returns:
        The compilation options.
      • getEffectiveAnnotationProcessorPath

        @Incubating
        @Classpath
        public FileCollection getEffectiveAnnotationProcessorPath()
        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.

        Since:
        3.4