Skip to content

Add dependency cache path overrides - #1175

Merged
brunoborges merged 3 commits into
mainfrom
brunoborges-allow-dependency-cache-paths
Jul 29, 2026
Merged

Add dependency cache path overrides#1175
brunoborges merged 3 commits into
mainfrom
brunoborges-allow-dependency-cache-paths

Conversation

@brunoborges

Copy link
Copy Markdown
Contributor

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-path input 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/cache directly.

Related issue:
Fixes: #1173

Check list:

  • Ran npm run check locally (format, lint, build, test) and all checks pass.
  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: dd650d36-9c97-4ca4-9ec8-39b37f99a07c
Copilot AI review requested due to automatic review settings July 29, 2026 18:28
@brunoborges
brunoborges requested a review from a team as a code owner July 29, 2026 18:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-path input through setup-java into 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

Comment thread README.md
Comment thread src/cache.ts Outdated
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
@brunoborges
brunoborges merged commit 0b56831 into main Jul 29, 2026
88 checks passed
@brunoborges
brunoborges deleted the brunoborges-allow-dependency-cache-paths branch July 29, 2026 18:43
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.

Allow overriding dependency cache paths

2 participants