How to disable build failures with enabled configuration cache in Gradle?

I have:

gradle.properties

org.gradle.configuration-cache=true
org.gradle.configuration-cache.problems=warn

JIB plugin defined:

jib {
	container {
		creationTime.set("USE_CURRENT_TIMESTAMP")
		mainClass = "com.my.MyApp"
	}
	from {
		image = "eclipse-temurin:17-jre"
	}
}

I run:

./gradlew jibDockerBuild

I get:

> Task :jibDockerBuild FAILED

10 problems were found storing the configuration cache, 2 of which seem unique.
- Task `:jibDockerBuild` of type `com.google.cloud.tools.jib.gradle.BuildDockerTask`: cannot deserialize object of type 'org.gradle.api.Project' as these are not supported with the configuration cache.
  See https://docs.gradle.org/8.1.1/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
- Task `:jibDockerBuild` of type `com.google.cloud.tools.jib.gradle.BuildDockerTask`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
  See https://docs.gradle.org/8.1.1/userguide/configuration_cache.html#config_cache:requirements:disallowed_types

See the complete report at file:///Users/artemptushkin/gitlab/IptiQ/dx/spring-cloud-config-server/build/reports/configuration-cache/dmnth65ek47ehgnuriyy459yl/ac38wk6b6wvejhas26wg0jngi/configuration-cache-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':jibDockerBuild'.
> Cannot invoke "org.gradle.api.Project.getProjectDir()" because "this.project" is null

It passes away when I disable the configuration cache

My expectations are that if I set org.gradle.configuration-cache.problems=warn then it never fails though it does

Relevant issue in the plugin Configuration cache problems in Gradle 8.1 · Issue #225 · n0mer/gradle-git-properties · GitHub

Feels like a bug to me.
Before Gradle 8, the task execution was done just normal from the actively built model in the run storing the configuration cache.
Since 8.0 even in the run storing the cache, the state as deserialized from the configuration cache is used, to have a more consistent and defined behavior for example.

I believe that this changes causes your problem.
It should probably use the built model and not the deserialized one if there are CC problems and the setting is to just warn.

You should definitely open a bug report about it and post its link here.

As a work-around you could try to declare that task as CC incompatible, maybe it works then.

If not, the only work-around would probably be to downgrade Gradle, or disable the CC.

Thanks, I opened a bug

Great, please post the link here, so anyone finding this thread can follow and thumbs-up.

Gradle build fails with configuration cache enabled with warnings · Issue #25235 · gradle/gradle · GitHub the corresponded Gradle bug

@Vampire take a look into the bug, please @eskatos says it’s just a documentation issue

Well, I’m just a user like you.
If Paul considers this just a doc issue, that’s maybe the case.
I added my voice to the issue, but ultimately the Gradle guys decide of course. :slight_smile: