Package org.gradle.api.file

# Interface SourceDirectorySet

All Superinterfaces:
  `AntBuilderAware`, `Buildable`, `Describable`, `FileCollection`, `FileTree`, `Iterable<File>`, `Named`, `PatternFilterable`

All Known Subinterfaces:
  `AntlrSourceDirectorySet`, `GroovySourceDirectorySet`, `ScalaSourceDirectorySet`

public interface SourceDirectorySet extends 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.

You can create an instance of `SourceDirectorySet` using the `ObjectFactory.sourceDirectorySet(String, String)` method.

You can filter the files that are obtainable in this set using patterns via `PatternFilterable.include(Spec)` and `PatternFilterable.include(Spec)` (or any overload of these methods). The set of included source directories themselves are not filtered.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface org.gradle.api.file.FileCollection

  `FileCollection.AntType`

  ## Nested classes/interfaces inherited from interface org.gradle.api.Named

  `Named.Namer`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<T extends Task>
  void`
  `compiledBy(TaskProvider<T> taskProvider, Function<T,DirectoryProperty> mapping)`
  Define the task responsible for processing the source.
  `Provider<Directory>`
  `getClassesDirectory()`
  Returns the directory property that is bound to the task that produces the output via `compiledBy(TaskProvider, Function)`.
  `DirectoryProperty`
  `getDestinationDirectory()`
  Configure the directory to assemble the compiled classes into.
  `PatternFilterable`
  `getFilter()`
  Returns the filter used to select the source from the source directories.
  `String`
  `getName()`
  A concise name for the source directory set (typically used to identify it in a collection).
  `FileCollection`
  `getSourceDirectories()`
  Returns the source directories that make up this set, represented as a `FileCollection`.
  `Set<File>`
  `getSrcDirs()`
  Returns the source directories that make up this set.
  `Set<DirectoryTree>`
  `getSrcDirTrees()`
  Returns the source directory trees that make up this set.
  `SourceDirectorySet`
  `setSrcDirs(Iterable<?> srcPaths)`
  Sets the source directories for this set.
  `SourceDirectorySet`
  `source(SourceDirectorySet source)`
  Adds the given source to this set.
  `SourceDirectorySet`
  `srcDir(Object srcPath)`
  Adds the given source directory to this set.
  `SourceDirectorySet`
  `srcDirs(Object... srcPaths)`
  Adds the given source directories to this set.

  ### Methods inherited from interface org.gradle.api.Buildable

  `getBuildDependencies`

  ### Methods inherited from interface org.gradle.api.Describable

  `getDisplayName`

  ### Methods inherited from interface org.gradle.api.file.FileCollection

  `addToAntBuilder, addToAntBuilder, contains, filter, filter, getAsPath, getElements, getSingleFile, isEmpty, minus, plus`

  ### Methods inherited from interface org.gradle.api.file.FileTree

  `getAsFileTree, getFiles, matching, matching, matching, plus, visit, visit, visit`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, iterator, spliterator`

  ### Methods inherited from interface org.gradle.api.tasks.util.PatternFilterable

  `exclude, exclude, exclude, exclude, getExcludes, getIncludes, include, include, include, include, setExcludes, setIncludes`

- ## Method Details

  - ### getName

    String getName()
    A concise name for the source directory set (typically used to identify it in a collection).
    Specified by:
      `getName` in interface `Named`
    Returns:
      The name. Never null.

  - ### srcDir

    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.
    Parameters:
      `srcPath` - The source directory. This is evaluated as per `Project.files(Object...)`
    Returns:
      this

  - ### srcDirs

    SourceDirectorySet srcDirs(Object... srcPaths)
    Adds the given source directories to this set. The given directories do not need to exist. Directories that do not exist are ignored.
    Parameters:
      `srcPaths` - The source directories. These are evaluated as per `Project.files(Object...)`
    Returns:
      this

  - ### getSrcDirs

    Set<File> getSrcDirs()
    Returns the source directories that make up this set.

    Note that filtering via patterns using `PatternFilterable.exclude(Spec)` and `PatternFilterable.include(Spec)` (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 `getSrcDirTrees()`.

    Does not filter source directories that do not exist.

    Returns:
      The source directories. Returns an empty set when this set contains no source directories.

  - ### setSrcDirs

    SourceDirectorySet setSrcDirs(Iterable<?> srcPaths)
    Sets the source directories for this set.
    Parameters:
      `srcPaths` - The source directories. These are evaluated as per `Project.files(Object...)`
    Returns:
      this

  - ### source

    SourceDirectorySet source(SourceDirectorySet source)
    Adds the given source to this set.
    Parameters:
      `source` - The source to add.
    Returns:
      this

  - ### getSourceDirectories

    FileCollection getSourceDirectories()
    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

    Set<DirectoryTree> getSrcDirTrees()
    Returns the source directory trees that make up this set.

    Note that filtering via patterns using `PatternFilterable.exclude(Spec)` and `PatternFilterable.include(Spec)` (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 `getSrcDirs()`.

    Does not filter source directories that do not exist.

    Note that if there are multiple source directories added to this set that include the same dir, we use the patterns from the first one we find (in the order they were added) to filter files in the returned `DirectoryTree`s. It is discouraged to add multiple source directories that include the same dir to the same set.

    Returns:
      The source directory trees. Returns an empty set when this set contains no source directories.

  - ### getFilter

    PatternFilterable getFilter()
    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`.
    Returns:
      The filter patterns.

  - ### getDestinationDirectory

    DirectoryProperty getDestinationDirectory()
    Configure the directory to assemble the compiled classes into.
    Returns:
      The destination directory property for this set of sources.
    Since:
      6.1

  - ### getClassesDirectory

    Provider<Directory> getClassesDirectory()
    Returns the directory property that is bound to the task that produces the output via `compiledBy(TaskProvider, 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 `getDestinationDirectory()`
    Returns:
      The classes directory property for this set of sources.
    Since:
      6.1

  - ### compiledBy

    <T extends Task> void compiledBy(TaskProvider<T> taskProvider, Function<T,DirectoryProperty> mapping)
    Define the task responsible for processing the source.
    Parameters:
      `taskProvider` - the task responsible for compiling the sources (.e.g. compileJava)
      `mapping` - a mapping from the task to the task's output directory (e.g. AbstractCompile::getDestinationDirectory)
    Since:
      6.1