Package org.gradle.api.tasks
Interface SourceSet
-
- All Superinterfaces:
ExtensionAware
public interface SourceSet extends ExtensionAware
ASourceSet
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/**' } } }
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
MAIN_SOURCE_SET_NAME
The name of the main source set.static java.lang.String
TEST_SOURCE_SET_NAME
The name of the test source set.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description SourceSet
compiledBy(java.lang.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.java.lang.String
getAnnotationProcessorConfigurationName()
Returns the name of the configuration containing annotation processors and their dependencies needed to compile this source set.FileCollection
getAnnotationProcessorPath()
Returns the classpath used to load annotation processors when compiling this source set.java.lang.String
getApiConfigurationName()
Returns the name of the API configuration for this source set.java.lang.String
getApiElementsConfigurationName()
Returns the name of the configuration that should be used when compiling against the API of this component.java.lang.String
getClassesTaskName()
Returns the name of the classes task for this source set.FileCollection
getCompileClasspath()
Returns the classpath used to compile this source.java.lang.String
getCompileClasspathConfigurationName()
Returns the name of the compile classpath configuration for this source set.java.lang.String
getCompileJavaTaskName()
Returns the name of the compile Java task for this source set.java.lang.String
getCompileOnlyApiConfigurationName()
Returns the name of the 'compile only api' configuration for this source set.java.lang.String
getCompileOnlyConfigurationName()
Returns the name of the compile only configuration for this source set.java.lang.String
getCompileTaskName(java.lang.String language)
Returns the name of a compile task for this source set.java.lang.String
getImplementationConfigurationName()
Returns the name of the implementation configuration for this source set.java.lang.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.java.lang.String
getJavadocElementsConfigurationName()
Returns the name of the configuration that represents the variant that carries the Javadoc for this source set in packaged form.java.lang.String
getJavadocJarTaskName()
Returns the name of the Javadoc Jar task for this source set.java.lang.String
getJavadocTaskName()
Returns the name of the Javadoc task for this source set.java.lang.String
getName()
Returns the name of this source set.SourceSetOutput
getOutput()
SourceSetOutput
is aFileCollection
of all output directories (compiled classes, processed resources, etc.) and it provides means to configure the default output dirs and register additional output dirs.java.lang.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.java.lang.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.java.lang.String
getRuntimeElementsConfigurationName()
Returns the name of the configuration containing elements that are strictly required at runtime.java.lang.String
getRuntimeOnlyConfigurationName()
Returns the name of the configuration that contains dependencies that are only required at runtime of the component.java.lang.String
getSourcesElementsConfigurationName()
Returns the name of the configuration that represents the variant that carries the original source code in packaged form.java.lang.String
getSourcesJarTaskName()
Returns the name of the Source Jar task for this source set.java.lang.String
getTaskName(java.lang.String verb, java.lang.String target)
Returns the name of a task for this source set.static boolean
isMain(SourceSet sourceSet)
Determines if this source set is the main source setSourceSet
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
setAnnotationProcessorPath(FileCollection annotationProcessorPath)
Set the classpath to use to load annotation processors when compiling this source 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.-
Methods inherited from interface org.gradle.api.plugins.ExtensionAware
getExtensions
-
-
-
-
Field Detail
-
MAIN_SOURCE_SET_NAME
static final java.lang.String MAIN_SOURCE_SET_NAME
The name of the main source set.- See Also:
- Constant Field Values
-
TEST_SOURCE_SET_NAME
static final java.lang.String TEST_SOURCE_SET_NAME
The name of the test source set.- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
java.lang.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.
-
getAnnotationProcessorPath
FileCollection getAnnotationProcessorPath()
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.- Returns:
- The annotation processor path. Never returns null.
- Since:
- 4.6
-
setAnnotationProcessorPath
void setAnnotationProcessorPath(FileCollection annotationProcessorPath)
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.- Parameters:
annotationProcessorPath
- The annotation processor path. Should not be null.- Since:
- 4.6
-
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 aFileCollection
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 inSourceSetOutput
- Returns:
- The output dirs, as a
SourceSetOutput
.
-
compiledBy
SourceSet compiledBy(java.lang.Object... taskPaths)
Registers a set of tasks which are responsible for compiling this source set into the classes directory. The paths are evaluated as perTask.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(@Nullable @DelegatesTo(SourceDirectorySet.class) 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(@Nullable @DelegatesTo(SourceDirectorySet.class) 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
java.lang.String getClassesTaskName()
Returns the name of the classes task for this source set.- Returns:
- The task name. Never returns null.
-
getProcessResourcesTaskName
java.lang.String getProcessResourcesTaskName()
Returns the name of the resource process task for this source set.- Returns:
- The task name. Never returns null.
-
getCompileJavaTaskName
java.lang.String getCompileJavaTaskName()
Returns the name of the compile Java task for this source set.- Returns:
- The task name. Never returns null.
-
getCompileTaskName
java.lang.String getCompileTaskName(java.lang.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.
-
getJavadocTaskName
java.lang.String getJavadocTaskName()
Returns the name of the Javadoc task for this source set.- Returns:
- The task name. Never returns null.
- Since:
- 6.0
-
getJarTaskName
java.lang.String getJarTaskName()
Returns the name of the Jar task for this source set.- Returns:
- The task name. Never returns null.
-
getJavadocJarTaskName
java.lang.String getJavadocJarTaskName()
Returns the name of the Javadoc Jar task for this source set.- Returns:
- The task name. Never returns null.
- Since:
- 6.0
-
getSourcesJarTaskName
java.lang.String getSourcesJarTaskName()
Returns the name of the Source Jar task for this source set.- Returns:
- The task name. Never returns null.
- Since:
- 6.0
-
getTaskName
java.lang.String getTaskName(@Nullable java.lang.String verb, @Nullable java.lang.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}
-
getCompileOnlyConfigurationName
java.lang.String getCompileOnlyConfigurationName()
Returns the name of the compile only configuration for this source set.- Returns:
- The compile only configuration name
- Since:
- 2.12
-
getCompileOnlyApiConfigurationName
java.lang.String getCompileOnlyApiConfigurationName()
Returns the name of the 'compile only api' configuration for this source set.- Returns:
- The 'compile only api' configuration name
- Since:
- 6.7
-
getCompileClasspathConfigurationName
java.lang.String getCompileClasspathConfigurationName()
Returns the name of the compile classpath configuration for this source set.- Returns:
- The compile classpath configuration
- Since:
- 2.12
-
getAnnotationProcessorConfigurationName
java.lang.String getAnnotationProcessorConfigurationName()
Returns the name of the configuration containing annotation processors and their dependencies needed to compile this source set.- Returns:
- the name of the annotation processor configuration.
- Since:
- 4.6
-
getApiConfigurationName
java.lang.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
java.lang.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
java.lang.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
java.lang.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
java.lang.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
java.lang.String getRuntimeElementsConfigurationName()
Returns the name of the configuration containing elements that are strictly 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
-
getJavadocElementsConfigurationName
java.lang.String getJavadocElementsConfigurationName()
Returns the name of the configuration that represents the variant that carries the Javadoc for this source set in packaged form. Used to publish a variant with a '-javadoc' zip.- Returns:
- the name of the javadoc elements configuration.
- Since:
- 6.0
-
getSourcesElementsConfigurationName
java.lang.String getSourcesElementsConfigurationName()
Returns the name of the configuration that represents the variant that carries the original source code in packaged form. Used to publish a variant with a '-sources' zip.- Returns:
- the name of the sources elements configuration.
- Since:
- 6.0
-
isMain
static boolean isMain(SourceSet sourceSet)
Determines if this source set is the main source set- Since:
- 6.7
-
-