# FileCollection

interface FileCollection : Iterable<T> , AntBuilderAware, Buildable

A `FileCollection` represents a collection of file system locations which you can query in certain ways. A file collection is can be used to define a classpath, or a set of source files, or to add files to an archive.

There are no methods on this interface that allow the contents of the collection to be modified. However, there are a number of sub-interfaces, such as ConfigurableFileCollection that allow changes to be made.

A file collection may contain task outputs. The file collection tracks not just a set of files, but also the tasks that produce those files. When a file collection is used as a task input property, Gradle will take care of automatically adding dependencies between the consuming task and the producing tasks.

You can obtain a `FileCollection` instance using files.

#### Inheritors

SourceSetOutput
FileTree
ConfigurableFileCollection
Configuration

## Types

AntType
Link copied to clipboard
enum AntType
Ant types which a `FileCollection` can be mapped to.

## Functions

addToAntBuilder
Link copied to clipboard
abstract fun addToAntBuilder(builder: Any, nodeName: String): Any
abstract fun addToAntBuilder(builder: Any, nodeName: String, type: FileCollection.AntType)
Adds this collection to an Ant task as a nested node.
contains
Link copied to clipboard
abstract fun contains(file: File): Boolean
Determines whether this collection contains the given file.
filter
Link copied to clipboard
abstract fun filter(filterClosure: Closure): FileCollection
abstract fun filter(filterSpec: Spec<in File>): FileCollection
Restricts the contents of this collection to those files which match the given criteria.
forEach
Link copied to clipboard
open fun forEach(p: Consumer<in T>)
getAsFileTree
Link copied to clipboard
abstract fun getAsFileTree(): FileTree
Converts this collection to a FileTree, if not already.
getAsPath
Link copied to clipboard
abstract fun getAsPath(): String
Returns the contents of this collection as a platform-specific path.
getBuildDependencies
Link copied to clipboard
abstract fun getBuildDependencies(): TaskDependency
getElements
Link copied to clipboard
abstract fun getElements(): Provider<Set<FileSystemLocation>>
Returns the contents of this file collection as a Provider of FileSystemLocation instances.
getFiles
Link copied to clipboard
abstract fun getFiles(): Set<File>
Returns the contents of this collection as a Set.
getSingleFile
Link copied to clipboard
abstract fun getSingleFile(): File
Returns the content of this collection, asserting it contains exactly one file.
isEmpty
Link copied to clipboard
abstract fun isEmpty(): Boolean
Returns true if this collection is empty.
iterator
Link copied to clipboard
abstract fun iterator(): Iterator<T>
minus
Link copied to clipboard
abstract fun minus(collection: FileCollection): FileCollection
Returns a `FileCollection` which contains the difference between this collection and the given collection.
plus
Link copied to clipboard
abstract fun plus(collection: FileCollection): FileCollection
Returns a `FileCollection` which contains the union of this collection and the given collection.
spliterator
Link copied to clipboard
open fun spliterator(): Spliterator<T>