Skip to content

Add Gradle Configuration Cache Support#272

Merged
tnj merged 13 commits into
masterfrom
feat/support-configuration-cache
Jun 11, 2026
Merged

Add Gradle Configuration Cache Support#272
tnj merged 13 commits into
masterfrom
feat/support-configuration-cache

Conversation

@tnj

@tnj tnj commented Jul 9, 2025

Copy link
Copy Markdown
Member

This fixes #148 and #270

This PR adds full support for Gradle's configuration cache feature to the DeployGate plugin, enabling faster builds through cached configuration reuse.

Changes

  • Enhanced BuildService Parameters: Extended the existing HttpClient BuildService to receive AGP version and plugin
    version through parameters instead of static access, eliminating configuration-time reads
  • Provider API Migration: Converted all environment variable and system property access to use Gradle's Provider API
    with proper forUseAtConfigurationTime() handling for Gradle 6.x compatibility
  • Static State Elimination: Removed static AGP version caching in AndroidGradlePlugin and updated BrowserUtils to
    accept Provider parameters instead of direct system access
  • Task Configuration: Updated all tasks to use Provider chains for extension values and added missing @Input/@Output
    annotations for proper serialization
  • Environment Handling: Deferred all environment checks (browser detection, file system operations) to task execution
    time using Provider mapping

Testing

  • Added comprehensive ConfigurationCacheSpec test suite verifying all plugin functionality
  • Added BrowserUtilsConfigurationCacheSpec for environment handling tests

tnj and others added 6 commits July 2, 2025 16:51
Implement full Configuration Cache compatibility for the DeployGate plugin
to improve build performance and enable caching of task configuration.

Changes:
- Add endpoint property to upload tasks to eliminate project access during execution
- Replace @internal with @nested annotations for proper input tracking
- Use Gradle logging instead of System.out for Configuration Cache compliance
- Defer file operations from configuration to execution time
- Add endpoint configuration to DeployGateExtension with default value
- Update task configuration to capture endpoint for browser opening

This enables faster incremental builds and better build reproducibility
when using Gradle's Configuration Cache feature.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace direct project.deploygate access with Provider API
- Remove static state from GradleCompat and use provider-based approach
- Pass AGP version through BuildService parameters instead of static
access
- Replace Config.shouldOpenAppDetailAfterUpload() with Provider-based
approach
- Add proper @Input/@output annotations to task properties
- Fix eager property access in task getDescription() methods
- Maintain backward compatibility with Gradle 6.7.1+
- Preserve variant name display in task descriptions

BREAKING CHANGE: None - all changes maintain backward compatibility

🤖 Generated with [Claude Code](https://claude.ai/code)

  Co-Authored-By: Claude <noreply@anthropic.com>
- Updated PackageAppTaskCompat to accept AGP version as a parameter for APK and AAB info retrieval.
- Modified AndroidGradlePlugin to remove static AGP version caching and introduced version string parameterization.
- Enhanced HttpClient to include plugin version details in HTTP headers.
- Refactored BrowserUtils to support configuration cache with ProviderFactory, ensuring environment checks are deferred.
- Improved LoginTask and UploadArtifactTask to utilize ProviderFactory for browser opening logic.
- Added ConfigurationCacheSpec to validate plugin compatibility with Gradle's configuration cache feature.
- Created TestHelper and TaskTestHelper classes to streamline test setup and reduce boilerplate code.
- Implemented BrowserUtilsConfigurationCacheSpec to ensure provider-based methods work correctly without direct system access.
- Updated UploadArtifactTaskSpec to utilize new input parameter handling and provider factory integration.
- Add missing @input and @InputFile annotations to AabInfo and ApkInfo interfaces
- Fix BrowserUtils to use forUseAtConfigurationTime() wrapper for Provider access
- Add release build type configuration to ConfigurationCacheSpec tests
- Prevent browser from actually opening during BrowserUtilsConfigurationCacheSpec tests

All tests now pass successfully with configuration cache enabled.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix BrowserUtilsSpec to mock hasBrowserLegacy instead of hasBrowser
  The openBrowser(String) method delegates to legacy implementation
- Fix BrowserUtilsConfigurationCacheSpec provider chain test
  Use mock providers instead of actual environment access to avoid
  configuration time provider evaluation issues

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@tnj tnj linked an issue Jul 9, 2025 that may be closed by this pull request
tnj and others added 3 commits July 9, 2025 17:07
- Fix BrowserUtilsSpec test by mocking CI environment check
- Update BrowserUtilsConfigurationCacheSpec to use parameterized tests with mock providers
- Fix UploadArtifactTask to remove extra .get() call on Boolean value

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
}
}

static boolean shouldOpenAppDetailAfterUpload() {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Replaced with openBrowserAfterUpload property in UploadArtifactTask

isInternalSigningConfigData / hasOutputsHandlerApiOnPackageApplication
compared major and minor independently (major >= 8 && minor >= N), which
breaks once AGP's major version increments. For example AGP 9.x reports a
minor < 3, so it incorrectly took the legacy signingConfigData / variantOutputs
code paths that no longer exist on modern PackageAndroidArtifact. Use
VersionString's semantic comparison (>= 8.3.0 / >= 8.1.0) instead.

Add a unit test that locks in the major-version-bump behavior (AGP 9.x/10.x),
and extend the acceptance test matrix up to AGP 8.13.0 with their minimum
Gradle versions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tnj tnj marked this pull request as ready for review June 3, 2026 02:52
Copilot AI review requested due to automatic review settings June 3, 2026 02:52

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

…env parsing

- UploadArtifactTask: give `endpoint` (DEPLOYGATE_ROOT) and `openBrowserAfterUpload`
  (false) conventions so a task that isn't fully wired (manual creation, tests)
  does not throw at `endpoint.get()` — which the `revision == 1` branch can reach
  even when openBrowser is disabled.
- DeployGatePlugin: parse DEPLOYGATE_OPEN_BROWSER as common truthy tokens
  (1/true/yes/on). `String#toBoolean()` accepted only "true" (silently ignoring
  1/yes), and a plain non-empty check would wrongly enable it for "false".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@satsukies satsukies left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for working!
Please check my comments.

Comment thread src/main/groovy/com/deploygate/gradle/plugins/internal/gradle/GradleCompat.groovy Outdated
Comment thread src/test/groovy/com/deploygate/gradle/plugins/TestHelper.groovy Outdated
Comment thread src/test/groovy/com/deploygate/gradle/plugins/tasks/TaskTestHelper.groovy Outdated
Comment thread src/test/groovy/com/deploygate/gradle/plugins/tasks/TaskTestHelper.groovy Outdated
Comment thread src/main/groovy/com/deploygate/gradle/plugins/DeployGatePlugin.groovy Outdated
…st helpers

- GradleCompat.forUseAtConfigurationTime: restore the Gradle-version check
  (call only below 7.0) instead of try/catch, which invoked the
  deprecated-on-7.4+ method and emitted warnings on Gradle 7.x/8.x.
- Remove unused TestHelper and TaskTestHelper (no callers) and the dead
  TestHelper import in UploadArtifactTaskSpec.
- DEPLOYGATE_OPEN_BROWSER: preserve the original Groovy truthiness
  (any non-empty value enables it) instead of an allow-list, keeping the
  behavior unchanged.
- CHANGELOG: note configuration cache support.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

- Resolve the AGP version eagerly inside AndroidGradlePlugin.ifPresent (where
  AGP is guaranteed applied) and pass the plain String plus the buildDirectory
  Provider into createApkInfoProvider/createAabInfoProvider. The apkInfo/aabInfo
  task-input provider chains no longer capture the Project, fixing the latent
  configuration-cache violation on the variant artifact path.
- Make the implicit `deployment` in the variant configure blocks explicit as
  `task.deployment` to remove the confusing Groovy-delegate resolution. Behavior
  is unchanged (verified by the acceptance suite, incl. the skipAssemble cases).

Verified with the example app on Gradle 6.7.1 + AGP 4.2.0: the configuration
cache entry is stored and reused with no problems for the variant upload tasks.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

@tnj tnj requested a review from satsukies June 5, 2026 08:22

@satsukies satsukies left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for making some fixes. LGTM

Comment on lines +31 to +42
/**
* Handle forUseAtConfigurationTime compatibility.
*
* {@code Provider#forUseAtConfigurationTime()} is only required to read providers at
* configuration time on Gradle 6.x. It was deprecated in Gradle 7.4 (so calling it on 7.0+
* emits a deprecation warning) and removed in Gradle 9.0. We therefore only invoke it on
* Gradle below 7.0 and return the provider untouched otherwise.
*
* ref: https://github.com/gradle/gradle/issues/15600
*/
static <T> Provider<T> forUseAtConfigurationTime(Provider<T> provider) {
if (getVersion().major >= 7) {
// removed since 7.0 ref: https://github.com/gradle/gradle/issues/15600
if (GradleVersion.current().baseVersion >= GradleVersion.version("7.0")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice. The reason is clear in the block comments.

@tnj

tnj commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

Thanks, I'll merge it with #283

@tnj tnj merged commit f2439e1 into master Jun 11, 2026
29 checks passed
@tnj tnj deleted the feat/support-configuration-cache branch June 11, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuration Cache Incompatibility in DeployGate Gradle Plugin configuration-cache enabled builds are not supported yet

3 participants