Opt the refreshVersions tasks out of the configuration cache#739
Open
sproctor wants to merge 1 commit into
Open
Opt the refreshVersions tasks out of the configuration cache#739sproctor wants to merge 1 commit into
sproctor wants to merge 1 commit into
Conversation
The `refreshVersions` and `refreshVersionsCleanup` tasks read state that is
initialized during the configuration phase (notably `OutputFile.rootDir`, set
in the plugin's `apply` block) from their task actions. When a configuration
cache entry is reused in a fresh daemon, the configuration phase is skipped, so
that state is never initialized and the task fails at execution with:
lateinit property rootDir has not been initialized
This matches the intermittent failure reported in Splitties#738: it only happens when an
existing configuration cache entry is reused.
These tasks were never meant to be configuration-cache compatible (they perform
network I/O and rewrite build files), and their siblings such as
`refreshVersionsMigrate` and `buildSrcLibs` already call
`skipConfigurationCache()`. This applies the same opt-out to the two tasks that
were missing it, so Gradle no longer stores or reuses an entry for them.
Also adds a Gradle TestKit functional test that verifies the tasks are reported
as incompatible with the configuration cache and that no entry is stored. The
functional test suite runs on Java 21 because TestKit launches the Gradle
version under test, which requires Java 17+.
Fixes Splitties#738
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
refreshVersionsintermittently fails with:The
refreshVersionsandrefreshVersionsCleanuptask actions read state that is initialized during the configuration phase — in particularOutputFile.rootDir, which is set from the plugin'sapplyblock viaOutputFile.init(project). When an existing configuration cache entry is reused, the configuration phase is skipped, so that state is never initialized and the task fails at execution time. This explains why the failure only shows up when the cache is reused (and is therefore intermittent), as reported in #738.Fix
These tasks were never intended to be compatible with the configuration cache: they perform network I/O and rewrite build files (
versions.properties, the version catalog, settings files). Their siblings already opt out viaskipConfigurationCache()— for examplerefreshVersionsMigrate,buildSrcLibs, andmigrateToRefreshVersionsDependenciesConstants. The two core tasks registered inRefreshVersionsCorePluginwere simply missing that call.This change adds
skipConfigurationCache()(which callsnotCompatibleWithConfigurationCache(...)) to bothrefreshVersionsandrefreshVersionsCleanup. Gradle then refuses to store an entry for builds that run them, so a stale entry can never be reused in a fresh process.Test
Adds a Gradle TestKit functional test (
ConfigurationCacheRegressionTest) that runsrefreshVersions --configuration-cacheagainst a fixture project and asserts the task is reported as incompatible with the configuration cache and that no entry is stored. It fails on the unpatched plugin (an entry is stored) and passes with the fix.The functional tests live in a dedicated
functionalTestsource set that runs on Java 21, because TestKit launches the Gradle version under test (9.x), which requires Java 17+, while the rest of the module compiles and unit-tests against Java 8.Fixes #738
🤖 Generated with Claude Code