Slackbot
02/07/2024, 1:06 PMMartin
02/07/2024, 1:19 PMprovider {
configuration.files.md5()
}
Can the CC be smart enough to not invalidate here?Vampire
02/07/2024, 1:34 PMValueSource
. In that case only the result of the value source would make the CC invalid or not, but then is executed on every build even if CC is reused and if not reused even twice.Martin
02/07/2024, 1:45 PMMartin
02/07/2024, 1:57 PMinput.set(configuration.elements.map { it.md5() })
Martin
02/07/2024, 1:57 PMprovider { configuration... }
doesn't work at all because it breaks task dependency (which is not related to CC)Vampire
02/07/2024, 2:09 PMelements
is there to get a Provider
that carries the task dependencies of the FileCollection
.
Actually I wonder that input.set(configuration.elements.map { it.md5() })
is not invalidating the CC.
I thought the providers are calculated at the time the CC entry is written and the result persisted.Martin
02/07/2024, 2:22 PMpublic ExecutionTimeValue<? extends T> calculateExecutionTimeValue() {
if (contentsAreBuiltByTask()) {
return ExecutionTimeValue.changingValue(this);
}
return ExecutionTimeValue.fixedValue(get());
}
so if the configuration is buildable by a task then get()
isn't called and instead the transforming lambdas are serialized insteadMartin
02/07/2024, 2:24 PMVampire
02/07/2024, 2:29 PMVampire
02/07/2024, 2:32 PMfoo.txt
contents:
abstract class Foo : DefaultTask() {
@get:Input
abstract val input: Property<String>
@TaskAction
fun foo() {
println("input = ${input.get()}")
}
}
val fooBucket by configurations.dependencyScope("fooBucket")
val fooElements = configurations.resolvable("fooElements") {
extendsFrom(fooBucket)
}
dependencies {
fooBucket(files("foo.txt"))
}
val foo by tasks.registering(Foo::class) {
input = fooElements.flatMap { it.elements }.map { it.single().asFile.readText() }
}
Martin
02/07/2024, 2:36 PMMartin
02/07/2024, 2:37 PMconfiguration
to be serialized as a "changing" value all the time (even when contents are not built by tasks)Vampire
02/07/2024, 2:37 PMabstract class Foo : DefaultTask() {
@get:Input
abstract val input: Property<String>
@TaskAction
fun foo() {
println("input = ${input.get()}")
}
}
val fooBucket by configurations.dependencyScope("fooBucket")
val fooElements = configurations.resolvable("fooElements") {
extendsFrom(fooBucket)
}
val bar by tasks.registering(Sync::class) {
from(file("foo.txt"))
into(layout.buildDirectory.dir("bar"))
}
dependencies {
fooBucket(bar.map { it.outputs.files })
}
val foo by tasks.registering(Foo::class) {
input = fooElements.flatMap { it.asFileTree.elements }.map { it.single().asFile.readText() }
}
Vampire
02/07/2024, 2:39 PMWhat preventsIt would typically be slower. If you can calculate a value at configuration time and persist the result, you don't have to do the calculation when CC is reused as the result of the calculation is already present.to be serialized as a "changing" value all the time (even when contents are not built by tasks)configuration
Vampire
02/07/2024, 2:39 PMVampire
02/07/2024, 2:40 PMMartin
02/07/2024, 2:40 PM