Skip to content

Fix Gradle build performance issues and enable configuration cache support - #3616

Open
MattBDev wants to merge 1 commit into
mainfrom
gradle-optimizations
Open

Fix Gradle build performance issues and enable configuration cache support#3616
MattBDev wants to merge 1 commit into
mainfrom
gradle-optimizations

Conversation

@MattBDev

Copy link
Copy Markdown
Contributor

Overview

Three small changes were made to the build scripts that remove redundant or legacy Gradle tasks/behavior. One of which unblocks Gradle's configuration cache and removes a dependency on a legacy Gradle plugin.

Description

  • Replaced our dependency on Grgit with a providers.exec-based helper for reading the commit hash and date. Previously, Grgit forked git twice at configuration time, which the configuration cache does not support. Grgit will never add support for the configuration cache and is in fact considered to be in "maintenance mode". providers.exec results are recorded as declared build inputs instead, so they can be cached and replayed.
    • Hash length from Grgit/Jgit is preserved.
  • Removed the allprojects { gradle.projectsEvaluated { ... } } wrapper around the configurateEach blocks. configureEach is already lazy and doesn't need an outer lifecycle hook. The wrapper was registering 18 identical callbacks (one per subproject) for no effect.
    • There is a behavioral change with this. The root's compiler-arg/test-logging settings now register earlier relative to subproject configuration. A subproject setting the same property would now win where root previously won. There are currently no subprojects currently setting these (only worldedit-core:test.maxHeapSize, untouched by this block).
  • Removed tasks.compileJava { dependsOn(":worldedit-libs:build") }. :worldedit-libs:build is a lifecycle task, not a jar — depending on it pulled in the full build/check/sourcesJar/javadocJar of all four worldedit-libs:* projects, including bukkit and cli, which worldedit-core does not use. The existingapi(project(":worldedit-libs:core")) / annotationProcessor(project(":worldedit-libs:core:ap")) dependencies already carry correct task ordering via Gradle's variant-aware resolution (outgoing.artifact(tasks.named("jar")) inbuildlogic.libs.gradle.kts), so the explicit dependsOn was redundant as well as too broad. It also broke configureondemand for any single-project build:
    > ./gradlew :worldedit-core:compileJava
    Task with name 'build' not found in project ':worldedit-libs:bukkit'
    
  • processResources: moved the fawe.properties expansion values into a block-local val, since a top-level val would capture the script object, which the configuration cache can't serialize.
  • configurations.all { } -> configurations.configureEach { }. Same resolutionStrategy, applied lazily instead of eagerly realizing every configuration in all 18 projects at configuration time.

Submitter Checklist

  • 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.

Copilot AI lite review requested due to automatic review settings August 10, 2026 02:04
@MattBDev
MattBDev requested a review from a team as a code owner August 10, 2026 02:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Gradle build logic to improve configuration-time performance and make the build compatible with Gradle’s configuration cache by removing legacy/eager configuration patterns and replacing Grgit-based Git metadata reads.

Changes:

  • Replaced Grgit usage with providers.exec Git CLI calls for revision/date metadata to support configuration cache.
  • Removed an overly broad compileJava dependency on :worldedit-libs:build and adjusted resource expansion inputs to be configuration-cache safe.
  • Switched eager configuration hooks (projectsEvaluated, configurations.all) to lazy equivalents (configureEach) to reduce configuration overhead.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
worldedit-core/build.gradle.kts Removes redundant task dependency and adjusts processResources expansion to avoid configuration-cache serialization issues.
gradle/libs.versions.toml Removes the Grgit version-catalog entry to drop the legacy dependency.
build.gradle.kts Replaces Grgit-based Git metadata with providers.exec to support configuration cache and reduce configuration-time work.
build-logic/src/main/kotlin/buildlogic.common.gradle.kts Makes resolution strategy configuration lazy by using configurations.configureEach.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread gradle/libs.versions.toml
Comment on lines 53 to 58
# Gradle plugins
pluginyml = "0.6.0"
mod-publish-plugin = "2.1.1"
grgit = "5.3.3"
shadow = "9.5.1"
paperweight = "2.0.0-SNAPSHOT"
codecov = "0.3.0"
…pport

Replace Grgit/JGit with providers.exec for git metadata so the build no longer forks external processes at configuration time. Fix a Project-capturing closure in worldedit-core's fawe.properties expansion. Together these bring the configuration cache from 3 problems to 0.

Also remove a dependsOn(":worldedit-libs:build") in worldedit-core that pulled in the full build/check/sourcesJar/javadocJar lifecycle of two lib projects (bukkit, cli) it doesn't use -- 27 tasks reduced to 4 for :worldedit-core:compileJava -- and drop a redundant projectsEvaluated wrapper around an already-lazy configureEach block.

Verified: 0 configuration-cache problems (was 3); jar artifacts byte-for-byte identical (7560 entries compared) before/after and with the cache on/off; 197 tests passing; version stamp format unchanged.
Copilot AI review requested due to automatic review settings August 10, 2026 02:16
@MattBDev
MattBDev force-pushed the gradle-optimizations branch from 44cd581 to b34a18f Compare August 10, 2026 02:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.

@MattBDev
MattBDev enabled auto-merge (squash) August 11, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants