You are reading documentation for 0.5.0. The latest release in the 0.5 line is 0.5.1.
The latest stable release is 0.8.4.
Getting Started
Gradle dependency metadata is cached by default in dependency-metadata. A standalone job owns
its complete snapshot automatically. On a cache miss, that partition starts empty.
For distributed jobs, select a metadata writer using the
same partition configuration in every job. Without a configured writer, the aggregator publishes its
own complete snapshot; ordinary workers’ metadata updates are omitted.
What this action does
This action speeds up JVM builds on CI by caching the build tool’s local artifact store between runs. On each run it:
- Restores the cache before the build so the build tool finds its dependencies already in place.
- Publishes a new complete immutable cache generation after a material change. Unchanged hits do not create duplicate entries.
Two job modes are available for both build tools:
- Single-job — one build job per workflow run. The action wraps that job and handles everything automatically.
- Distributed multi-job — multiple parallel build jobs. Each job uploads only the delta it produced; a dedicated aggregator job merges all deltas into the next cache entry so no job’s work is lost.
Gradle
For Gradle the action caches GRADLE_USER_HOME and additionally:
- Provisions any missing
gradle-wrapper.jarfiles, verifying each one with a SHA-256 checksum and a PGP signature before writing it to disk. See Security for details.
Maven
For Maven the action caches the Maven user home (~/.m2 by default, or the path set by
maven-user-home), including the local repository under repository/ and Maven Wrapper downloads
under wrapper/dists/. No wrapper provisioning is performed — Maven’s own bootstrap is handled by
the runner environment or actions/setup-java.
Build-output caching requires a separately configured Maven extension. See goal-level incremental caching for how it relates to Mammoth’s repository caching.
Workflow shape
For an existing workflow, first use Adoption and Migration to choose cache owners, preserve write restrictions and define a small pilot.
The examples below document the action contract. Pin an exact published release or candidate
ref containing the generated dist/ bundles, and place the action step before the first Gradle or
Maven invocation and before any step that populates the managed cache area. Ordinary source branches such as main omit those bundles and cannot be used as
installable action refs. Available candidates and final releases are listed on
GitHub Releases.
Leave dependency caching disabled in actions/setup-java and remove any other restore that
populates the same cache area. JDK installation and settings-only setup can run before Mammoth
when they leave the enabled partitions empty. Existing directories and settings outside those
partitions are allowed. Mammoth rejects existing managed files and preserves them. See
restore admission failures for dedicated-home examples.
Cache and same-run delta artifact operations use job-scoped Actions runtime credentials, so they do
not require actions: write. The examples grant only contents: read for checkout. See
Security for the full permissions boundary.
The action defaults to read-only on pull_request and pull_request_target events, so
cache writes from untrusted forks are automatically suppressed. Repository config can make this
policy stricter but cannot lower the pull-request floor; only a direct workflow input can do that.
Read-only jobs still restore base files and must meet the same prepare preconditions. Read-only
workers upload nothing, and read-only aggregators skip artifact exchange.
Gradle
1jobs:
2 build:
3 runs-on: ubuntu-latest
4 permissions:
5 contents: read
6 steps:
7 - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
8 - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654
9 with:
10 distribution: temurin
11 java-version: '21'
12 - uses: buildish-tooling/buildish-mammoth-cache/actions/github/gradle@<materialized-ref>
13 - run: ./gradlew build
Maven
1jobs:
2 build:
3 runs-on: ubuntu-latest
4 permissions:
5 contents: read
6 steps:
7 - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
8 - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654
9 with:
10 distribution: temurin
11 java-version: '21'
12 - uses: buildish-tooling/buildish-mammoth-cache/actions/github/maven@<materialized-ref>
13 - run: mvn verify
How it works
The action runs twice per job: a prepare step before the build and a finalize step after. Prepare records a cutoff after restore; finalize observes metadata after the build. Workers exchange assumed changed files and usage paths; eligible writers save complete generations when required. Filesystem and clock behavior make activity detection best-effort.
sequenceDiagram
participant P as prepare
participant B as Your build steps
participant F as finalize
P->>P: restore cache
note over P: Gradle only: provision gradle-wrapper.jar
P->>P: record activity cutoff
P-->>B: hand off
B->>B: build runs …
B-->>F: job post step
F->>F: scan metadata before own reads
F->>F: freeze upsert, used and GC decisions
F->>F: publish complete generation if required
For distributed multi-job builds, worker jobs upload their delta as a workflow artifact instead of saving the cache directly. An aggregator job then merges all worker deltas into a single cache entry. See Distributed multi-job for details.