Skip to content

Gradle 9.0.0 incompatibility #2599

@JavierSegoviaCordoba

Description

@JavierSegoviaCordoba

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions