Andrea Di Menna
03/01/2024, 11:36 AMWriteProperties
task which seems to be not restored from the build cache. This happens not consistently.
I get
> Task :gradle-plugins:config-gradle-plugin:props FROM-CACHE
Appending implementation to build cache key: org.gradle.api.tasks.WriteProperties_Decorated@7f188f326239382116310befb40da15f
Appending additional implementation to build cache key: org.gradle.api.tasks.WriteProperties_Decorated@7f188f326239382116310befb40da15f
Appending input value fingerprint for 'comment' to build cache key: f6bd6b3389b872033d462029172c8612
Appending input value fingerprint for 'encoding' to build cache key: a01a9ddf322da930e94b377f84683032
Appending input value fingerprint for 'lineSeparator' to build cache key: d0608bef942477d145a034e0902d2ff8
Appending input value fingerprint for 'properties' to build cache key: 3a19c1074096c79765360687c2843f48
Appending output property name to build cache key: destinationFile
Build cache key for task ':gradle-plugins:config-gradle-plugin:props' is 3edb56921b5aba38b2f0c0e8e1ab8a9a
but then there is no such file in the directory where it should be restored.
This does not happen with Gradle 8.5
Do you have any hints to follow?Vampire
03/01/2024, 11:58 AMAndrea Di Menna
03/01/2024, 12:02 PMVampire
03/01/2024, 12:10 PMAndrea Di Menna
03/01/2024, 12:21 PMMETADATA
tree-destinationFile
the content of tree-destinationFile
is the properties file written by the task.
Is this correct?
The task is definition is
val props = tasks.register<WriteProperties>("props") {
destinationFile.set(file("${project.buildDir}/resources/main/${project.name}.properties"))
property("version", project.version)
}
Vampire
03/01/2024, 12:41 PMprocessResources
task - which effectively is like a Sync
task - runs after the cache was restored and thus removes the file that should not be there and is considered a stale file from a previous run.Vampire
03/01/2024, 12:41 PMVampire
03/01/2024, 12:42 PMsourcesJar
task will not ever see your file or have the necessary task dependency implicitly.Vampire
03/01/2024, 12:43 PMsourceSets {
main {
resources {
srcDir(propsTask)
}
}
}
Vampire
03/01/2024, 12:44 PMsrc/main/resources
with placeholders and configure the processResources
task to expand(...)
the placeholder.
This imho has various advantages, except if you also need that file dedicated for some other task.Andrea Di Menna
03/01/2024, 12:58 PMexpand
approach 😄