Hello, Gradle report a Configuration cache proble...
# community-support
e
Hello, Gradle report a Configuration cache problems on a `Logger`reference. Is this expected behavior ? Error message:
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
Configuration cache problems found in this build.

1 problem was found storing the configuration cache.
- Task `:list:checkReproCase` 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/8.11.1/userguide/configuration_cache.html#config_cache:requirements:disallowed_types>
The error complains about a
GradleScript
reference see UnsupportedTypesCodecs.kt#L93 Gradle version
8.13
,
8.11.1
Reprocase :
Copy code
val checkReproCase by tasks.registering(Task::class) {
    doLast {
        logReproCase(logger)
    }
}

private fun logReproCase(logger:Logger) {
    logger.info("reprocase")
}

tasks.check {
    dependsOn(checkReproCase)
}
p
You should store the logger in a variable, otherwise you use
project.logger
implicitly during runtime and any project access is not allowed at runtime.
Copy code
val checkReproCase by tasks.registering(Task::class) {
    val logger = logger
    doLast {
        logReproCase(logger)
    }
}
e
Same error using
Copy code
val checkReproCase by tasks.registering(Task::class) {
    val loggerRef = logger
    doLast {
        logReproCase(loggerRef)
    }
}

private fun logReproCase(loggerParam:Logger) {
    <http://loggerParam.info|loggerParam.info>("reprocase")
}

tasks.check {
    dependsOn(checkReproCase)
}
v
Because the problem is not (or at least not exclusively) the
logger
. You call a function that you defined in the script. So to call that function you need the reference to that script instance and that is what it complains about.
e
Thank you @Philip W, @Vampire for taking time to help me. Yes you are right, I forgot that I was not in a kotlin file but in a gradle script. I will test it and report it here.
Problem solved thank you. Moving my code out of the script remove the problem. Thank you and have a nice week.
👌 1