SourceSet

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

Properties

Link copied to clipboard

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

Link copied to clipboard
The name of the main source set.
Link copied to clipboard
The name of the test source set.

Functions

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

Link copied to clipboard
All Java source files for this source set.
Link copied to clipboard
All source files for this source set.
Link copied to clipboard
Returns the name of the configuration containing annotation processors and their dependencies needed to compile this source set.
Link copied to clipboard
Returns the classpath used to load annotation processors when compiling this source set.
Link copied to clipboard
Returns the name of the API configuration for this source set.
Link copied to clipboard
Returns the name of the configuration that should be used when compiling against the API of this component.
Link copied to clipboard
abstract fun getClassesTaskName(): String
Returns the name of the classes task for this source set.
Link copied to clipboard
Returns the classpath used to compile this source.
Link copied to clipboard
Returns the name of the compile classpath configuration for this source set.
Link copied to clipboard
Returns the name of the compile Java task for this source set.
Link copied to clipboard
Returns the name of the 'compile only api' configuration for this source set.
Link copied to clipboard
Returns the name of the compile only configuration for this source set.
Link copied to clipboard
abstract fun getCompileTaskName(language: String): String
Returns the name of a compile task for this source set.
Link copied to clipboard
Link copied to clipboard
Returns the name of the implementation configuration for this source set.
Link copied to clipboard
abstract fun getJarTaskName(): String
Returns the name of the Jar task for this source set.
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.
Link copied to clipboard
Returns the name of the configuration that represents the variant that carries the Javadoc for this source set in packaged form.
Link copied to clipboard
Returns the name of the Javadoc Jar task for this source set.
Link copied to clipboard
abstract fun getJavadocTaskName(): String
Returns the name of the Javadoc task for this source set.
Link copied to clipboard
abstract fun getName(): String
Returns the name of this source set.
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.
Link copied to clipboard
Returns the name of the resource process task for this source set.
Link copied to clipboard
Returns the non-Java resources which are to be copied into the resources output directory.
Link copied to clipboard
Returns the classpath used to execute this source.
Link copied to clipboard
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.
Link copied to clipboard
Returns the name of the configuration containing elements that are strictly required at runtime.
Link copied to clipboard
Returns the name of the configuration that contains dependencies that are only required at runtime of the component.
Link copied to clipboard
Returns the name of the configuration that represents the variant that carries the original source code in packaged form.
Link copied to clipboard
Returns the name of the Source Jar task for this source set.
Link copied to clipboard
abstract fun getTaskName(@Nullable verb: String, @Nullable target: String): String
Returns the name of a task for this source set.
Link copied to clipboard
open fun isMain(sourceSet: SourceSet): Boolean
Determines if this source set is the main source set
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.
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.
Link copied to clipboard
abstract fun setAnnotationProcessorPath(annotationProcessorPath: FileCollection)
Set the classpath to use to load annotation processors when compiling this source set.
Link copied to clipboard
abstract fun setCompileClasspath(classpath: FileCollection)
Sets the classpath used to compile this source.
Link copied to clipboard
abstract fun setRuntimeClasspath(classpath: FileCollection)
Sets the classpath used to execute this source.
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.