Skip to content

Cache Gradle dependencies in the Docker build so CI stops hitting Maven Central rate limits - #16

Merged
op-techy merged 1 commit into
mainfrom
ci/gradle-cache
Dec 4, 2026
Merged

op-techy merged 1 commit into
mainfrom
ci/gradle-cache

Conversation

@op-techy

@op-techy op-techy commented Dec 3, 2026

Copy link
Copy Markdown
Owner

The CI Docker job failed twice with Received status code 429 from server: Too Many Requests from Maven Central (most recently on main after #15, fixed by a re-run).

Why

The test job already caches Gradle (setup-gradle). The Docker job didn't, in practice: the Dockerfile kept Gradle's downloads in a BuildKit cache mount, which the GitHub Actions layer cache (cache-to: type=gha) doesn't save, and the build layer was invalidated by any source change. So every CI run downloaded Gradle and every dependency again.

Change

  • build.gradle: a downloadDependencies task that resolves every configuration (downloads all jars, compiles nothing).
  • Dockerfile: runs it before copying src, so dependencies sit in their own layer that changes only when the build files change. CI's existing type=gha cache (mode=max) keeps that layer. The compile step then runs with --offline, which also proves nothing else is fetched.
  • README: Docker section describes the new caching.

The workflow file is unchanged.

Verified locally

  • Image builds; the --offline compile succeeds.
  • After editing a source file, the dependency layer is CACHED and only the ~15 s compile runs.
  • ./gradlew downloadDependencies test passes with no deprecation warnings.

The first CI run on this branch still downloads everything (filling the cache); runs after that reuse it until build.gradle changes.

CI's Docker job re-downloaded every dependency on each run: the BuildKit cache
mount isn't exported to the GitHub Actions layer cache, and the build layer is
invalidated by any source change. Twice that hit Maven Central's rate limit
(HTTP 429) and failed the build.

A new downloadDependencies task resolves every configuration; the Dockerfile
runs it before copying src, so the layer changes only with the build files and
is reused from the gha cache. The compile step then runs with --offline.
@op-techy
op-techy merged commit a793828 into main Dec 4, 2026
2 checks passed
@op-techy
op-techy deleted the ci/gradle-cache branch December 4, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant