Hey, I am still working (and reading + learning) o...
# configuration-cache
l
Hey, I am still working (and reading + learning) on some of my CC issues, is there a way to see which part(s) of my task are the problem (variable name, or class names, something which would give me a hint where to look) when something like this is reported:
1 problem was found storing the configuration cache.
`- Task
:models:migrateDocumentModels
of type `org.gradle.api.DefaultTask`: cannot serialize Gradle script object references as these are not supported with the configuration cache.`
See <https://docs.gradle.org/9.1.0/userguide/configuration_cache_requirements.html#config_cache:requirements:disallowed_types>
That would be really helpful - I know the report has a hierarchical view, but that one has e.g. "this$0" which is not that helpful. I've got this task at the moment, which does result in the problem found above (it calls a jar / javaexec task in a loop):
val docModelMigration: Configuration by configurations.creating
docModelMigration.isTransitive = false
dependencies {
docModelMigration(libs.tool.model.migration) {
artifact {
classifier = "jar-with-dependencies"
}
}
}
val models =
listOf(
"modelA",
"modelB"
)
val migrateDocumentModels =
tasks.register("migrateDocumentModels") {
val myModels = models.toMutableList()
val myWorkingDir = layout.projectDirectory.asFile
val classPathFiles =
files(
docModelMigration.files,
java.sourceSets.main
.get()
.resources.srcDirs,
)
doLast {
myModels.forEach { model ->
val theTask =
providers
.javaexec {
workingDir = myWorkingDir
classpath = classPathFiles
mainClass = "com.example.migration.MigratorCli"
args = listOf(model)
}
theTask.result.get().assertNormalExitValue()
println(
theTask.standardOutput.asText
.get()
.trim(),
)
}
}
}
Anyone an idea what is wrong here - I moved all those project refs (working dir, classpath file collections from the configuration) out of
doLast { }
but I am still missing something here, what I am doing wrong, hints appreciated, thx.
v
Gradle cannot really know what exactly the problematic access is, or at least noone programmed it if it were possible.
The problem is
providers
val providers = providers
and it works
Here is the issue about improving it: https://github.com/gradle/gradle/issues/20930
l
Thx, you're right - I totally missed the
providers
- which is from the
project
.
👌 1
And thanks for that issue link too.
👌 1
v
Yep. Actually, with
val migrateDocumentModels = tasks.register("migrateDocumentModels") {
it complains about the script object, with only
tasks.register("migrateDocumentModels") {
it complains about the project object. Slight difference in the compilation result I guess.