LoremIpsum-42
09/25/2025, 10:37 AM1 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.Vampire
09/25/2025, 10:51 AMVampire
09/25/2025, 10:51 AMprovidersVampire
09/25/2025, 10:51 AMval providers = providers and it worksVampire
09/25/2025, 10:54 AMLoremIpsum-42
09/25/2025, 10:55 AMproviders - which is from the project .LoremIpsum-42
09/25/2025, 10:56 AMVampire
09/25/2025, 10:56 AMval 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.