api / org.gradle.api.file / ConfigurableFileCollection

ConfigurableFileCollection

interface ConfigurableFileCollection : FileCollection

A ConfigurableFileCollection is a mutable FileCollection.

You can obtain an instance of ConfigurableFileCollection by calling

Functions

builtBy

abstract fun builtBy(vararg tasks: Any): ConfigurableFileCollection

Registers some tasks which build the files of this collection.

from

abstract fun from(vararg paths: Any): ConfigurableFileCollection

Adds a set of source paths to this collection. The given paths are evaluated as per org.gradle.api.Project#files(Object...).

getBuiltBy

abstract fun getBuiltBy(): MutableSet<Any>

Returns the set of tasks which build the files of this collection.

getFrom

abstract fun getFrom(): MutableSet<Any>

Returns the set of source paths for this collection. The paths are evaluated as per org.gradle.api.Project#files(Object...).

setBuiltBy

abstract fun setBuiltBy(tasks: MutableIterable<*>): ConfigurableFileCollection

Sets the tasks which build the files of this collection.

setFrom

abstract fun setFrom(paths: MutableIterable<*>): Unit
abstract fun setFrom(vararg paths: Any): Unit

Sets the source paths for this collection. The given paths are evaluated as per org.gradle.api.Project#files(Object...).

Inherited Functions

add

abstract fun add(collection: FileCollection): FileCollection

Adds another collection to this collection. This is an optional operation.

addToAntBuilder

abstract fun addToAntBuilder(builder: Any, nodeName: String, type: AntType): Unit

Adds this collection to an Ant task as a nested node. The given type determines how this collection is added:

  • AntType#MatchingTask: adds this collection to an Ant MatchingTask. The collection is converted to a set of source directories and include and exclude patterns. The source directories as added as an Ant Path with the given node name. The patterns are added using 'include' and 'exclude' nodes.
  • AntType#FileSet: adds this collection as zero or more Ant FileSets with the given node name.
  • AntType#ResourceCollection: adds this collection as zero or more Ant ResourceCollections with the given node name.
You should prefer using AntType#ResourceCollection, if the target Ant task supports it, as this is generally the most efficient. Using the other types may involve copying the contents of this collection to a temporary directory.

abstract fun addToAntBuilder(builder: Any, nodeName: String): Any

Adds this collection to an Ant task as a nested node. Equivalent to calling addToAntBuilder(builder, nodeName,AntType.ResourceCollection).

asType

abstract fun asType(type: Class<*>): Any

Converts this collection into an object of the specified type. Supported types are: Collection, List, Set, Object[], File[], File, and FileTree.

You can call this method in your build script using the as operator.

contains

abstract fun contains(file: File): Boolean

Determines whether this collection contains the given file. Generally, this method is more efficient than calling getFiles().contains(file).

filter

abstract fun filter(filterClosure: Closure<Any>): FileCollection

Restricts the contents of this collection to those files which match the given criteria. The filtered collection is live, so that it reflects any changes to this collection.

The given closure is passed the File as a parameter, and should return a boolean value.

abstract fun filter(filterSpec: Spec<in File>): FileCollection

Restricts the contents of this collection to those files which match the given criteria. The filtered collection is live, so that it reflects any changes to this collection.

getAsFileTree

abstract fun getAsFileTree(): FileTree

Converts this collection to a FileTree. Generally, for each file in this collection, the resulting file tree will contain the source file at the root of the tree. For each directory in this collection, the resulting file tree will contain all the files under the source directory.

getAsPath

abstract fun getAsPath(): String

Returns the contents of this collection as a platform-specific path. This can be used, for example, in an Ant <path> element.

getFiles

abstract fun getFiles(): MutableSet<File>

Returns the contents of this collection as a Set.

getSingleFile

abstract fun getSingleFile(): File

Returns the content of this collection, asserting it contains exactly one file.

isEmpty

abstract fun isEmpty(): Boolean

Returns true if this collection is empty. Generally, calling this method is more efficient than calling getFiles().isEmpty().

minus

abstract fun minus(collection: FileCollection): FileCollection

Returns a FileCollection which contains the difference between this collection and the given collection. The returned collection is live, and tracks changes to both source collections.

You can call this method in your build script using the - operator.

plus

abstract fun plus(collection: FileCollection): FileCollection

Returns a FileCollection which contains the union of this collection and the given collection. The returned collection is live, and tracks changes to both source collections.

You can call this method in your build script using the + operator.

stopExecutionIfEmpty

abstract fun stopExecutionIfEmpty(): FileCollection

Throws a StopExecutionException if this collection is empty.

Extension Functions

getValue

operator fun ConfigurableFileCollection.getValue(receiver: Any?, property: KProperty<*>): ConfigurableFileCollection

Property delegate for ConfigurableFileCollection instances.

setValue

operator fun ConfigurableFileCollection.setValue(receiver: Any?, property: KProperty<*>, value: Iterable<*>): Unit

Property delegate for ConfigurableFileCollection instances.