# SourceSet

interface SourceSet : ExtensionAware(source)

A `SourceSet` represents a logical group of Java source and resource files. They are covered in more detail in the user manual.

The following example shows how you can configure the 'main' source set, which in this case involves excluding classes whose package begins 'some.unwanted.package' from compilation of the source files in the 'java' SourceDirectorySet:

    plugins {
        id 'java'
    }

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

Content copied to clipboard

## Properties

extra
Link copied to clipboard
val ExtensionAware.extra: ExtraPropertiesExtension

The extra properties extension in this object's extension container.

MAIN_SOURCE_SET_NAME
Link copied to clipboard
val MAIN_SOURCE_SET_NAME: String = "main"
The name of the main source set.
TEST_SOURCE_SET_NAME
Link copied to clipboard
val TEST_SOURCE_SET_NAME: String = "test"
The name of the test source set.

## Functions

compiledBy
Link copied to clipboard
abstract fun compiledBy(taskPaths: Array<Any>): SourceSet
Registers a set of tasks which are responsible for compiling this source set into the classes directory.
configure
Link copied to clipboard
inline fun <T : Any> ExtensionAware.configure(noinline configuration: T.() -> Unit)

Executes the given configuration block against the extension of the specified type.

getAllJava
Link copied to clipboard
abstract fun getAllJava(): SourceDirectorySet
All Java source files for this source set.
getAllSource
Link copied to clipboard
abstract fun getAllSource(): SourceDirectorySet
All source files for this source set.
getAnnotationProcessorConfigurationName
Link copied to clipboard
abstract fun getAnnotationProcessorConfigurationName(): String
Returns the name of the configuration containing annotation processors and their dependencies needed to compile this source set.
getAnnotationProcessorPath
Link copied to clipboard
abstract fun getAnnotationProcessorPath(): FileCollection
Returns the classpath used to load annotation processors when compiling this source set.
getApiConfigurationName
Link copied to clipboard
abstract fun getApiConfigurationName(): String
Returns the name of the API configuration for this source set.
getApiElementsConfigurationName
Link copied to clipboard
abstract fun getApiElementsConfigurationName(): String
Returns the name of the configuration that should be used when compiling against the API of this component.
getClassesTaskName
Link copied to clipboard
abstract fun getClassesTaskName(): String
Returns the name of the classes task for this source set.
getCompileClasspath
Link copied to clipboard
abstract fun getCompileClasspath(): FileCollection
Returns the classpath used to compile this source.
getCompileClasspathConfigurationName
Link copied to clipboard
abstract fun getCompileClasspathConfigurationName(): String
Returns the name of the compile classpath configuration for this source set.
getCompileJavaTaskName
Link copied to clipboard
abstract fun getCompileJavaTaskName(): String
Returns the name of the compile Java task for this source set.
getCompileOnlyApiConfigurationName
Link copied to clipboard
abstract fun getCompileOnlyApiConfigurationName(): String
Returns the name of the 'compile only api' configuration for this source set.
getCompileOnlyConfigurationName
Link copied to clipboard
abstract fun getCompileOnlyConfigurationName(): String
Returns the name of the compile only configuration for this source set.
getCompileTaskName
Link copied to clipboard
abstract fun getCompileTaskName(language: String): String
Returns the name of a compile task for this source set.
getExtensions
Link copied to clipboard
abstract fun getExtensions(): ExtensionContainer
getImplementationConfigurationName
Link copied to clipboard
abstract fun getImplementationConfigurationName(): String
Returns the name of the implementation configuration for this source set.
getJarTaskName
Link copied to clipboard
abstract fun getJarTaskName(): String
Returns the name of the Jar task for this source set.
getJava
Link copied to clipboard
abstract fun getJava(): SourceDirectorySet
Returns the Java source which is to be compiled by the Java compiler into the class output directory.
getJavadocElementsConfigurationName
Link copied to clipboard
abstract fun getJavadocElementsConfigurationName(): String
Returns the name of the configuration that represents the variant that carries the Javadoc for this source set in packaged form.
getJavadocJarTaskName
Link copied to clipboard
abstract fun getJavadocJarTaskName(): String
Returns the name of the Javadoc Jar task for this source set.
getJavadocTaskName
Link copied to clipboard
abstract fun getJavadocTaskName(): String
Returns the name of the Javadoc task for this source set.
getName
Link copied to clipboard
abstract fun getName(): String
Returns the name of this source set.
getOutput
Link copied to clipboard
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.
getProcessResourcesTaskName
Link copied to clipboard
abstract fun getProcessResourcesTaskName(): String
Returns the name of the resource process task for this source set.
getResources
Link copied to clipboard
abstract fun getResources(): SourceDirectorySet
Returns the non-Java resources which are to be copied into the resources output directory.
getRuntimeClasspath
Link copied to clipboard
abstract fun getRuntimeClasspath(): FileCollection
Returns the classpath used to execute this source.
getRuntimeClasspathConfigurationName
Link copied to clipboard
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.
getRuntimeElementsConfigurationName
Link copied to clipboard
abstract fun getRuntimeElementsConfigurationName(): String
Returns the name of the configuration containing elements that are strictly required at runtime.
getRuntimeOnlyConfigurationName
Link copied to clipboard
abstract fun getRuntimeOnlyConfigurationName(): String
Returns the name of the configuration that contains dependencies that are only required at runtime of the component.
getSourcesElementsConfigurationName
Link copied to clipboard
abstract fun getSourcesElementsConfigurationName(): String
Returns the name of the configuration that represents the variant that carries the original source code in packaged form.
getSourcesJarTaskName
Link copied to clipboard
abstract fun getSourcesJarTaskName(): String
Returns the name of the Source Jar task for this source set.
getTaskName
Link copied to clipboard
abstract fun getTaskName(@Nullable verb: String, @Nullable target: String): String
Returns the name of a task for this source set.
isMain
Link copied to clipboard
open fun isMain(sourceSet: SourceSet): Boolean
Determines if this source set is the main source set
java
Link copied to clipboard
abstract fun java(@Nullable @DelegatesTo(value = SourceDirectorySet::class) configureClosure: Closure): SourceSet
abstract fun java(configureAction: Action<in SourceDirectorySet>): SourceSet
Configures the Java source for this set.
resources
Link copied to clipboard
abstract fun resources(@Nullable @DelegatesTo(value = SourceDirectorySet::class) configureClosure: Closure): SourceSet
abstract fun resources(configureAction: Action<in SourceDirectorySet>): SourceSet
Configures the non-Java resources for this set.
setAnnotationProcessorPath
Link copied to clipboard
abstract fun setAnnotationProcessorPath(annotationProcessorPath: FileCollection)
Set the classpath to use to load annotation processors when compiling this source set.
setCompileClasspath
Link copied to clipboard
abstract fun setCompileClasspath(classpath: FileCollection)
Sets the classpath used to compile this source.
setRuntimeClasspath
Link copied to clipboard
abstract fun setRuntimeClasspath(classpath: FileCollection)
Sets the classpath used to execute this source.
the
Link copied to clipboard
inline fun <T : Any> ExtensionAware.the(): T

Returns the extension of the specified type.

fun <T : Any> ExtensionAware.the(extensionType: KClass<T>): T

Returns the extension of the specified extensionType.