Slackbot
03/03/2023, 9:39 PMRyan Schmitt
03/03/2023, 9:43 PMfrom(files(task).asFileTree.filter {
it.path.endsWith("dir1/dir2/file")
})
Ryan Schmitt
03/03/2023, 9:44 PMRyan Schmitt
03/03/2023, 10:28 PMFileTree
is clearly powerful but I don't really understand how it works, particularly when derived from some other file collection, e.g. by filtering, merging, calling asFileTree
...Adam
03/04/2023, 8:29 AMTo convert a file tree to a flat collection, use thehttps://docs.gradle.org/current/userguide/working_with_files.html#sec:file_treesproperty.FileTree.getFiles()
Ryan Schmitt
03/07/2023, 7:24 PMRyan Schmitt
03/07/2023, 7:24 PMFileTree
has to wait until execution timeRyan Schmitt
03/07/2023, 7:25 PMgetFiles()
on a Buildable
with build dependencies just silently returns an empty file set, instead of throwing an exceptionAdam
03/07/2023, 7:32 PMval files: Provider<Collection<File>> =
task.map { it.outputFiles.myCustomFlattenFilteringOperation() }
from(files)
Gradle will know that it needs to run task
in order to compute files
Adam
03/07/2023, 7:34 PMproviders.provider { task.files... }
to make a custom provider (but then Gradle doesn’t realise there’s a task dependency)
and I think with file collections you can even just pass in a lambda and it’ll be lazily evaluated
from({ task.files... })
Ryan Schmitt
03/08/2023, 1:11 AMRyan Schmitt
03/08/2023, 1:11 AMtask.outputFiles
but I do see task.outputs.files
Ryan Schmitt
03/08/2023, 1:11 AMtask.outputDirectory
which I think was removed in Gradle 8Adam
03/08/2023, 9:28 AM.outputFiles
is psuedo-code :)