Skip to content

Java

Java CI on GitHub Actions

Every build re-downloads the same Maven or Gradle dependencies.

120s → 4s
Dependency resolve
9m → 90s
Incremental build
91%
Cache hit rate

Every build re-downloads the same Maven or Gradle dependencies.

Why it happens

~/.m2 and ~/.gradle are empty on a fresh runner, and JVM startup plus annotation processing add fixed overhead per module.

What to change

  1. Cache ~/.m2/repository or ~/.gradle/caches keyed on the build files
  2. Enable the Gradle configuration cache and build cache
  3. Keep the Gradle daemon alive within a job rather than forking per module
  4. Give the JVM enough heap — GC thrash looks exactly like a slow build

Java on runnerhut

yaml
jobs:
build:
runs-on: runnerhut-8vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with: { java-version: '21', distribution: temurin, cache: gradle }
- run: ./gradlew build --build-cache --configuration-cache
A working starting point

The only runnerhut-specific line is `runs-on: runnerhut-8vcpu-ubuntu-2404`. Everything else is standard GitHub Actions — the same actions, the same secrets and the same permissions model you use today.

Your next build could be twice as fast, at half the price

Start free. Migrating away is the same one line, and we publish that diff too.