Skip to content

Comments

Fix: (build) Defer shadowJar output access to fix exclusive lock issue#4805

Merged
NotMyFault merged 2 commits intoIntellectualSites:mainfrom
LcyDev:fix
Dec 22, 2025
Merged

Fix: (build) Defer shadowJar output access to fix exclusive lock issue#4805
NotMyFault merged 2 commits intoIntellectualSites:mainfrom
LcyDev:fix

Conversation

@LcyDev
Copy link
Contributor

@LcyDev LcyDev commented Dec 15, 2025

Overview

[error] FAILURE: Build failed with an exception.

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

Description

This issue is only present when running the project with org.gradle.parallel=true

The previous implementation accessed the .archiveFile property directly during the configuration phase. This is not allowed.

This eager access forces Gradle to resolve dependent configs inmmediately, potentially leading to this error when running in parallel or with Configuration Cache.

  • Resolves exclusive lock error by deferring Jar output access
  • Avoids eager task output resolution for runServer tasks.
  • Uses Provider API for shadowJar output in runServer tasks.

This ensures that the output file path is only resolved during the Execution Phase, where Gradle holds the necessary locks, thereby eliminating the unsafe access and improving build stability ;)

Gradle Docs

Submitter Checklist

  • Make sure you are opening from a topic branch (/feature/fix/docs/ branch (right side)) and not your main branch.
  • Ensure that the pull request title represents the desired changelog entry.
  • New public fields and methods are annotated with @since TODO.
  • I read and followed the contribution guidelines.

@LcyDev LcyDev requested a review from a team as a code owner December 15, 2025 06:56
@github-actions github-actions bot added the Bugfix This PR fixes a bug label Dec 15, 2025
build.gradle.kts Outdated
.map { task -> (task as Jar).archiveFile }
.toTypedArray())
// Defer the access to the execution phase.
pluginJars(project.files(plotSquaredShadowJarProviders))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need to move the logic further up into a variable but makes sense otherwise

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're totally right. my bad.

@NotMyFault NotMyFault requested review from a team and dordsor21 December 17, 2025 16:32
Avoids eager task output resolution for runServer tasks
Uses Provider API for shadowJar output in runServer tasks
@dordsor21 dordsor21 requested a review from a team December 22, 2025 16:26
Copy link
Collaborator

@NotMyFault NotMyFault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable

@NotMyFault NotMyFault merged commit 8caa426 into IntellectualSites:main Dec 22, 2025
9 checks passed
pull bot pushed a commit to Craftstuebchen/PlotSquared that referenced this pull request Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugfix This PR fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants