update
Applies an eager transformation to the current contents of this file collection, without explicitly resolving it. The provided transformer is applied to the file collection representing the current contents, and the returned collection is used as a new content. The current contents collection can be used to derive the new value, but doesn't have to. Returning null from the transformer empties this collection. For example, it is possible to filter out all text files from the collection:
def collection = files("a.txt", "b.md")
collection.update { it.filter { f -> !f.name.endsWith(".txt") } }
println(collection.files) // ["b.md"]
Further changes to this file collection, such as calls to setFrom or from, are not transformed, and override the update 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 the 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.update { it.filter { f -> !f.name.endsWith(".txt") } }
upstream.from("c.md", "d.txt")
println(collection.files) // ["b.md", "c.md"]
The current contents collection inherits dependencies of this collection specified by builtBy.
Parameters
the transformation to apply to the current value. May return null, which empties this collection.