interface FileCollection : MutableIterable<File>, AntBuilderAware, Buildable
A FileCollection
represents a collection of files which you can query in certain ways. A file collection is often used to define a classpath, or to add files to a container.
You can obtain a FileCollection
instance using org.gradle.api.Project#files
.
class AntType
Ant types which a |
abstract fun add(collection: FileCollection): FileCollection
Adds another collection to this collection. This is an optional operation. |
|
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#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 |
|
abstract fun asType(type: Class<*>): Any
Converts this collection into an object of the specified type. Supported types are: You can call this method in your build script using the |
|
abstract fun contains(file: File): Boolean
Determines whether this collection contains the given file. Generally, this method is more efficient than calling |
|
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. |
|
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. |
|
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. |
|
abstract fun getFiles(): MutableSet<File>
Returns the contents of this collection as a Set. |
|
abstract fun getSingleFile(): File
Returns the content of this collection, asserting it contains exactly one file. |
|
abstract fun isEmpty(): Boolean
Returns true if this collection is empty. Generally, calling this method is more efficient than calling |
|
abstract fun minus(collection: FileCollection): FileCollection
Returns a You can call this method in your build script using the |
|
abstract fun plus(collection: FileCollection): FileCollection
Returns a You can call this method in your build script using the |
|
abstract fun stopExecutionIfEmpty(): FileCollection
Throws a StopExecutionException if this collection is empty. |
abstract fun getBuildDependencies(): TaskDependency
Returns a dependency which contains the tasks which build this artifact. All |
interface ConfigurableFileCollection : FileCollection
A You can obtain an instance of |
|
interface Configuration : FileCollection, HasConfigurableAttributes<Configuration>
A Configuration is an instance of a FileCollection that contains all dependencies (see also |
|
interface FileTree : FileCollection
A You can obtain a |
|
interface SourceSetOutput : FileCollection
A collection of all output directories (compiled classes, processed resources, etc.) - notice that SourceSetOutput extends FileCollection. Provides output information of the source set. Allows configuring the default output dirs and specify additional output dirs. Working with generated resources.
In general, we recommend generating resources into folders different than the regular resourcesDir and classesDir. Usually, it makes the build easier to understand and maintain. Also it gives some additional benefits because other Gradle plugins can take advantage of the output dirs 'registered' in the SourceSet.output. For example: Java plugin will use those dirs in calculating class paths and for jarring the content; IDEA and Eclipse plugins will put those folders on relevant classpath. An example how to work with generated resources: Find more information in #dir(java.util.Map, Object) and #getDirs()
|