Table of Contents
API Documentation: | SourceDirectorySet |
---|
A SourceDirectorySet
represents a set of source files composed from a set of source directories, along
with associated include and exclude patterns.
SourceDirectorySet
extends FileTree
. The contents of the file tree represent the source files of this set,
arranged in a hierarchy. The file tree is live and reflects changes to the source directories and their contents.
You can create an instance of SourceDirectorySet
using the ObjectFactory.sourceDirectorySet(java.lang.String, java.lang.String)
method.
You can filter the files that are obtainable in this set using patterns via <UNHANDLED-LINK>#include(Spec)</UNHANDLED-LINK> and <UNHANDLED-LINK>#include(Spec)</UNHANDLED-LINK> (or any overload of these methods). The set of included source directories themselves are not filtered.
Property | Description |
classesDirectory | The directory property that is bound to the task that produces the output via |
destinationDirectory | Configure the directory to assemble the compiled classes into. |
filter | The filter used to select the source from the source directories. These filter patterns are applied after
the include and exclude patterns of this source directory set. Generally, the filter patterns are used to
restrict the contents to certain types of files, eg |
srcDirs | The source directories that make up this set. |
Method | Description |
compiledBy(taskProvider, mapping) | Define the task responsible for processing the source. |
source(source) | Adds the given source to this set. |
srcDir(srcPath) | Adds the given source directory to this set. The given directory does not need to exist. Directories that do not exist are ignored. |
srcDirs(srcPaths) | Adds the given source directories to this set. The given directories do not need to exist. Directories that do not exist are ignored. |
The directory property that is bound to the task that produces the output via SourceDirectorySet.compiledBy(org.gradle.api.tasks.TaskProvider, java.util.function.Function)
.
Use this as part of a classpath or input to another task to ensure that the output is created before it is used.
Note: To define the path of the output folder use SourceDirectorySet.getDestinationDirectory()
- Default with
java-base
plugin: ${project.layout.buildDirectory}
/classes/${sourceDirectorySet.name}
/${sourceSet.name}
DirectoryProperty
destinationDirectory
Configure the directory to assemble the compiled classes into.
- Default with
java-base
plugin: ${project.layout.buildDirectory}
/classes/${sourceDirectorySet.name}
/${sourceSet.name}
PatternFilterable
filter
(read-only)
The filter used to select the source from the source directories. These filter patterns are applied after
the include and exclude patterns of this source directory set. Generally, the filter patterns are used to
restrict the contents to certain types of files, eg *.java
.
The source directories that make up this set.
Note that filtering via patterns using <UNHANDLED-LINK>#exclude(Spec)</UNHANDLED-LINK> and <UNHANDLED-LINK>#include(Spec)</UNHANDLED-LINK> (or any overload of these methods) only
filters files within the DirectoryTree
s returned by this method and does not filter
the set of source directory trees themselves. This result should agree with SourceDirectorySet.getSrcDirTrees()
.
Does not filter source directories that do not exist.
- Default with
java-base
plugin: src/
${sourceSet.name}
/${sourceDirectorySet.name}
void
compiledBy
(TaskProvider
<T
>
taskProvider, Function
<T
, DirectoryProperty
>
mapping)
TaskProvider
<T
>Function
<T
, DirectoryProperty
>Define the task responsible for processing the source.
SourceDirectorySet
source
(SourceDirectorySet
source)
Adds the given source to this set.
SourceDirectorySet
srcDir
(Object
srcPath)
Adds the given source directory to this set. The given directory does not need to exist. Directories that do not exist are ignored.
SourceDirectorySet
srcDirs
(Object
...
srcPaths)
Object
...Adds the given source directories to this set. The given directories do not need to exist. Directories that do not exist are ignored.