Package: org.gradle.api.tasks

## [Java] Interface SourceSet

- A `SourceSet` represents a logical group of Java source and resources.

  See the example below how SourceSet 'main' is accessed and how the SourceDirectorySet 'java' is configured to exclude some package from compilation.

       apply plugin: 'java'

       sourceSets {
         main {
           java {
             exclude 'some/unwanted/package/**'
           }
         }
       }

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `String` | `MAIN_SOURCE_SET_NAME` | The name of the main source set.
    `String` | `TEST_SOURCE_SET_NAME` | The name of the test source set.

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `SourceSet` | `compiledBy(Object... taskPaths)` Registers a set of tasks which are responsible for compiling this source set into the classes directory.
    `SourceDirectorySet` | `getAllJava()` All Java source files for this source set.
    `SourceDirectorySet` | `getAllSource()` All source files for this source set.
    `String` | `getClassesTaskName()` Returns the name of the classes task for this source set.
    `FileCollection` | `getCompileClasspath()` Returns the classpath used to compile this source.
    `String` | `getCompileClasspathConfigurationName()` Returns the name of the compile classpath configuration for this source set.
    `String` | `getCompileConfigurationName()` Returns the name of the compile configuration for this source set.
    `String` | `getCompileJavaTaskName()` Returns the name of the compile Java task for this source set.
    `String` | `getCompileOnlyConfigurationName()` Returns the name of the compile only configuration for this source set.
    `String` | `getCompileTaskName(String language)` Returns the name of a compile task for this source set.
    `String` | `getJarTaskName()` Returns the name of the Jar task for this source set.
    `SourceDirectorySet` | `getJava()` Returns the Java source which is to be compiled by the Java compiler into the class output directory.
    `String` | `getName()` Returns the name of this source set.
    `SourceSetOutput` | `getOutput()` SourceSetOutput is a FileCollection of all output directories (compiled classes, processed resources, etc.)
    `String` | `getProcessResourcesTaskName()` Returns the name of the resource process task for this source set.
    `SourceDirectorySet` | `getResources()` Returns the non-Java resources which are to be copied into the resources output directory.
    `FileCollection` | `getRuntimeClasspath()` Returns the classpath used to execute this source.
    `String` | `getRuntimeConfigurationName()` Returns the name of the runtime configuration for this source set.
    `String` | `getTaskName(String verb, String target)` Returns the name of a task for this source set.
    `SourceSet` | `java(groovy.lang.Closure configureClosure)` Configures the Java source for this set.
    `SourceSet` | `resources(groovy.lang.Closure configureClosure)` Configures the non-Java resources for this set.
    `void` | `setCompileClasspath(FileCollection classpath)` Sets the classpath used to compile this source.
    `void` | `setRuntimeClasspath(FileCollection classpath)` Sets the classpath used to execute this source.

- - ### Field Detail

    - #### public String MAIN_SOURCE_SET_NAME

      The name of the main source set.

    - #### public String TEST_SOURCE_SET_NAME

      The name of the test source set.

  - ### Method Detail

    - #### public SourceSet compiledBy(Object... taskPaths)

      Registers a set of tasks which are responsible for compiling this source set into the classes directory. The paths are evaluated as per Task.dependsOn.

      Parameters:
        `taskPaths` - The tasks which compile this source set.
      Returns:
        this

    - #### public SourceDirectorySet getAllJava()

      All Java source files for this source set. This includes, for example, source which is directly compiled, and source which is indirectly compiled through joint compilation.

      Returns:
        the Java source. Never returns null.

    - #### public SourceDirectorySet getAllSource()

      All source files for this source set.

      Returns:
        the source. Never returns null.

    - #### public String getClassesTaskName()

      Returns the name of the classes task for this source set.

      Returns:
        The task name. Never returns null.

    - #### public FileCollection getCompileClasspath()

      Returns the classpath used to compile this source.

      Returns:
        The classpath. Never returns null.

    - #### @Incubating public String getCompileClasspathConfigurationName()

      Returns the name of the compile classpath configuration for this source set.

      Returns:
        The compile classpath configuration
      Since:
        2.12

    - #### public String getCompileConfigurationName()

      Returns the name of the compile configuration for this source set.

      Returns:
        The configuration name

    - #### public String getCompileJavaTaskName()

      Returns the name of the compile Java task for this source set.

      Returns:
        The task name. Never returns null.

    - #### @Incubating public String getCompileOnlyConfigurationName()

      Returns the name of the compile only configuration for this source set.

      Returns:
        The compile only configuration name
      Since:
        2.12

    - #### public String getCompileTaskName(String language)

      Returns the name of a compile task for this source set.

      Parameters:
        `language` - The language to be compiled.
      Returns:
        The task name. Never returns null.

    - #### public String getJarTaskName()

      Returns the name of the Jar task for this source set.

      Returns:
        The task name. Never returns null.

    - #### public SourceDirectorySet getJava()

      Returns the Java source which is to be compiled by the Java compiler into the class output directory.

      Returns:
        the Java source. Never returns null.

    - #### public String getName()

      Returns the name of this source set.

      Returns:
        The name. Never returns null.

    - #### public SourceSetOutput getOutput()

      SourceSetOutput is a FileCollection of all output directories (compiled classes, processed resources, etc.) and it provides means to configure the default output dirs and register additional output dirs. See examples in SourceSetOutput

      Returns:
        The output dirs, as a SourceSetOutput.

    - #### public String getProcessResourcesTaskName()

      Returns the name of the resource process task for this source set.

      Returns:
        The task name. Never returns null.

    - #### public SourceDirectorySet getResources()

      Returns the non-Java resources which are to be copied into the resources output directory.

      Returns:
        the resources. Never returns null.

    - #### public FileCollection getRuntimeClasspath()

      Returns the classpath used to execute this source.

      Returns:
        The classpath. Never returns null.

    - #### public String getRuntimeConfigurationName()

      Returns the name of the runtime configuration for this source set.

      Returns:
        The runtime configuration name

    - #### public String getTaskName(String verb, String target)

      Returns the name of a task for this source set.

      Parameters:
        `verb` - The action, may be null.
        `target` - The target, may be null
      Returns:
        The task name, generally of the form \${verb}\${name}\${noun}

    - #### public SourceSet java(groovy.lang.Closure configureClosure)

      Configures the Java source for this set.

      The given closure is used to configure the SourceDirectorySet which contains the Java source.

      Parameters:
        `configureClosure` - The closure to use to configure the Java source.
      Returns:
        this

    - #### public SourceSet resources(groovy.lang.Closure configureClosure)

      Configures the non-Java resources for this set.

      The given closure is used to configure the SourceDirectorySet which contains the resources.

      Parameters:
        `configureClosure` - The closure to use to configure the resources.
      Returns:
        this

    - #### public void setCompileClasspath(FileCollection classpath)

      Sets the classpath used to compile this source.

      Parameters:
        `classpath` - The classpath. Should not be null.

    - #### public void setRuntimeClasspath(FileCollection classpath)

      Sets the classpath used to execute this source.

      Parameters:
        `classpath` - The classpath. Should not be null.