Skip to content

feat[oss-licenses]: Add full Gradle Configuration Cache support#365

Merged
timothyfroehlich merged 12 commits intogoogle:mainfrom
timothyfroehlich:froeht/config-cache
Mar 3, 2026
Merged

feat[oss-licenses]: Add full Gradle Configuration Cache support#365
timothyfroehlich merged 12 commits intogoogle:mainfrom
timothyfroehlich:froeht/config-cache

Conversation

@timothyfroehlich
Copy link
Member

@timothyfroehlich timothyfroehlich commented Mar 3, 2026

Description

This PR introduces full support for Gradle's Configuration Cache to the oss-licenses-plugin, allowing for significant build speed improvements in subsequent runs.

Key Architectural Changes

  1. Unified Lazy Dependency Resolution:

    • Rewrote DependencyUtil.groovy to perform artifact resolution during the configuration phase instead of the execution phase.
    • Replicated internal Android Gradle Plugin (AGP) logic using ArtifactView and ArtifactResolutionQuery against the variant's runtimeConfiguration.
    • Consolidated the resolution of physical library files (JAR/AAR) and POM metadata into a single lazy Provider.
    • Injected these mappings into LicensesTask via a new @Input property (MapProperty<String, ArtifactFiles> artifactFiles), ensuring the task remains a pure, cacheable function.
  2. Test Infrastructure & Parallelization:

    • Improved Parallelism: Refactored EndToEndTest.kt to remove the previous @Parameterized setup. The tests are now "unrolled" into concrete subclasses, allowing Gradle to execute them in parallel, significantly reducing CI time.
    • Fixed Script Capture: Resolved an issue in build.gradle.kts where the test task's doFirst closure was capturing the Gradle script object, which blocked configuration caching.
    • New Regression Suite: Added DependencyResolutionTest.java to programmatically verify that the resolution engine correctly handles version conflicts, transitives, and scoped dependencies.
    • Absent Report Handling: Added testAbsentDependencyReport to verify correct fallback behavior on debug variants where the AGP dependency report is absent.
  3. Version & Tooling:

    • Bumped version to 0.11.0 for release.
    • Updated AGP to 9.0.1 and Gradle Wrapper to 9.3.1.
    • Maintained Java 17 toolchain parity while ensuring compatibility with legacy Gradle versions (down to 7.5).

Related Changes

  • Preserved 100% behavioral parity with existing license text parsing and deduplication logic.
  • Added ArtifactFiles.groovy data class.
  • Suppressed legacy Protobuf security warnings caused by AGP dependencies.

* Update Android Gradle Plugin to 9.0.1
* Update Gradle Wrapper to 9.3.1
* Update Kotlin plugin to 2.3.10
* Update Protobuf, Guava, Truth, and Gson
* Bump version to 0.10.11-SNAPSHOT
* Remove `markNotCompatibleWithConfigurationCache` from `OssLicensesPlugin`
* Add `testConfigurationCache` to `EndToEndTest` to verify cache reuse
* Suppress Protobuf security warnings in `gradle.properties` caused by AGP dependencies
* Refactor `DependencyUtil` to resolve artifacts using `ArtifactView` and `ArtifactResolutionQuery` instead of accessing `ResolvedConfiguration` directly.
* Pass resolved artifacts as inputs to `LicensesTask` via a new `artifactFiles` property to avoid project access during execution.
* Add `ArtifactFiles` data class to hold resolved POM and library files.
* Update `OssLicensesPlugin` to provide lazy artifact resolution.
* Update `EndToEndTest` to verify configuration cache compatibility.
@timothyfroehlich timothyfroehlich changed the title feat: Add full Gradle Configuration Cache support feat[oss-licences]: Add full Gradle Configuration Cache support Mar 3, 2026
@timothyfroehlich timothyfroehlich changed the title feat[oss-licences]: Add full Gradle Configuration Cache support feat[oss-licenses]: Add full Gradle Configuration Cache support Mar 3, 2026
xyarco
xyarco previously approved these changes Mar 3, 2026
@timothyfroehlich timothyfroehlich requested a review from rlazo March 3, 2026 16:44
rlazo
rlazo previously approved these changes Mar 3, 2026
Copy link
Collaborator

@rlazo rlazo left a comment

Choose a reason for hiding this comment

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

Approved with nits

@timothyfroehlich timothyfroehlich dismissed stale reviews from rlazo and xyarco via 1aff4c7 March 3, 2026 19:46
This commit updates the copyright headers for all modified Google-owned
source files to include the 2026 year range, as per Google's open-source
policy. For files missing headers, the original publication year was
retrieved from Git history and used as the start of the range.
@timothyfroehlich timothyfroehlich merged commit dc6599f into google:main Mar 3, 2026
6 checks passed
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.

3 participants