From 049894a72af98be949df63d3e28616773b14edfa Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Wed, 5 Aug 2026 09:51:33 +0200 Subject: [PATCH] [MINOR] Persist the Maven build cache between CI runs .mvn/extensions.xml enables maven-build-cache-extension, but the cache never survives a CI run: actions/setup-java's `cache: maven` persists ~/.m2/repository only, while the extension writes to ~/.m2/build-cache. The effect is visible in any recent build log - ten modules, ten "Local build was not found by checksum" lines, zero restores - so every run rebuilds and retests all ten modules from scratch, including for pull requests that touch only the website or a single module. Restore ~/.m2/build-cache before the build and save it afterwards. Only main writes an entry; pull requests restore from main's rather than each branch consuming the repository-wide 10 GB cache budget. Source Build Check is deliberately left alone - it passes -Dmaven.build.cache.enabled=false and skips `cache: maven` on purpose, to prove the source release builds without prebuilt artifacts. --- .github/workflows/mvn-ci-build.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/mvn-ci-build.yml b/.github/workflows/mvn-ci-build.yml index 92e478940..eb5ae7bcb 100644 --- a/.github/workflows/mvn-ci-build.yml +++ b/.github/workflows/mvn-ci-build.yml @@ -43,5 +43,25 @@ jobs: distribution: 'temurin' cache: maven + # `cache: maven` above only persists ~/.m2/repository. The build cache + # extension configured in .mvn/extensions.xml writes to ~/.m2/build-cache, + # so without this it starts empty on every run and never restores a module. + # Only `main` writes an entry, so pull requests warm up from `main` instead + # of each branch filling the repository-wide cache budget. + - name: Restore Maven build cache + uses: actions/cache/restore@v6 + with: + path: ~/.m2/build-cache + key: maven-build-cache-${{ runner.os }}-${{ github.sha }} + restore-keys: | + maven-build-cache-${{ runner.os }}- + - name: Build all module with Maven run: ./mvnw clean install -ntp -B + + - name: Save Maven build cache + if: github.ref == 'refs/heads/main' && success() + uses: actions/cache/save@v6 + with: + path: ~/.m2/build-cache + key: maven-build-cache-${{ runner.os }}-${{ github.sha }}