Skip to content
Documentation

Docs / Adapter commands / sbt 2

sbt 2 adapter

Reuse sbt 2 build results through a shared REAPI cache while the tool keeps control of task identities and local execution.

Command
boringcache sbt
Protocol
REAPI gRPC action cache and content-addressable store; cache only
Action
mode: sbt

How the adapter works

Native client configuration

Use sbt 2 and addRemoteCachePlugin in project/plugins.sbt. sbt 1 uses a different remote-cache protocol. Optional global-base selects the global settings directory and must not contain whitespace. Native relative paths use the repo-plan directory and Docker requires an absolute container path. The native adapter preserves other SBT_OPTS and the global base used for plugins. It copies existing global .sbt settings into a private directory, adds cache settings there, and uses a private server directory. Each invocation has its own settings snapshot; setup and cleanup leave the original files unchanged. An existing -Dsbt.global.settings selects which settings to copy.

Shared cache lifecycle

The adapter selects the cache tag, starts a loopback REAPI endpoint, runs the client, and drains cache writes before shutdown. A cache miss runs the task locally.

Read and write policy

Read-only runs do not publish cache entries. Trusted writable runs may publish. Unknown or misplaced adapter options fail before cache startup.

Set up sbt 2

Commit this configuration and run boringcache sbt. Omit command when the Action should prepare caching for several later commands. Use sbt 2 and addRemoteCachePlugin in project/plugins.sbt. sbt 1 uses a different remote-cache protocol. Optional global-base selects the global settings directory and must not contain whitespace. Native relative paths use the repo-plan directory and Docker requires an absolute container path. The native adapter preserves other SBT_OPTS and the global base used for plugins. It copies existing global .sbt settings into a private directory, adds cache settings there, and uses a private server directory. Each invocation has its own settings snapshot; setup and cleanup leave the original files unchanged. An existing -Dsbt.global.settings selects which settings to copy.

workspace = "my-org/my-project"

[adapters.sbt]
tag = "sbt-build"
command = ["sbt", "compile"]

Before the first run

  • Install the project's sbt 2 version before running the adapter.
  • Review boringcache sbt --dry-run --json before the first build.
  • Remote execution is not provided; use an empty REAPI instance name.

Building inside Docker? Follow the Docker REAPI tool-cache setup to select this tool, its cache tag, and its read/write policy.

Use the same adapter in GitHub Actions

A committed adapter command runs in this Action step. Without one, the Action prepares caching for later tool commands and removes its temporary configuration after stopping the client and cache service.

.github/workflows/ci.yml
- uses: boringcache/one@6b680206950cc926444c045302370653fae538f1 # v1.50.0
  with:
    trust-policy: auto
    mode: sbt

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

Lichess and Play Framework build the same upstream commits with BoringCache and GHA Cache on the same runner classes.

Lichess

sbt

Benchmark →

Online chess server written in Scala.

Average restore, build and save · lower is better

GitHub runner

4 vCPU · 16 GB · Ubuntu 24.04 x86-64

BoringCache
1 min 58 s 9 builds
GHA Cache
4 min 56 s 9 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.

GHA Cache vs BoringCache
1.75× · 3 of 9
4 CPU models recorded
BoringCache · Remote cache
AMD EPYC 7763 (5 builds) · AMD EPYC 9V45 (2 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 7763 (4 builds) · AMD EPYC 9V74 (2 builds) · Intel Xeon Platinum 8573C (2 builds) · AMD EPYC 9V45 (1 build)

Cache hits

BoringCache · GitHub runner · 4 vCPU

99.7% of 44,895 lookups over 9 builds

Served from the runner
Under 1 ms per read
Read from cache
958 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.