api / org.gradle.api.file / SourceDirectorySet

SourceDirectorySet

interface SourceDirectorySet : FileTree, PatternFilterable, Named, Describable

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.

Functions

getFilter

abstract fun getFilter(): PatternFilterable

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

getName

abstract fun getName(): String

A concise name for the source directory set (typically used to identify it in a collection).

getOutputDir

abstract fun getOutputDir(): File

Returns the directory to put the output for these sources.

getSourceDirectories

abstract fun getSourceDirectories(): FileCollection

Returns the source directories that make up this set, represented as a FileCollection. Does not filter source directories that do not exist. Generally, it is preferable to use this method instead of #getSrcDirs(), as this method does not require the source directories to be calculated when it is called. Instead, the source directories are calculated when queried. The return value of this method also maintains dependency information.

The returned collection is live and reflects changes to this source directory set.

getSrcDirTrees

abstract fun getSrcDirTrees(): MutableSet<DirectoryTree>

Returns the source directory trees that make up this set. Does not filter source directories that do not exist.

getSrcDirs

abstract fun getSrcDirs(): MutableSet<File>

Returns the source directories that make up this set. Does not filter source directories that do not exist.

setOutputDir

abstract fun setOutputDir(provider: Provider<File>): Unit

Sets the provider that gives the directory to assemble the compiled classes into.

abstract fun setOutputDir(outputDir: File): Unit

Sets the directory to assemble the compiled classes into.

setSrcDirs

abstract fun setSrcDirs(srcPaths: MutableIterable<*>): SourceDirectorySet

Sets the source directories for this set.

source

abstract fun source(source: SourceDirectorySet): SourceDirectorySet

Adds the given source to this set.

srcDir

abstract fun srcDir(srcPath: Any): SourceDirectorySet

Adds the given source directory to this set. The given directory does not need to exist. Directories that do not exist are ignored.

srcDirs

abstract fun srcDirs(vararg srcPaths: Any): SourceDirectorySet

Adds the given source directories to this set. The given directories to not need to exist. Directories that do no exist are ignored.

Inherited Functions

exclude

abstract fun exclude(vararg excludes: String): PatternFilterable
abstract fun exclude(excludes: MutableIterable<String>): PatternFilterable

Adds an ANT style exclude pattern. This method may be called multiple times to append new patterns and multiple patterns may be specified in a single call. If excludes are not provided, then no files will be excluded. If excludes are provided, then files must not match any exclude pattern to be processed.

abstract fun exclude(excludeSpec: Spec<FileTreeElement>): PatternFilterable

Adds an exclude spec. This method may be called multiple times to append new specs. If excludes are not provided, then no files will be excluded. If excludes are provided, then files must not match any exclude pattern to be processed.

abstract fun exclude(excludeSpec: Closure<Any>): PatternFilterable

Adds an exclude spec. This method may be called multiple times to append new specs.The given closure is passed a org.gradle.api.file.FileTreeElement as its parameter. The closure should return true or false. Example:

 copySpec { from 'source' into 'destination' //an example of excluding files from certain configuration: exclude { it.file in configurations.someConf.files } } 
If excludes are not provided, then no files will be excluded. If excludes are provided, then files must not match any exclude pattern to be processed.

getAsFileTree

abstract fun getAsFileTree(): FileTree

Returns this.

getDisplayName

abstract fun getDisplayName(): String

Returns the display name of this object. It is strongly encouraged to compute it lazily, and cache the value if it is expensive.

getExcludes

abstract fun getExcludes(): MutableSet<String>

Returns the set of exclude patterns.

getFiles

abstract fun getFiles(): MutableSet<File>

Returns the contents of this tree as a flattened Set.

getIncludes

abstract fun getIncludes(): MutableSet<String>

Returns the set of include patterns.

include

abstract fun include(vararg includes: String): PatternFilterable
abstract fun include(includes: MutableIterable<String>): PatternFilterable

Adds an ANT style include pattern. This method may be called multiple times to append new patterns and multiple patterns may be specified in a single call. If includes are not provided, then all files in this container will be included. If includes are provided, then a file must match at least one of the include patterns to be processed.

abstract fun include(includeSpec: Spec<FileTreeElement>): PatternFilterable

Adds an include spec. This method may be called multiple times to append new specs. If includes are not provided, then all files in this container will be included. If includes are provided, then a file must match at least one of the include patterns or specs to be included.

abstract fun include(includeSpec: Closure<Any>): PatternFilterable

Adds an include spec. This method may be called multiple times to append new specs. The given closure is passed a org.gradle.api.file.FileTreeElement as its parameter. If includes are not provided, then all files in this container will be included. If includes are provided, then a file must match at least one of the include patterns or specs to be included.

matching

abstract fun matching(filterConfigClosure: Closure<Any>): FileTree

Restricts the contents of this tree to those files matching the given filter. The filtered tree is live, so that any changes to this tree are reflected in the filtered tree.

The given closure is used to configure the filter. A org.gradle.api.tasks.util.PatternFilterable is passed to the closure as its delegate. Only files which match the specified include patterns will be included in the filtered tree. Any files which match the specified exclude patterns will be excluded from the filtered tree.

abstract fun matching(filterConfigAction: Action<in PatternFilterable>): FileTree

Restricts the contents of this tree to those files matching the given filter. The filtered tree is live, so that any changes to this tree are reflected in the filtered tree.

The given action is used to configure the filter. A org.gradle.api.tasks.util.PatternFilterable is passed to the action. Only files which match the specified include patterns will be included in the filtered tree. Any files which match the specified exclude patterns will be excluded from the filtered tree.

abstract fun matching(patterns: PatternFilterable): FileTree

Restricts the contents of this tree to those files matching the given filter. The filtered tree is live, so that any changes to this tree are reflected in the filtered tree.

The given pattern set is used to configure the filter. Only files which match the specified include patterns will be included in the filtered tree. Any files which match the specified exclude patterns will be excluded from the filtered tree.

plus

abstract fun plus(fileTree: FileTree): FileTree

Returns a FileTree which contains the union of this tree and the given tree. The returned tree is live, so that changes to either this tree or the other source tree are reflected in the returned tree.

setExcludes

abstract fun setExcludes(excludes: MutableIterable<String>): PatternFilterable

Set the allowable exclude patterns. Note that unlike #exclude(Iterable) this replaces any previously defined excludes.

setIncludes

abstract fun setIncludes(includes: MutableIterable<String>): PatternFilterable

Set the allowable include patterns. Note that unlike #include(Iterable) this replaces any previously defined includes.

visit

abstract fun visit(visitor: FileVisitor): FileTree

Visits the files and directories in this file tree. Files are visited in depth-first prefix order, so that a directory is visited before its children.

abstract fun visit(visitor: Closure<Any>): FileTree

Visits the files and directories in this file tree. Files are visited in depth-first prefix order, so that a directory is visited before its children. The file/directory to be visited is passed to the given closure as a

abstract fun visit(visitor: Action<in FileVisitDetails>): FileTree

Visits the files and directories in this file tree. Files are visited in depth-first prefix order, so that a directory is visited before its children. The file/directory to be visited is passed to the given action as a