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
         }
     
    • 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.

        The PathSensitivity for the sources is configured to be PathSensitivity.ABSOLUTE. If your sources are less strict, please change it accordingly by overriding this method in your subclass.

        Overrides:
        getSource in class SourceTask
        Returns:
        The source.
      • getToolChain

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

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

        @Inject
        protected org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilerFactory getIncrementalCompilerFactory()
      • getJavaToolChainFactory

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

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