Add Gradle cache to official pack pipeline#35049
Conversation
The cache-gradle.yml template was added to provision.yml in PR #35016, but the official build's Pack job uses pack.yml directly which never calls provision.yml. This caused the 10.0.60 official build to fail with 'Permission denied: getsockopt' when Gradle tried to download Maven dependencies on Windows agents with network isolation. Adding the same Gradle cache template to pack.yml ensures the cache is warm before the pack step invokes Gradle. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 35049Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35049" |
There was a problem hiding this comment.
Pull request overview
Adds Gradle dependency caching to the shared pack.yml pipeline template so official pack jobs warm/restore the Gradle cache before invoking the pack step (helping avoid transient Maven/Gradle network failures on Windows agents).
Changes:
- Invoke the existing shared
cache-gradle.ymltemplate fromeng/pipelines/common/pack.ymlbefore the pack build runs.
The Windows cache was empty (cache miss) because it had never been populated. With network isolation blocking repo.maven.apache.org, Windows builds can't download Gradle dependencies on first run. Since Gradle dependencies are platform-independent Java JARs, add a fallback restore key without Agent.OS so Windows can restore from the macOS-populated cache. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| "gradle" | "v1" | "$(Agent.OS)" | ||
| "gradle" | "v1" |
There was a problem hiding this comment.
Does this share the cache between all OSs? I don't know if their cache is cross-platform.
|
Replying to @jonathanpeppers' question on the cross-OS fallback key ( Short answer: The Gradle dependency cache is mostly cross-platform, but not entirely. The fallback is a best-effort warm start, not a guaranteed full restore. What works cross-OS:
What doesn't work cross-OS:
Net effect: The cross-OS fallback gives Windows a warm start with ~95% of the dependencies pre-cached (all the pure Java artifacts). OS-specific artifacts (aapt2) would still need to be resolved. This is strictly better than a complete cache miss, and Gradle handles the incompatible entries gracefully (cache miss → regenerate, not crash). That said — in practice, this build currently only has a Pack macOS job (no Pack Windows), so the cross-OS fallback isn't actually being exercised today. If a Windows Pack job is added in the future and CFSClean is still blocking Maven Central, the fallback alone won't be sufficient (aapt2 download would still fail). A Windows-specific cache would need to be populated separately, or aapt2's Maven domain would need to be allowlisted. Happy to remove the cross-OS key if you think the partial-restore behavior is more confusing than helpful. The OS-specific keys ( Cross-checked with Sonnet 4.6, Codex 5.3, and Opus 4.6 — all agree the dependency artifacts are portable but OS-specific binaries (aapt2) are not. Gradle self-heals on incompatible cache entries rather than crashing. |
| # Cache Gradle downloads to avoid transient network failures during Android binding builds | ||
| - template: /eng/pipelines/common/cache-gradle.yml@self | ||
| parameters: | ||
| checkoutDirectory: ${{ parameters.checkoutDirectory }} |
There was a problem hiding this comment.
The general idea of restoring the cache here would improve this pipeline, for sure.
The OS-independent fallback key could restore macOS-cached aapt2 native binaries on Windows, which are not cross-platform compatible. Keep only OS-specific restore keys. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/backport to main |
|
Started backporting to |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Problem
The official build (
dotnet-maui, definition 1095) forrelease/10.0.1xx-sr6has been failing with Gradle network errors on Windows:Build 2954057 failed even though it included the Gradle cache fix from PR #35016. The cache step was added to
provision.yml, but the official Pack job usespack.ymldirectly — which never callsprovision.yml.Fix
Add the same
cache-gradle.ymltemplate call toeng/pipelines/common/pack.ymlbefore the pack step, matching the pattern already used inprovision.yml.Impact
This unblocks the 10.0.60 official build by ensuring the Gradle dependency cache is warm before the Pack step invokes Gradle on Windows agents with network isolation.