Skip to content

Broken with OpenJDK 24 (gradle 9.x snapshots) #4018

Open

Description

@theoparis

See gradle/gradle#32597

[error] FAILURE: Build failed with an exception.

* What went wrong:
Resolution of the configuration ':brigadier:annotationProcessor' was attempted without an exclusive lock. This is unsafe and not allowed.

The project builds fine from the command line (with JAVA_HOME set to Java 24), so I assume it is an issue with this extension, or maybe eclipse jdtls.

Activity

  1. einarjohnson commented on Sep 25, 2025

    @einarjohnson

    did you ever figure this one out? having the same issue

  2. added a commit that references this issue on Oct 7, 2025
  3. PyvesB commented on May 27, 2026

    @PyvesB

    Worth noting that this is not specific to Java 24 nor to Gradle snapshots. The issue remains on Java 25 and 26, as well as stable Gradle 9 releases.

    I managed to work around the issue by adding the following Gradle init file with Claude's help (~/.gradle/init.d/ide-import-compat.init.gradle.kts):

    import org.gradle.api.internal.project.ProjectInternal
    
    // Gradle 9.x requires an exclusive project lock to resolve any configuration.
    // When the Gradle Build Server fetches the IDE model via a BuildAction, it resolves
    // all resolvable configurations (annotationProcessor, checkstyle, compileClasspath, …)
    // without holding individual sub-project locks, causing:
    //   "Resolution of the configuration '...' was attempted without an exclusive lock."
    //
    // Fix: pre-resolve ALL resolvable configurations in gradle.projectsEvaluated, which fires
    // after ALL afterEvaluate callbacks complete. We acquire each project's lock explicitly via
    // applyToMutableState so hasMutableState() is true during resolution.
    // DefaultConfiguration.resolveGraphIfRequired() then short-circuits on the cached result
    // before the hasMutableState() check when the GBS model builder runs.
    if (gradle.startParameter.taskNames.isEmpty()) {
        gradle.projectsEvaluated {
            rootProject.allprojects {
                val projectOwner = (this as ProjectInternal).owner
                configurations
                    .filter { it.isCanBeResolved }
                    .forEach { config ->
                        projectOwner.applyToMutableState { _ ->
                            try {
                                config.resolve()
                            } catch (_: Exception) {
                                // Ignore — best-effort pre-resolution; IDE import takes priority.
                            }
                        }
                    }
            }
        }
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions