Add dependency cache path overrides - #1175
Merged
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: dd650d36-9c97-4ca4-9ec8-39b37f99a07c
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new multiline cache-path input to let users override the dependency cache locations used by setup-java’s built-in caching for Maven/Gradle/sbt, while keeping existing defaults and cache-key behavior when the input is omitted.
Changes:
- Wire a new
cache-pathinput throughsetup-javainto the cache restore flow. - Persist resolved cache paths from restore to post-job save via action state so both phases cache the same locations.
- Add/extend unit + E2E coverage and document how to configure build tools to match the overridden cache paths.
Show a summary per file
| File | Description |
|---|---|
| src/setup-java.ts | Reads cache-path as multiline input and passes it to cache restore. |
| src/constants.ts | Defines the new INPUT_CACHE_PATH constant. |
| src/cache.ts | Adds cache path resolution + state persistence; uses resolved paths for restore/save. |
| README.md | Documents cache-path behavior and provides usage example(s). |
| action.yml | Declares the new cache-path input. |
| .github/workflows/e2e-cache.yml | Adds an E2E round-trip job validating a custom Maven repository cache path. |
| tests/setup-java.test.ts | Verifies orchestration passes cache-path through to cache.restore. |
| tests/cache.test.ts | Adds coverage for restoring/persisting/saving custom cache paths across package managers. |
| dist/setup/index.js | Updates the packaged action bundle for the setup entrypoint. |
| dist/cleanup/index.js | Updates the packaged action bundle for the post-job cleanup/save entrypoint. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 8/10 changed files
- Comments generated: 2
- Review effort level: Low
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: dd650d36-9c97-4ca4-9ec8-39b37f99a07c
Align the custom cache save and restore key inputs and use the workflow hash to avoid a previously populated cache entry. Rebuild the distribution bundles. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: dd650d36-9c97-4ca4-9ec8-39b37f99a07c
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.
Description:
Users can relocate Maven, Gradle, and sbt dependency caches, but setup-java's built-in caching previously used only hardcoded locations. This adds a multiline
cache-pathinput that replaces the selected package manager's main dependency paths while preserving existing defaults and cache-key computation when omitted.The resolved paths are persisted from restore to the post-job save so both phases use identical locations. Maven and Gradle wrapper caches remain independently managed at their existing paths. Unit tests cover all supported package managers, multiline exclusions, setup wiring, and restore/save consistency; the cache E2E workflow now verifies a custom Maven repository round trip. Documentation explains build-tool configuration, key behavior, and when to use
actions/cachedirectly.Related issue:
Fixes: #1173
Check list:
npm run checklocally (format, lint, build, test) and all checks pass.