skip to content

Wrapper, Distribution and Build Environment

The environment a build runs in: the committed wrapper and its distribution, Gradle version management, JVM toolchains, properties, and daemon tuning. Interviewers ask because reproducibility across machines lives entirely here.

on this pageshow

explore

questions

115 · 5 sections

What is the distributionSha256Sum property in gradle-wrapper.properties, and what does it protect against?

level: juniorimportance: must knowfreq 45%
basics
~10 s

It's a SHA-256 checksum of the Gradle distribution ZIP, stored in gradle-wrapper.properties. The wrapper verifies the downloaded distribution against it and aborts if they don't match, protecting against a tampered or corrupted download.

open as a page

In gradle-wrapper.properties, what does distributionUrl control, and what is the practical difference between the '-bin' and '-all' distribution variants?

level: juniorimportance: must knowfreq 70%
basics
~10 s

distributionUrl tells the wrapper which Gradle version to download. The '-bin' zip contains only the runtime; '-all' also bundles sources and documentation so IDEs can show Gradle API docs. Both run builds identically.

open as a page

What are the files that make up the Gradle Wrapper, and what is each one responsible for?

level: juniorimportance: must knowfreq 70%
basics
~10 s

Four committed files: gradlew (Unix script), gradlew.bat (Windows script), gradle/wrapper/gradle-wrapper.jar (the bootstrapping code), and gradle/wrapper/gradle-wrapper.properties (which Gradle version/distribution to use).

open as a page

How do you upgrade the Gradle version used by a project's wrapper, and what command actually regenerates the wrapper files?

level: juniorimportance: must knowfreq 70%
basics
~10 s

Run ./gradlew wrapper --gradle-version 9.0. The built-in wrapper task rewrites gradle-wrapper.properties (and scripts/jar) to point at the requested version, so everyone uses it on the next build.

open as a page

How do you pin the distribution checksum using the wrapper task instead of editing gradle-wrapper.properties by hand?

level: middleimportance: must knowfreq 40%
basics
~10 s

Run the wrapper task with --gradle-distribution-sha256-sum and the official checksum, e.g. ./gradlew wrapper --gradle-version 8.7 --gradle-distribution-sha256-sum <sum>. Gradle writes distributionSha256Sum into gradle-wrapper.properties for you.

open as a page

What is the difference between the JDK Gradle runs on and the Java version your project compiles against, and why does that distinction matter for compatibility?

level: juniorimportance: must knowfreq 60%
basics
~10 s

Gradle itself runs on one JDK (the one launching the daemon). Your code can compile/test against a different Java version via toolchains. Each Gradle release only supports running on certain JDKs.

open as a page

How do you upgrade the Gradle version used by a project that has the wrapper checked in?

level: juniorimportance: must knowfreq 70%
basics
~10 s

Run ./gradlew wrapper --gradle-version X. This rewrites distributionUrl in gradle-wrapper.properties so the next ./gradlew invocation downloads and uses that version. You never hand-install Gradle.

open as a page

After a build you see: 'Deprecated Gradle features were used in this build, making it incompatible with Gradle N.' What does this tell you and what should you do?

level: juniorimportance: must knowfreq 50%
basics
~20 s

It means your build used something that will be removed in the next major Gradle (version N), so it would break after upgrading. Re-run with --warning-mode all to see the specific deprecations, then fix them.

open as a page

What does Gradle's --warning-mode flag do, and what are its possible values when you're preparing for a major-version upgrade?

level: juniorimportance: must knowfreq 55%
basics
~10 s

--warning-mode controls how Gradle shows warnings (mainly deprecations). Values: all, summary, none, fail. Use all to see every deprecation with details before upgrading to a new major Gradle version.

open as a page

Before upgrading the JDK on your CI agents or bumping Gradle, how do you use the official Gradle compatibility matrix to avoid breakage?

level: middleimportance: must knowfreq 55%
basics
~10 s

Look up your Gradle version in the official compatibility matrix to confirm it supports running on the target JDK before installing that JDK on CI. If not, bump Gradle first.

open as a page

How do you tell an Android Gradle Plugin (AGP) project which JDK to use to compile Java and Kotlin, using a JVM toolchain?

level: juniorimportance: must knowfreq 55%
basics
~10 s

Set a JVM toolchain language version. With the Kotlin plugin use kotlin { jvmToolchain(17) }; AGP picks up that JDK to compile Java and Kotlin instead of the JDK running Gradle.

open as a page

What is a Java toolchain in Gradle, and why would you declare one instead of just relying on whatever JDK launched Gradle?

level: juniorimportance: must knowfreq 70%
basics
~20 s

A toolchain tells Gradle which exact JDK version to use to compile, test, and run your code. Declaring one decouples that from the JDK that started Gradle, so the build uses the JDK you specify, not whatever happens to be on PATH.

open as a page

What does Gradle's local JDK auto-detection do, and where does it look for installed JDKs?

level: juniorimportance: must knowfreq 55%
basics
~10 s

Gradle scans well-known locations for installed JDKs so a declared toolchain can be matched to a local JDK without you configuring paths. It checks SDKMAN, asdf, Jabba, Homebrew, and standard OS install directories.

open as a page

Show the minimal settings.gradle.kts setup that lets Gradle download a missing JDK, and explain what each piece does.

level: juniorimportance: must knowfreq 40%
basics
~10 s

Apply the foojay-resolver-convention plugin in settings.gradle.kts. It registers the Foojay repository under toolchainManagement, so Gradle can auto-download a missing toolchain JDK.

open as a page

What is JDK auto-provisioning in Gradle, and what makes it work?

level: juniorimportance: must knowfreq 55%
basics
~10 s

If a build needs a JDK that isn't installed locally, Gradle can automatically download it. By default Gradle needs a toolchain resolver plugin (foojay-resolver) registered in settings to know where to fetch JDKs from.

open as a page

Where can a gradle.properties file live, and what is each location used for?

level: juniorimportance: must knowfreq 60%
basics
~10 s

Two main spots: the project root (<project>/gradle.properties), checked into the repo for shared settings, and GRADLE_USER_HOME (~/.gradle/gradle.properties), a per-developer/machine file for local or secret values.

open as a page

What does the org.gradle.parallel flag do, and how do you enable it both persistently and for a single build invocation?

level: juniorimportance: must knowfreq 70%
basics
~10 s

org.gradle.parallel=true lets Gradle run tasks from different projects at the same time using worker threads. Set it in gradle.properties, or pass --parallel on the command line for one build.

open as a page

What is the difference between passing -Pname=value and -Dname=value on the Gradle command line?

level: juniorimportance: must knowfreq 70%
basics
~10 s

-P sets a Gradle project property (read in the build script as a project property). -D sets a JVM system property (read via System.getProperty). They land in different namespaces.

open as a page

How do you read a value from gradle.properties lazily in a modern Gradle build, and why prefer providers.gradleProperty('x') over project.property('x')?

level: juniorimportance: must knowfreq 60%
basics
~10 s

Use providers.gradleProperty("x"), which returns a Provider<String> read lazily at execution time. project.property("x") reads eagerly at configuration time and touches the Project object, which the configuration cache disallows.

open as a page

If the same property is defined in the project-root gradle.properties, in GRADLE_USER_HOME, and on the command line, which value wins?

level: middleimportance: must knowfreq 65%
basics
~10 s

Highest to lowest: command line / system-property / env-var overrides beat GRADLE_USER_HOME/gradle.properties, which beats the project-root gradle.properties. So the command line wins, and user-home beats the committed project file.

open as a page

What does the Gradle daemon do, and how do you disable it for a single build invocation?

level: juniorimportance: must knowfreq 60%
basics
~10 s

The daemon is a long-lived background JVM that Gradle reuses across builds to avoid startup cost. Disable it for one build with --no-daemon, or permanently via org.gradle.daemon=false in gradle.properties.

open as a page

What does the org.gradle.daemon.idletimeout property control, and what is its default?

level: juniorimportance: must knowfreq 45%
basics
~10 s

It sets how long (in milliseconds) an idle Gradle daemon stays alive before shutting itself down. The default is 10800000 ms — three hours.

open as a page

What is org.gradle.jvmargs and where do you set it to control the Gradle daemon's heap?

level: juniorimportance: must knowfreq 62%
basics
~10 s

org.gradle.jvmargs is a Gradle property that passes JVM flags (like -Xmx) to the build daemon's JVM. You set it in gradle.properties, usually in the project root or the user's ~/.gradle directory.

open as a page

What is the difference between the JVM that runs the Gradle daemon and the JVM used by Java toolchains for compiling and testing your code?

level: juniorimportance: must knowfreq 55%
basics
~10 s

The daemon JVM is the JVM that actually runs Gradle itself. Java toolchains pick a (possibly different) JDK to compile and run your project's code. They are configured separately and can be different versions.

open as a page

Why is disabling (or constraining) the Gradle daemon a common recommendation on ephemeral CI agents?

level: middleimportance: must knowfreq 65%
basics
~10 s

On throwaway CI agents the daemon never gets reused, so it brings no speed-up but risks orphaned processes and memory bloat. Disabling it gives a clean, predictable single-use JVM per job.

open as a page