Skip to content
Documentation

Docs / Adapter commands / Gradle

Gradle adapter

Keep Gradle's task cacheability and cache keys. The adapter supplies the shared HTTP build-cache endpoint and write policy.

Command
boringcache gradle
Protocol
Gradle HTTP build cache over /cache/*
Action
mode: gradle

How the adapter works

Gradle-native cache

The build still uses Gradle's cacheable task model and HTTP build-cache protocol.

Same workspace as other tools

A JVM repo can share Gradle cache, Docker cache, and dependency archives under one repo cache plan.

Read-only PRs

Run pull requests restore-only, then publish cache from trusted branches.

Set up Gradle

Keep the command and cache tag in .boringcache.toml, then use the same boringcache gradle entrypoint locally and in CI.

[adapters.gradle]
tag = "gradle-cache"
command = ["./gradlew", "build", "--no-daemon"]

# Run: boringcache gradle

Before the first run

  • Prefer the project's Gradle wrapper.
  • Keep cacheable task inputs deterministic across the jobs expected to share outputs.
  • Review existing Gradle user-home and build-cache settings before adding overrides.

Use the same adapter in GitHub Actions

The Action prepares Gradle's HTTP build-cache configuration for the later wrapper command and keeps your existing project settings in place.

.github/workflows/ci.yml
- uses: boringcache/one@1781572d7b3ec5aef652f8ba479b981439b2776b # v1.48.2
  with:
    trust-policy: auto
    mode: gradle

- run: ./gradlew build --no-daemon

Approve the repository through Connect CI and grant the job contents: read and id-token: write. The Action uses that Machine connection. Pull requests restore by default; trusted jobs may publish. See the authentication example in the GitHub Actions reference for scoped credentials when OIDC is unavailable.

GitHub Actions reference

Benchmarks

OpenTelemetry Java builds the same upstream commits with BoringCache, Bitrise Build Cache, Depot Cache and GHA Cache on the same runner classes.

OpenTelemetry Java

Gradle

Benchmark →

OpenTelemetry API and SDK for Java.

Average restore, build and save · lower is better

GitHub runner

4 vCPU · 16 GB · Ubuntu 24.04 x86-64

BoringCache
3 min 8 s 6 builds
Depot Cache
3 min 41 s 6 builds
GHA Cache
3 min 0 s 6 builds
Same CPU model

Builds of one commit can land on different CPU models. These ratios use only the build pairs where both caches ran on the same model; above 1.00× means BoringCache's total time over those pairs was lower.

Depot Cache vs BoringCache
1.26× · 1 of 6
GHA Cache vs BoringCache
0.95× · 2 of 6
5 CPU models recorded
BoringCache · Build cache
AMD EPYC 9V74 (2 builds) · AMD EPYC 7763 (1 build) · Intel Xeon Platinum 8370C (1 build) · Intel Xeon Platinum 8573C (1 build) · AMD EPYC 9V45 (1 build)
Depot Cache
AMD EPYC 7763 (4 builds) · Intel Xeon Platinum 8573C (1 build) · AMD EPYC 9V74 (1 build)
GHA Cache · Local cache directory restored and saved by actions/cache
AMD EPYC 9V74 (6 builds)
Cold and warm builds

Each table is one workflow run with one build per cache. A row marked Different CPU ran on another CPU model than BoringCache at the same level, so part of its time difference can come from the hardware.

One cold and warm build per cache
Cache Cold Warm CPU
BoringCache Build cache 12 min 22 s 2 min 8 s AMD EPYC 9V74
Depot Cache 16 min 0 s 2 min 36 s Cold: AMD EPYC 7763 · Warm: AMD EPYC 9V74 Different CPU
GHA Cache Local cache directory restored and saved by actions/cache 13 min 18 s 95.5 s AMD EPYC 9V45 Different CPU

Cache hits

BoringCache · GitHub runner · 4 vCPU

96.7% of 4,722 lookups over 6 builds

Served from the runner
Under 1 ms per read
Read from cache
255 MB

Tool reference

Check the tool's own reference when you need cache-key rules, build settings, or version-specific behavior.

All adapter commands

Compare every supported command, protocol, and Action mode in one place.

Adapter command index →

Need help or found something unclear? Open an issue or browse the CLI repo.