跪拜 Guibai
← All articles
Android · Gradle

Gradle 9.6.0 Stops Invalidating Configuration Cache for CI-Only Parameters

By 黄林晴 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

For Android teams running CI pipelines with per-build parameters, this fix directly reduces build times by preserving configuration cache hits. It also signals Gradle's tightening of implicit cross-project dependencies, which will force cleanup of fragile Groovy DSL patterns before Gradle 10.

Summary

Gradle 9.6.0 ships a targeted fix for a common CI headache: configuration cache invalidation caused by project properties that are never read during the configuration phase. In older versions, passing parameters like build numbers, channel IDs, or feature flags via `-Dorg.gradle.project.*` or `ORG_GRADLE_PROJECT_*` would force a cache recomputation even if those values were only consumed inside task actions. The new release detects whether a property actually participates in configuration and skips cache invalidation if it doesn't.

Beyond the cache fix, the release adds `--non-interactive` to prevent builds from hanging on prompts in headless CI environments, and `NO_COLOR` support to strip ANSI codes from logs. Test HTML reports now have sortable columns. A significant deprecation targets implicit parent-project property lookups in subprojects — a pattern common in older Android multi-module setups — with full removal planned for Gradle 10. The upgrade path is the standard wrapper update, requiring JVM 17–26 and compatible with AGP 9.0 through 9.3.0-alpha06.

Takeaways
Gradle 9.6.0 no longer invalidates the configuration cache when a project property changes, provided that property is only read during the task execution phase.
CI parameters like build numbers, channel IDs, and feature flags — typically passed via `-Dorg.gradle.project.*` or `ORG_GRADLE_PROJECT_*` — benefit most from this fix.
The new `--non-interactive` flag prevents Gradle from waiting for user input in automated CI pipelines.
Setting the `NO_COLOR` environment variable disables color output, keeping CI logs clean of control characters.
Test HTML reports now have sortable columns: numeric columns default to descending, success rate defaults to ascending.
Implicit lookup of parent project properties from subprojects is deprecated in 9.6.0 and will be removed in Gradle 10.
Shared configuration should be moved to `gradle.properties` or convention plugins instead of relying on root project `ext` blocks.
Upgrade via `./gradlew :wrapper --gradle-version=9.6.0`; requires JVM 17–26 and is tested with AGP 9.0–9.3.0-alpha06.
Conclusions

The configuration cache fix is narrowly scoped — it only helps when properties are truly unused during configuration. Custom tasks or plugins that read environment variables or perform I/O in the configuration phase will still break caching.

The deprecation of implicit parent-project lookups is the more disruptive change for established Android projects. Many teams have years of accumulated Groovy DSL scripts that rely on this behavior, and the migration window is now open.

The `--non-interactive` flag addresses a silent CI failure mode that is notoriously hard to debug — a build that hangs waiting for input with no obvious error in logs.

Concepts & terms
Configuration Cache
A Gradle feature that caches the result of the build configuration phase (task graph construction) so that subsequent builds can skip re-evaluating build scripts if inputs haven't changed. It significantly speeds up repeated builds.
Implicit Parent-Project Lookup
In Gradle's Groovy DSL, a subproject can access properties and methods defined in the root project without an explicit reference. Gradle 9.6.0 deprecates this behavior, requiring shared configuration to be declared explicitly.
Convention Plugin
A Gradle plugin that encapsulates shared build logic (e.g., common Android SDK versions, Kotlin compiler options) so that multiple subprojects can apply it consistently without duplicating configuration or relying on implicit parent-project properties.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗