Skip to content

sbt Build Cache

Avrea provides a remote cache for sbt 2. Task results such as compilation are cached, so a build with unchanged inputs restores them instead of running the tasks again.

Requires sbt 2.1.0 or newer. For dependency downloads, see Maven / Gradle Packages.

The cache location is pre-configured. Add sbt's remote cache plugin to your project to use it:

project/plugins.sbt
addRemoteCachePlugin

That line is all your repository needs. Outside Avrea runners no cache location is set, so the plugin does nothing there.

If your job sets SBT_CONFIG_HOME or, on Linux and macOS, its own XDG_CONFIG_HOME, sbt reads its global settings from that location instead of the one Avrea provides. Add a settings file to the 2 subdirectory of the sbt directory your job uses, for example $SBT_CONFIG_HOME/2/avrea-remote-cache.sbt:

avrea-remote-cache.sbt
Global / remoteCache := Some(uri("http://cache.avrea.com:8290/sbt-build"))

Your workflow needs no changes:

workflow.yml
jobs:
build:
runs-on: avrea-ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '21'
- uses: sbt/setup-sbt@v1
- run: sbt test

sbt reports cache use at the end of each command:

[success] elapsed time: 0 s, cache 100%, 1 disk cache hit, 2 remote cache hits

If your build sets Global / remoteCache itself, Avrea leaves it alone and your cache is used.

To turn the Avrea sbt cache off for a repository, see Managing caches.