spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Gradle 9.0.0 incompatibility

Open JavierSegoviaCordoba opened this issue 4 months ago • 2 comments

After upgrading Gradle to 9.0.0 in a project, it fails with

* What went wrong:
Execution failed for task ':spotlessInternalRegisterDependencies'.
> Cannot mutate configuration container for buildscript of root project 'semver-gradle-plugin-project' using create(String). Configurations cannot be added or removed from the buildscript configuration container.

With configuration cache disabled.

The next error is with config cache enabled:


1 problem was found storing the configuration cache.
- Task `:spotlessInternalRegisterDependencies` of type `com.diffplug.gradle.spotless.RegisterDependenciesTask`: error writing value of type 'com.diffplug.spotless.JarState$Promised'

...

* What went wrong:
Configuration cache state could not be cached: field `jarState` of `com.diffplug.spotless.kotlin.KtfmtStep` bean found in field `roundtripStateInternal` of `com.diffplug.spotless.FormatterStepSerializationRoundtrip` bean found in field `steps` of task `:spotlessInternalRegisterDependencies` of type `com.diffplug.gradle.spotless.RegisterDependenciesTask`: error writing value of type 'com.diffplug.spotless.JarState$Promised'
> Cannot mutate configuration container for buildscript of root project 'semver-gradle-plugin-project' using create(String). Configurations cannot be added or removed from the buildscript configuration container.

Which is probably the same issue.

I am using the next configurations:

if (isRootProject) {
    configure<SpotlessExtensionPredeclare> {
        kotlin { kotlin -> kotlin.ktfmt(ktfmtVersion.get()) }
    }
}
configure<SpotlessExtension> {
    kotlin { kotlin ->
        kotlin.target(includes.get())
        kotlin.targetExclude(excludes.get())
        kotlin.ktfmt(ktfmtVersion.get()).kotlinlangStyle()
    }
}

And I think it is related to SpotlessExtensionPredeclare, but if I remove it, I get

* What went wrong:
Configuration cache state could not be cached: field `stepsInternalEquality` of task `:spotlessKotlin` of type `com.diffplug.gradle.spotless.SpotlessTaskImpl`: error writing value of type 'com.diffplug.spotless.ConfigurationCacheHackList'
> Add a step with [com.facebook:ktfmt:0.56] into the `spotlessPredeclare` block in the root project.

Or without config cache:

* What went wrong:
Execution failed for task ':spotlessKotlin'.
> Add a step with [com.facebook:ktfmt:0.56] into the `spotlessPredeclare` block in the root project.

JavierSegoviaCordoba avatar Aug 16 '25 16:08 JavierSegoviaCordoba

Maybe related to this?

  • https://github.com/diffplug/spotless/issues/1633

JavierSegoviaCordoba avatar Aug 16 '25 16:08 JavierSegoviaCordoba

Disabling everything related to predeclared dependencies fixes the issue.

JavierSegoviaCordoba avatar Aug 16 '25 16:08 JavierSegoviaCordoba