Package org.gradle.api.tasks

# Interface SourceSet

public 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
Modifier and Type
Field
Description
`static final String`
`MAIN_SOURCE_SET_NAME`
The name of the main source set.
`static final String`
`TEST_SOURCE_SET_NAME`
The name of the test source set.

## Method Summary

Modifier and Type
Method
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`
`getApiConfigurationName()`
Returns the name of the API configuration for this source set.
`String`
`getApiElementsConfigurationName()`
Returns the name of the configuration that should be used when compiling against the API of this component.
`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`
`getImplementationConfigurationName()`
Returns the name of the implementation configuration 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.) and it provides means to configure the default output dirs and register additional output dirs.
`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`
`getRuntimeClasspathConfigurationName()`
Returns the name of the runtime classpath configuration of this component: the runtime classpath contains elements of the implementation, as well as runtime only elements.
`String`
`getRuntimeConfigurationName()`
Returns the name of the runtime configuration for this source set.
`String`
`getRuntimeElementsConfigurationName()`
Returns the name of the configuration containing elements that are stricly required at runtime.
`String`
`getRuntimeOnlyConfigurationName()`
Returns the name of the configuration that contains dependencies that are only required at runtime of the component.
`String`
`getTaskName(String verb, String target)`
Returns the name of a task for this source set.
`SourceSet`
`java(Closure configureClosure)`
Configures the Java source for this set.
`SourceSet`
`java(Action<? super SourceDirectorySet> configureAction)`
Configures the Java source for this set.
`SourceSet`
`resources(Closure configureClosure)`
Configures the non-Java resources for this set.
`SourceSet`
`resources(Action<? super SourceDirectorySet> configureAction)`
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 Details

### MAIN_SOURCE_SET_NAME

static final String MAIN_SOURCE_SET_NAME
The name of the main source set.

See Also:
  - Constant Field Values

### TEST_SOURCE_SET_NAME

static final String TEST_SOURCE_SET_NAME
The name of the test source set.

See Also:
  - Constant Field Values

## Method Details

### getName

String getName()
Returns the name of this source set.

Returns:
  The name. Never returns null.

### getCompileClasspath

FileCollection getCompileClasspath()
Returns the classpath used to compile this source.

Returns:
  The classpath. Never returns null.

### setCompileClasspath

void setCompileClasspath(FileCollection classpath)
Sets the classpath used to compile this source.

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

### getRuntimeClasspath

FileCollection getRuntimeClasspath()
Returns the classpath used to execute this source.

Returns:
  The classpath. Never returns null.

### setRuntimeClasspath

void setRuntimeClasspath(FileCollection classpath)
Sets the classpath used to execute this source.

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

### getOutput

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

### compiledBy

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(Object...)`.

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

### getResources

SourceDirectorySet getResources()
Returns the non-Java resources which are to be copied into the resources output directory.

Returns:
  the resources. Never returns null.

### resources

SourceSet resources(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

### resources

SourceSet resources(Action<? super SourceDirectorySet> configureAction)
Configures the non-Java resources for this set.

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

Parameters:
  `configureAction` - The action to use to configure the resources.
Returns:
  this

### getJava

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.

### java

SourceSet java(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

### java

SourceSet java(Action<? super SourceDirectorySet> configureAction)
Configures the Java source for this set.

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

Parameters:
  `configureAction` - The action to use to configure the Java source.
Returns:
  this

### getAllJava

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.

### getAllSource

SourceDirectorySet getAllSource()
All source files for this source set.

Returns:
  the source. Never returns null.

### getClassesTaskName

String getClassesTaskName()
Returns the name of the classes task for this source set.

Returns:
  The task name. Never returns null.

### getProcessResourcesTaskName

String getProcessResourcesTaskName()
Returns the name of the resource process task for this source set.

Returns:
  The task name. Never returns null.

### getCompileJavaTaskName

String getCompileJavaTaskName()
Returns the name of the compile Java task for this source set.

Returns:
  The task name. Never returns null.

### getCompileTaskName

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.

### getJarTaskName

String getJarTaskName()
Returns the name of the Jar task for this source set.

Returns:
  The task name. Never returns null.

### getTaskName

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}

### getCompileConfigurationName

String getCompileConfigurationName()
Returns the name of the compile configuration for this source set.

Returns:
  The configuration name

### getRuntimeConfigurationName

String getRuntimeConfigurationName()
Returns the name of the runtime configuration for this source set.

Returns:
  The runtime configuration name

### getCompileOnlyConfigurationName

@Incubating String getCompileOnlyConfigurationName()
Returns the name of the compile only configuration for this source set.

Returns:
  The compile only configuration name
Since:
  2.12

### getCompileClasspathConfigurationName

@Incubating String getCompileClasspathConfigurationName()
Returns the name of the compile classpath configuration for this source set.

Returns:
  The compile classpath configuration
Since:
  2.12

### getApiConfigurationName

@Incubating String getApiConfigurationName()
Returns the name of the API configuration for this source set. The API configuration contains dependencies which are exported by this source set, and is not transitive by default. This configuration is not meant to be resolved and should only contain dependencies that are required when compiling against this component.

Returns:
  The API configuration name
Since:
  3.3

### getImplementationConfigurationName

@Incubating String getImplementationConfigurationName()
Returns the name of the implementation configuration for this source set. The implementation configuration should contain dependencies which are specific to the implementation of the component (internal APIs).

Returns:
  The configuration name
Since:
  3.4

### getApiElementsConfigurationName

@Incubating String getApiElementsConfigurationName()
Returns the name of the configuration that should be used when compiling against the API of this component. This configuration is meant to be consumed by other components when they need to compile against it.

Returns:
  The API compile configuration name
Since:
  3.3

### getRuntimeOnlyConfigurationName

@Incubating String getRuntimeOnlyConfigurationName()
Returns the name of the configuration that contains dependencies that are only required at runtime of the component. Dependencies found in this configuration are visible to the runtime classpath of the component, but not to consumers.

Returns:
  the runtime only configuration name
Since:
  3.4

### getRuntimeClasspathConfigurationName

@Incubating String getRuntimeClasspathConfigurationName()
Returns the name of the runtime classpath configuration of this component: the runtime classpath contains elements of the implementation, as well as runtime only elements.

Returns:
  the name of the runtime classpath configuration
Since:
  3.4

### getRuntimeElementsConfigurationName

@Incubating String getRuntimeElementsConfigurationName()
Returns the name of the configuration containing elements that are stricly required at runtime. Consumers of this configuration will get all the mandatory elements for this component to execute at runtime.

Returns:
  the name of the runtime elements configuration.
Since:
  3.4