Slackbot
12/15/2022, 10:34 AMAlexander Likhachev
12/15/2022, 7:15 PMtasks.register("myTask") {
val inputConfiguration: FileCollection = configurations.runtimeClasspath.get()
inputs.files(inputConfiguration)
val outputFile = layout.buildDirectory.file("output.txt")
outputs.file(outputFile)
doFirst {
outputFile.get().asFile.writeText(inputConfiguration.files.joinToString { "${it.name}: ${it.readBytes().size}"})
}
}
Execution time depends on configuration (and configuration cache respectively), not vice versaMartin
12/15/2022, 7:31 PMExecution time depends on configurationI mean that's a constraint introduced by CC, right? Without CC the code above works well. I'm guessing because evaluation of the provider is postponed to
:app:myTask
execution (or just before I guess, not sure), which seems to be enough to let :lib:jar
the time to execute.Martin
12/15/2022, 7:32 PMMartin
12/15/2022, 7:32 PMAlexander Likhachev
12/15/2022, 11:27 PMI mean that’s a constraint introduced by CC, right?I guess it is a general direction where Gradle goes — defining more strict rules to be able to optimize things and keep them understandable. This particular thing may be a bug, but I’m not sure, may be someone from Gradle team could answer more precisely. Documentation of
TaskInputs.property
says:
If the value is not known when registering the input, a org.gradle.api.provider.Provider can be passed instead. Gradle will then resolve the provider at the latest possible time in order to determine the actual property value.
Alexander Likhachev
12/15/2022, 11:29 PMconfigurations
on the project
instance, which usage is restricted with configuration cache at execution time.