Skip to content

build: download the Gradle wrapper from Gradle's GitHub releases - #195

Merged
trendvidia merged 3 commits into
mainfrom
build/gradle-github-mirror
Nov 8, 2026
Merged

trendvidia merged 3 commits into
mainfrom
build/gradle-github-mirror

Conversation

@bfrancojr

Copy link
Copy Markdown
Collaborator

CI could not build this repo whenever services.gradle.org was down. The wrapper downloads Gradle from there with a 10-second timeout and no retries. On 2026-11-08 that host returned 504 for minutes at a time, so every job that builds protowire-java failed before compiling anything. That includes protowire's cross-port security gate, which then blocked an unrelated PR (trendvidia/protowire#591; see trendvidia/protowire#592).

This PR points the wrapper at Gradle's own copy of the same file on GitHub (the gradle/gradle-distributions releases), which is where CI runs. It also adds distributionSha256Sum, so the wrapper refuses any file but Gradle's.

Advances trendvidia/protowire#592 by a different route. That issue asked for a cache; this removes the download from services.gradle.org instead.

Evidence

  • Same file. The GitHub copy is 151,620,138 bytes with SHA-256 21bd5da2…e389607. That equals Gradle's published gradle-9.8.2-bin.zip.sha256.
  • Downloads from GitHub. With an empty GRADLE_USER_HOME, ./gradlew --version printed Downloading https://github.com/gradle/gradle-distributions/releases/download/v9.8.2/gradle-9.8.2-bin.zip, then Gradle 9.8.2.
  • The gate's build passes. ./gradlew --quiet :check-decode:installDist exits 0 and produces check-decode/build/install/check-decode/bin/check-decode.
  • The checksum is enforced. With its first byte changed, the wrapper exits 1 with Expected checksum: '00bd5da2…' / Actual checksum: '21bd5da2…'.

Watch on the next Gradle upgrade

Dependabot updates this file (#132 changed only the version inside the URL). How it treats a GitHub URL I can't test until the next Gradle release. There are two ways it could go wrong:

  • It bumps the version but leaves the old checksum. The wrapper then fails loudly on the checksum, as shown above.
  • It rewrites the URL back to services.gradle.org. That one is quiet: the download goes back to the old host.

So review the next wrapper bump for the host and the checksum. Not in the changelog, since nothing a user of the library sees changes.

The wrapper fetched gradle-9.8.2-bin.zip from services.gradle.org, with
a 10 s timeout and no retries. On 2026-11-08 that host returned 504 for
minutes at a time, and every CI job that builds this repo failed before
compiling anything, protowire's cross-port security gate included
(trendvidia/protowire#592).

Gradle publishes the same files as releases of gradle/gradle-distributions
on GitHub, which is where CI runs. distributionSha256Sum pins the file
to the checksum Gradle publishes, so the wrapper refuses anything else.
@bfrancojr

Copy link
Copy Markdown
Collaborator Author

Also: publish.yml and codeql.yml run the same wrapper, so the release and CodeQL jobs download from GitHub too after this.

@bfrancojr

Copy link
Copy Markdown
Collaborator Author

CI result: the GitHub download works, but it is not reliable on its own. Every job downloaded from github.com/gradle/gradle-distributions as intended (the log shows Downloading https://github.com/gradle/gradle-distributions/...). Across this PR and its twin (protowire-java#195 / protowire-kotlin#28), 3 of the 6 downloads then failed with Read timed out, after the wrapper's networkTimeout=10000. There are no retries, since retries=0. The failures were the CodeQL job in both repos and Kotlin's ubuntu build. GitHub serves the file through a redirect to release-assets.githubusercontent.com, a CDN outside the runner's network. So a stalled read still kills the job. Not ready to merge as is.

With the download moved to GitHub's releases, 3 of 6 CI jobs still
failed: each stalled reading from release-assets.githubusercontent.com
and gave up at networkTimeout=10000 on its only attempt
("Attempt 1/1 failed ... Read timed out"). A stalled read is what a
longer timeout and a retry are for. Checked against an address that
never answers: the wrapper then reports "Attempt 1/4" to "Attempt 4/4".
The conformance job runs the cross-port gates, which build this repo
through ./gradlew, but set up no Gradle cache. So the wrapper downloaded
Gradle on every run, and the gate scripts print a build's output only
when it fails. That is where 'Downloading ... failed: timeout (10000ms)'
came from. The build job already caches it through setup-gradle, and on
main it restores gradle-wrapper-zips-v2-* and downloads nothing.
@bfrancojr

Copy link
Copy Markdown
Collaborator Author

CI is green at 070a16b, the commit with retries and the cache. Every Gradle download in this commit's runs came from https://github.com/gradle/gradle-distributions/..., none from services.gradle.org, and none needed a retry (no Attempt N/4 failed lines). These PR runs still download Gradle: the cached copy was saved under the old URL, and a PR can't write a new cache entry. The first run on main after merge saves it.

trendvidia added a commit to trendvidia/protowire that referenced this pull request Nov 8, 2026
* ci: cache the Gradle distribution in the cross-port gates

The security, text, write and envelope gates build protowire-java
through its wrapper but set up Java without any Gradle cache, so each
run downloaded Gradle from services.gradle.org. On 2026-11-08 that host
returned 504 for minutes at a time, and the security gate failed three
times before it reached the corpus (run 42440559767, attempts 2-4).
setup-gradle caches the distribution, as protowire-java's own CI
already does.

* ci: cache the Gradle distribution in CodeQL's java-kotlin job

The job builds the JetBrains plugin through its wrapper without a Gradle
cache, so it downloaded Gradle on every run. editors-jetbrains.yml
already caches it with setup-gradle. The plugin turns on the build
cache, so the compile CodeQL traces now passes --no-build-cache: classes
restored from the cache are never compiled, and CodeQL would find no
code to analyse (protowire-java's codeql.yml hit the same thing).

* editors/jetbrains: download Gradle from GitHub, wait 60 s and retry 3 times

Same change as trendvidia/protowire-java#195 and
trendvidia/protowire-kotlin#28. The wrapper fetched Gradle from
services.gradle.org with a 10 s timeout and no retries. It now fetches
Gradle's own copy from the gradle/gradle-distributions releases on
GitHub, pinned by distributionSha256Sum to the checksum Gradle
publishes, and retries a stalled download.

---------

Co-authored-by: TrendVidia <coder@trendvidia.com>
@trendvidia
trendvidia merged commit 4d7c7f9 into main Nov 8, 2026
4 checks passed
@trendvidia
trendvidia deleted the build/gradle-github-mirror branch November 8, 2026 12:55
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.

2 participants