Infrastructure worth keeping — and kept patched.

What does the build cache store? Gradle and Maven

Knowing what Gradle and Maven put in the cache tells you what you are paying disk for. We ran real Gradle and Maven builds against FosterStack Cache and counted every entry.

The short answer

Gradle

Maven

What to do

Our advice, not a test result. Measure your own project before you pick a limit. The server's status page (/statusz) shows the entry count and the size in bytes. To see how it changes as you build, see is my build cache server healthy, and what to alert on. To pick a size limit, see how big a server does a build cache need and how the size limit works.

Gradle: what one build stored

What the 13 entries were (Mac run)

StoredEntries
:core:compileJava1
:util:compileJava1
:api:compileJava1
:app:compileJava1
Kotlin build script compilation, first stage5
Kotlin build script compilation, second stage4

These are the lines Gradle printed:

Stored cache entry for task ':core:compileJava' with cache key ...
Stored cache entry for Kotlin DSL script compilation (Project/TopLevel/stage1) with cache key ...
Stored cache entry for Kotlin DSL script compilation (Project/TopLevel/stage2) with cache key ...

What was not stored

These tasks ran and stored nothing: classes, jar, assemble and build for each of the four modules. In our other runs the jar tasks never printed FROM-CACHE either. In our builds you will see them run on every fresh checkout.

See it for your own build

Start from an empty cache, run your build once with -i, and count. We ran exactly this command, with the output saved, and it printed the same 13 entries:

gradle build -i | grep "Stored cache entry"

If your Gradle home has already compiled your build scripts, you will not see the script entries again: in a second run with the same Gradle home against a new empty server, only the 4 compileJava entries were stored, and the server held 4 entries and 11,425 bytes.

Size your Maven build cache: what it stores, in real numbers

Entries and bytes after each build

StepEntries on the serverBytes
Empty server00
After the first build (all three modules built)744,810
After a second build from a fresh copy (all three restored)846,128

The 7 entries from the first build

FileHow manyWhat it is
core.jar, util.jar, app.jar3The built jar of each module (5,028 to 5,340 bytes each)
buildinfo.xml3A record for each module that the next build looks up first (9,007 to 9,332 bytes each)
build-cache-report.xml1A report about the build run itself

The key is shortened to <key> here:

[INFO] Saved to remote cache http://127.0.0.1:18180//v1.1/demo/core/<key>/core.jar

What a restored build adds

The second build restored all three modules and built nothing, and it uploaded one file: build-cache-report.xml. So our fully restored build still added one entry, 1,318 bytes (46,128 minus 44,810). We saw two builds, so we cannot say whether every restored build does the same.

On the first build, against an empty server, Maven 3.10.0 also printed three [ERROR] Error downloading cache item ... buildinfo.xml lines (Maven 3.9.9 logs these misses as [INFO] Cache item not found). Those were ordinary misses on an empty cache, and the build succeeded; see enable or disable the Maven build cache extension.

What this means for sizing

In this tiny project the buildinfo.xml files were bigger than the jars: about 9 KB each against about 5 KB, and together 27,661 of the 44,810 bytes. We did not test how that balance changes with large jars.

We tried one small project with jars of a few kilobytes. We did not test large jars, many versions of the same module, or a project with test reports.

If you do not see what you expect

Look at why the hit rate is low and enable or disable the Gradle build cache. A task that stored nothing in your build, such as the jar tasks in ours, could not come from the cache.

See Maven build cache not restoring.

How we checked

Gradle. The four-module build from Gradle build cache for a monorepo: core, util, api and app, each with 12 small Java classes and a Kotlin build file. Our first run used a project folder that still held build output from an earlier check; we repeated it, with the same 13 entries, from a clean copy and got the same results. We started a new, empty server and ran gradle build --console=plain --no-daemon -i once, with the local cache off and a new, empty Gradle home. The -i flag makes Gradle print a line each time it stores something. The build ended with BUILD SUCCESSFUL. The project has no tests, so there are no test entries here; for those, see Gradle test task FROM-CACHE.

The server's status page then said: 13 entries, 36,054 bytes. When we repeated the run, the entry count was the same and the size varied by a few dozen bytes (36,054 to 36,103 across our runs).

Maven. The three-module project from Maven build cache extension in a multi-module project: core, util and app. We started a new, empty server and ran mvn verify twice, each time from a fresh copy of the project with an empty local build cache. Both builds ran on the same Mac and shared one already-filled local Maven repository, offline (-o -B, plus options for the repository and the local cache location). Both ended with BUILD SUCCESS. In our runs the extension printed one Saved to remote cache line for each entry that ended up on the server, and the server's status page (/statusz) gave the counts.

Run on Gradle 9.8.0 with FosterStack Cache 0.2.1, macOS (arm64), Java 27.

Run on Maven 3.10.0 with maven-build-cache-extension 1.2.3 and FosterStack Cache 0.2.1, macOS (arm64), Java 27 (Homebrew).

Second run: Linux, 0.2.2 (the Gradle half)

We ran the four-module Gradle build again on a GitHub-hosted Linux machine with FosterStack Cache 0.2.2, Gradle 9.8.0 and Java 21. We wrote the build files again, because they are not shown here, so the counts differ a little from the Mac run: 12 entries here, 13 there.

The Gradle half: the run and its log are public.

Second run: Linux, 0.2.2 (the Maven half)

The Maven runs above were on a Mac with 0.2.1. We ran the three-module build again on a GitHub-hosted Linux machine with FosterStack Cache 0.2.2, Maven 3.10.0 and Java 21.

The run and its log are public.