public interface FileCollection extends Iterable<File>, org.gradle.api.tasks.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 Project.files(java.lang.Object...)
.
修飾子とタイプ | インタフェースと説明 |
---|---|
static class |
FileCollection.AntType
Ant types which a
FileCollection can be mapped to. |
修飾子とタイプ | メソッドと説明 |
---|---|
FileCollection |
add(FileCollection collection)
Adds another collection to this collection.
|
Object |
addToAntBuilder(Object builder,
String nodeName)
Adds this collection to an Ant task as a nested node.
|
void |
addToAntBuilder(Object builder,
String nodeName,
FileCollection.AntType type)
Adds this collection to an Ant task as a nested node.
|
Object |
asType(Class<?> type)
Converts this collection into an object of the specified type.
|
boolean |
contains(File file)
Determines whether this collection contains the given file.
|
FileCollection |
filter(Closure filterClosure)
Restricts the contents of this collection to those files which match the given criteria.
|
FileCollection |
filter(Spec<? super File> filterSpec)
Restricts the contents of this collection to those files which match the given criteria.
|
FileTree |
getAsFileTree()
Converts this collection to a
FileTree . |
String |
getAsPath()
Returns the contents of this collection as a platform-specific path.
|
Set<File> |
getFiles()
Returns the contents of this collection as a Set.
|
File |
getSingleFile()
Returns the content of this collection, asserting it contains exactly one file.
|
boolean |
isEmpty()
Returns true if this collection is empty.
|
FileCollection |
minus(FileCollection collection)
Returns a
FileCollection which contains the intersection of this collection and the given collection. |
FileCollection |
plus(FileCollection collection)
Returns a
FileCollection which contains the union of this collection and the given collection. |
FileCollection |
stopExecutionIfEmpty()
Throws a
StopExecutionException if this collection is empty. |
forEach, iterator, spliterator
getBuildDependencies
File getSingleFile() throws IllegalStateException
IllegalStateException
- when this collection does not contain exactly one file.Set<File> getFiles()
boolean contains(File file)
getFiles().contains(file)
.file
- The file to check for.String getAsPath()
FileCollection plus(FileCollection collection)
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.
collection
- The other collection. Should not be null.FileCollection minus(FileCollection collection)
Returns a FileCollection
which contains the intersection 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.
collection
- The other collection. Should not be null.FileCollection filter(Closure filterClosure)
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.
filterClosure
- The closure to use to select the contents of the filtered collection.FileCollection filter(Spec<? super File> filterSpec)
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.
filterSpec
- The criteria to use to select the contents of the filtered collection.Object asType(Class<?> type) throws UnsupportedOperationException
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.
type
- The type to convert to.UnsupportedOperationException
- When an unsupported type is specified.FileCollection add(FileCollection collection) throws UnsupportedOperationException
Adds another collection to this collection. This is an optional operation.
collection
- The collection to add.UnsupportedOperationException
- When this collection does not allow modification.boolean isEmpty()
getFiles().isEmpty()
.FileCollection stopExecutionIfEmpty() throws StopExecutionException
StopExecutionException
if this collection is empty.StopExecutionException
- When this collection is empty.FileTree getAsFileTree()
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.FileTree
. Never returns null.void addToAntBuilder(Object builder, String nodeName, FileCollection.AntType type)
FileCollection.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.FileCollection.AntType.FileSet
: adds this collection as zero or more Ant FileSets with the given node name.FileCollection.AntType.ResourceCollection
: adds this collection as zero or more Ant ResourceCollections with the
given node name.FileCollection.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.builder
- The builder to add this collection to.nodeName
- The target node name.type
- The target Ant type