AntBuilderAware
, Buildable
, FileCollection
, HasConfigurableValue
, java.lang.Iterable<java.io.File>
, SupportsConvention
@SupportsKotlinAssignmentOverloading public interface ConfigurableFileCollection extends FileCollection, HasConfigurableValue, SupportsConvention
A ConfigurableFileCollection
is a mutable FileCollection
.
You can obtain an instance of ConfigurableFileCollection
by calling Project.files(Object...)
or ObjectFactory.fileCollection()
.
Note: This interface is not intended for implementation by build script or plugin authors.
FileCollection.AntType
Modifier and Type | Method | Description |
---|---|---|
ConfigurableFileCollection |
builtBy(java.lang.Object... tasks) |
Registers some tasks which build the files of this collection.
|
ConfigurableFileCollection |
convention(java.lang.Iterable<?> paths) |
Specifies the value to use as the convention (default value) to be used when resolving this file collection,
if no source paths are explicitly defined.
|
ConfigurableFileCollection |
convention(java.lang.Object... paths) |
Specifies the value to use as the convention (default value) to be used when resolving this file collection,
if no source paths are explicitly defined.
|
ConfigurableFileCollection |
from(java.lang.Object... paths) |
Adds a set of source paths to this collection.
|
java.util.Set<java.lang.Object> |
getBuiltBy() |
Returns the set of tasks which build the files of this collection.
|
java.util.Set<java.lang.Object> |
getFrom() |
Returns the set of source paths for this collection.
|
void |
replace(Transformer<? extends @Nullable FileCollection,? super FileCollection> transformation) |
Replaces the current contents of this file collection with a one computed by the provided transformation.
|
ConfigurableFileCollection |
setBuiltBy(java.lang.Iterable<?> tasks) |
Sets the tasks which build the files of this collection.
|
void |
setFrom(java.lang.Iterable<?> paths) |
Sets the source paths for this collection.
|
void |
setFrom(java.lang.Object... paths) |
Sets the source paths for this collection.
|
getBuildDependencies
addToAntBuilder, addToAntBuilder, contains, filter, filter, getAsFileTree, getAsPath, getElements, getFiles, getSingleFile, isEmpty, minus, plus
disallowChanges, disallowUnsafeRead, finalizeValue, finalizeValueOnRead
unset, unsetConvention
java.util.Set<java.lang.Object> getFrom()
Project.files(Object...)
.void setFrom(java.lang.Iterable<?> paths)
Project.files(Object...)
.paths
- The paths.void setFrom(java.lang.Object... paths)
Project.files(Object...)
.paths
- The paths.@Incubating ConfigurableFileCollection convention(java.lang.Iterable<?> paths)
paths
- The paths.@Incubating ConfigurableFileCollection convention(java.lang.Object... paths)
paths
- The paths.ConfigurableFileCollection from(java.lang.Object... paths)
Project.files(Object...)
.paths
- The files to add.java.util.Set<java.lang.Object> getBuiltBy()
ConfigurableFileCollection setBuiltBy(java.lang.Iterable<?> tasks)
tasks
- The tasks. These are evaluated as per Task.dependsOn(Object...)
.ConfigurableFileCollection builtBy(java.lang.Object... tasks)
tasks
- The tasks. These are evaluated as per Task.dependsOn(Object...)
.@Incubating void replace(Transformer<? extends @Nullable FileCollection,? super FileCollection> transformation)
def collection = files("a.txt", "b.md") collection.replace { it.filter { f -> !f.name.endsWith(".txt") } } println(collection.files) // ["b.md"]
Further changes to this file collection, such as calls to setFrom(Object...)
or from(Object...)
, are not transformed, and override the replacement instead.
Because of this, this method inherently depends on the order of changes, and therefore must be used sparingly.
If this file collection consists of other mutable sources, then the current contents collection tracks changes to these sources. For example, changes to the upstream collection are visible:
def upstream = files("a.txt", "b.md") def collection = files(upstream) collection.replace { it.filter { f -> !f.name.endsWith(".txt") } } upstream.from("c.md", "d.txt") println(collection.files) // ["b.md", "c.md"]The provided transformation runs eagerly, so it can capture any objects without introducing memory leaks and without breaking configuration caching. However, transformations applied to the current contents collection (like
FileCollection.filter(Closure)
) are subject to the usual constraints.
The current contents collection inherits dependencies of this collection specified by builtBy(Object...)
.
transformation
- the transformation to apply to the current value. May return null, which empties this collection.