Current Behavior
When task defines output as filtered via include/exclude filters fileTree the root directory of fileTree is considered as output.
Expected Behavior
If task output uses a filtered fileTree, the root directory of the fileTree should not be considered as output, only files/directories matching the exclude/include patterns should be considered as outputs.
Context (optional)
No response
Steps to Reproduce
This dummy build.gradle.kts showcases the issue:
plugins {
base
}
// This mocks the task that takes `.graphqls` files in `src` directory and generates `.go` files from them in the same directory.
// The files are partly generated and supposed to be edited manually after generation, to implement actual resolver logic, thats
// why they sit in the `src` directory
tasks.register<Exec>("generate") {
commandLine("echo", "Generating..")
inputs.files(layout.projectDirectory.dir("src").asFileTree.matching{ include("*.graphqls") })
outputs.files(layout.projectDirectory.dir("src").asFileTree.matching{ include("*.go") })
doLast{
println("Generation complete.")
}
}
// This mocks the task that validates the `.graphqls` files in the `src` directory
// This have no dependency on `generate`, as it only validates the `.graphqls` files that are not generated by the `generate` task
tasks.register<Exec>("validate") {
commandLine("echo", "Validating...")
inputs.files(layout.projectDirectory.dir("src").asFileTree.matching { include("*.graphqls") })
doLast {
println("Validation complete.")
}
}
tasks.named("build") {
dependsOn("validate", "generate")
}
Executing gradle's build task results in the following error:
A problem was found with the configuration of task ':validate' (type 'Exec').
- Gradle detected a problem with the following location: '/tmp/gradle_tasks/src'.
Reason: Task ':validate' uses this output of task ':generate' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
As a workaround for this i am calling .elements on the fileTree and passing the result as task output:
outputs.files(layout.projectDirectory.dir("src").asFileTree.matching{ include("*.go") }.elements)
Gradle version
8.9
Build scan URL (optional)
No response
Your Environment (optional)
No response
Current Behavior
When task defines output as filtered via include/exclude filters fileTree the root directory of fileTree is considered as output.
Expected Behavior
If task output uses a filtered fileTree, the root directory of the fileTree should not be considered as output, only files/directories matching the exclude/include patterns should be considered as outputs.
Context (optional)
No response
Steps to Reproduce
This dummy
build.gradle.ktsshowcases the issue:plugins { base } // This mocks the task that takes `.graphqls` files in `src` directory and generates `.go` files from them in the same directory. // The files are partly generated and supposed to be edited manually after generation, to implement actual resolver logic, thats // why they sit in the `src` directory tasks.register<Exec>("generate") { commandLine("echo", "Generating..") inputs.files(layout.projectDirectory.dir("src").asFileTree.matching{ include("*.graphqls") }) outputs.files(layout.projectDirectory.dir("src").asFileTree.matching{ include("*.go") }) doLast{ println("Generation complete.") } } // This mocks the task that validates the `.graphqls` files in the `src` directory // This have no dependency on `generate`, as it only validates the `.graphqls` files that are not generated by the `generate` task tasks.register<Exec>("validate") { commandLine("echo", "Validating...") inputs.files(layout.projectDirectory.dir("src").asFileTree.matching { include("*.graphqls") }) doLast { println("Validation complete.") } } tasks.named("build") { dependsOn("validate", "generate") }Executing gradle's build task results in the following error:
As a workaround for this i am calling
.elementson the fileTree and passing the result as task output:Gradle version
8.9
Build scan URL (optional)
No response
Your Environment (optional)
No response