Description:
Add an optional multiline cache-path input that overrides the main dependency cache paths for the package manager selected by cache.
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '21'
cache: maven
cache-path: |
/custom/maven/repository
When omitted, the existing Maven, Gradle, and sbt defaults remain unchanged.
Proposed behavior:
cache-path accepts one or more newline-separated paths.
- Supplied paths replace the selected package manager's main dependency paths.
- The action does not configure the build tool; users must ensure it uses the same paths.
- Maven and Gradle wrapper caches remain independently managed.
- Restore and post-job save use identical resolved paths.
- Existing behavior and cache keys remain unchanged when the input is omitted.
- Paths and exclusion patterns supported by
actions/cache remain supported.
Examples:
# Gradle
with:
cache: gradle
cache-path: /custom/gradle-home/caches
env:
GRADLE_USER_HOME: /custom/gradle-home
# sbt
with:
cache: sbt
cache-path: |
/custom/ivy/cache
/custom/coursier/cache
Direct actions/cache usage should remain the documented option for advanced keying, fallback keys, and unusual cache topology.
Related: #680
Justification:
Maven, Gradle, and sbt all allow users to relocate their dependency caches. The built-in caching currently uses hardcoded locations, requiring affected users to disable it and reproduce setup-java's cache behavior with actions/cache.
Although cache-primary-key can be reused, it is only computed when built-in caching is enabled, which also performs an unnecessary restore against the default paths. A cache-path override preserves setup-java's simple caching experience for a standard build-tool configuration while keeping existing behavior fully backward compatible.
Acceptance criteria:
- Supports Maven, Gradle, and sbt.
- Supports multiline paths and exclusion patterns accepted by
actions/cache.
- Preserves existing defaults when omitted.
- Uses custom paths for both restore and save.
- Includes unit and end-to-end coverage.
- Documents when direct
actions/cache usage is preferable.
Are you willing to submit a PR?
Yes.
Description:
Add an optional multiline
cache-pathinput that overrides the main dependency cache paths for the package manager selected bycache.When omitted, the existing Maven, Gradle, and sbt defaults remain unchanged.
Proposed behavior:
cache-pathaccepts one or more newline-separated paths.actions/cacheremain supported.Examples:
Direct
actions/cacheusage should remain the documented option for advanced keying, fallback keys, and unusual cache topology.Related: #680
Justification:
Maven, Gradle, and sbt all allow users to relocate their dependency caches. The built-in caching currently uses hardcoded locations, requiring affected users to disable it and reproduce setup-java's cache behavior with
actions/cache.Although
cache-primary-keycan be reused, it is only computed when built-in caching is enabled, which also performs an unnecessary restore against the default paths. A cache-path override preserves setup-java's simple caching experience for a standard build-tool configuration while keeping existing behavior fully backward compatible.Acceptance criteria:
actions/cache.actions/cacheusage is preferable.Are you willing to submit a PR?
Yes.