Safeguard
Developer Tools•

Should Gradle be allowed to auto-download a JDK for my build?

Gradle toolchains can download a JDK if a resolver plugin is set up. On CI, pre-install approved JDKs and turn auto-download off so the source is known.

Safeguard Security Team
3 min read

For CI and release builds, no: install approved JDKs yourself and turn auto-download off, so you know exactly which compiler and runtime built your software. For developer laptops it is a convenience that needs a deliberate resolver choice. Gradle only downloads when a toolchain repository is configured, and its docs describe no integrity check of the download.

How auto-provisioning works

Per Gradle's toolchain documentation, if no matching local JDK exists, Gradle can download one, but only when a toolchain download repository is configured. Repository definitions come from settings plugins. The example in the docs is the Foojay Toolchains Plugin, which uses the foojay Disco API. Gradle installs downloaded JDKs in the Gradle user home, and only downloads GA releases.

Two details matter for planning. Provisioned JDKs are never revisited and automatically updated by auto-provisioning, so they can age. And Gradle downloads from the first repository in the list that provides a match.

Why it is a supply chain choice

The JDK compiles your code and runs your tests. It is as central as any dependency. A settings plugin that decides where JDKs come from is itself a dependency of the build, which is why it belongs in your plugin review.

The page we read does not describe checksum or signature verification for downloaded JDKs, so do not assume one. It does say installations that are missing a bin/java executable are ignored with a warning.

Choosing a policy

EnvironmentSuggested policyWhy
Release CIAuto-download off, JDK baked into a reviewed imageKnown compiler source
General CIOff, or on with an internal resolverRepeatability
Developer machineOn, with a resolver you choseConvenience
Air gappedOffNo network

Steps

  1. Decide which JDK vendor and version your release builds use, and record it.
  2. Install it in the CI image from a source you verify.
  3. Set the org.gradle.java.installations.auto-download property to false, in gradle.properties or with a system property. The docs say to make sure the JDK is installed first, then stop the daemon.
  4. If you allow auto-download, review the resolver plugin and its version like any other plugin.
  5. Record the JDK in your build metadata or SBOM so you can answer which JDK built a release.
  6. Revisit provisioned JDKs on a schedule, since Gradle will not update them.

What to record for later questions

Customers and auditors increasingly ask what built the product. Capture the JDK vendor, version and source, plus the Gradle version and plugin versions, alongside the artifact. See signature, provenance and SBOM attestation for how those records relate.

Try it yourself

Click through it at your own pace, or open it full screen.

See how one control maps to several frameworks. Build environment records are a common evidence request.

Safeguard's compliance and evidence automation helps collect records like these, and the free scan at gold.safeguard.sh/scan covers dependencies.

Quick check

Does Gradle download a JDK by default?

Only if a toolchain download repository is configured through a settings plugin, according to the Gradle docs.

Are downloaded JDKs updated automatically?

No. The docs say auto-provisioned JDKs are never revisited and updated by auto-provisioning.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.