api / org.gradle.api.tasks / SourceSet

SourceSet

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/**' } } } 

Properties

MAIN_SOURCE_SET_NAME

static val MAIN_SOURCE_SET_NAME: String

The name of the main source set.

TEST_SOURCE_SET_NAME

static val TEST_SOURCE_SET_NAME: String

The name of the test source set.

Functions

compiledBy

abstract fun compiledBy(vararg taskPaths: Any): SourceSet

Registers a set of tasks which are responsible for compiling this source set into the classes directory. The paths are evaluated as per org.gradle.api.Task#dependsOn(Object...).

getAllJava

abstract fun getAllJava(): SourceDirectorySet

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.

getAllSource

abstract fun getAllSource(): SourceDirectorySet

All source files for this source set.

getAnnotationProcessorConfigurationName

abstract fun getAnnotationProcessorConfigurationName(): String

Returns the name of the configuration containing annotation processors and their dependencies needed to compile this source set.

getAnnotationProcessorPath

abstract fun getAnnotationProcessorPath(): FileCollection

Returns the classpath used to load annotation processors when compiling this source set. This path is also used for annotation processor discovery. The classpath can be empty, which means use the compile classpath; if you want to disable annotation processing, then use -proc:none as a compiler argument.

getApiConfigurationName

abstract fun getApiConfigurationName(): String

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.

getApiElementsConfigurationName

abstract fun getApiElementsConfigurationName(): String

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.

getClassesTaskName

abstract fun getClassesTaskName(): String

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

getCompileClasspath

abstract fun getCompileClasspath(): FileCollection

Returns the classpath used to compile this source.

getCompileClasspathConfigurationName

abstract fun getCompileClasspathConfigurationName(): String

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

getCompileConfigurationName

abstract fun getCompileConfigurationName(): String

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

getCompileJavaTaskName

abstract fun getCompileJavaTaskName(): String

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

getCompileOnlyConfigurationName

abstract fun getCompileOnlyConfigurationName(): String

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

getCompileTaskName

abstract fun getCompileTaskName(language: String): String

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

getImplementationConfigurationName

abstract fun getImplementationConfigurationName(): String

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

getJarTaskName

abstract fun getJarTaskName(): String

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

getJava

abstract fun getJava(): SourceDirectorySet

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

getName

abstract fun getName(): String

Returns the name of this source set.

getOutput

abstract fun getOutput(): SourceSetOutput

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

getProcessResourcesTaskName

abstract fun getProcessResourcesTaskName(): String

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

getResources

abstract fun getResources(): SourceDirectorySet

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

getRuntimeClasspath

abstract fun getRuntimeClasspath(): FileCollection

Returns the classpath used to execute this source.

getRuntimeClasspathConfigurationName

abstract fun getRuntimeClasspathConfigurationName(): String

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.

getRuntimeConfigurationName

abstract fun getRuntimeConfigurationName(): String

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

getRuntimeElementsConfigurationName

abstract fun getRuntimeElementsConfigurationName(): String

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.

getRuntimeOnlyConfigurationName

abstract fun getRuntimeOnlyConfigurationName(): String

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.

getTaskName

abstract fun getTaskName(verb: String, target: String): String

Returns the name of a task for this source set.

java

abstract fun java(configureClosure: Closure<Any>): SourceSet

Configures the Java source for this set.

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

abstract fun java(configureAction: Action<in SourceDirectorySet>): SourceSet

Configures the Java source for this set.

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

resources

abstract fun resources(configureClosure: Closure<Any>): SourceSet

Configures the non-Java resources for this set.

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

abstract fun resources(configureAction: Action<in SourceDirectorySet>): SourceSet

Configures the non-Java resources for this set.

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

setAnnotationProcessorPath

abstract fun setAnnotationProcessorPath(annotationProcessorPath: FileCollection): Unit

Set the classpath to use to load annotation processors when compiling this source set. This path is also used for annotation processor discovery. The classpath can be empty, which means use the compile classpath; if you want to disable annotation processing, then use -proc:none as a compiler argument.

setCompileClasspath

abstract fun setCompileClasspath(classpath: FileCollection): Unit

Sets the classpath used to compile this source.

setRuntimeClasspath

abstract fun setRuntimeClasspath(classpath: FileCollection): Unit

Sets the classpath used to execute this source.

Extension Properties

ext

val SourceSet.ext: ExtraPropertiesExtension

Retrieves the ext extension.

Extension Functions

ext

fun SourceSet.ext(configure: ExtraPropertiesExtension.() -> Unit): Unit

Configures the ext extension.