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 pageshowhide
explore
- Wrapper & Distribution25 questions
- Wrapper Scripts & Files5 questions
- gradle-wrapper.properties & distributionUrl5 questions
- wrapper Task & --gradle-version5 questions
- distributionSha256Sum Integrity5 questions
- Validating the Wrapper Jar5 questions
- Version Management15 questions
- Upgrading Gradle Versions5 questions
- Compatibility Matrix5 questions
- --warning-mode & Deprecations5 questions
- JVM Toolchains35 questions
- Declaring a Toolchain5 questions
- Vendor & Implementation Selection5 questions
- Local JDK Detection5 questions
- Auto-Provisioning & Foojay Resolver5 questions
- toolchainManagement Repositories5 questions
- Per-Task Toolchains5 questions
- Toolchains in Android Builds5 questions
- Properties & Environment20 questions
- gradle.properties Precedence5 questions
- org.gradle.* Build Flags5 questions
- -P vs -D vs ORG_GRADLE_PROJECT_5 questions
- providers.gradleProperty API5 questions
- Daemon JVM Tuning20 questions
- org.gradle.jvmargs Heap & Metaspace5 questions
- Daemon Idle Timeout & Lifecycle5 questions
- Daemon Toolchain (org.gradle.java.home)5 questions
- Disabling the Daemon (--no-daemon, CI)5 questions
questions
115 · 5 sectionsWhat is the distributionSha256Sum property in gradle-wrapper.properties, and what does it protect against?
basics
~10 sIt'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.
In gradle-wrapper.properties, what does distributionUrl control, and what is the practical difference between the '-bin' and '-all' distribution variants?
basics
~10 sdistributionUrl 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.
What are the files that make up the Gradle Wrapper, and what is each one responsible for?
basics
~10 sFour 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).
How do you upgrade the Gradle version used by a project's wrapper, and what command actually regenerates the wrapper files?
basics
~10 sRun ./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.
How do you pin the distribution checksum using the wrapper task instead of editing gradle-wrapper.properties by hand?
basics
~10 sRun 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.
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?
basics
~10 sGradle 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.
How do you upgrade the Gradle version used by a project that has the wrapper checked in?
basics
~10 sRun ./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.
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?
basics
~20 sIt 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.
What does Gradle's --warning-mode flag do, and what are its possible values when you're preparing for a major-version upgrade?
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.
Before upgrading the JDK on your CI agents or bumping Gradle, how do you use the official Gradle compatibility matrix to avoid breakage?
basics
~10 sLook 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.
How do you tell an Android Gradle Plugin (AGP) project which JDK to use to compile Java and Kotlin, using a JVM toolchain?
basics
~10 sSet 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.
What is a Java toolchain in Gradle, and why would you declare one instead of just relying on whatever JDK launched Gradle?
basics
~20 sA 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.
What does Gradle's local JDK auto-detection do, and where does it look for installed JDKs?
basics
~10 sGradle 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.
Show the minimal settings.gradle.kts setup that lets Gradle download a missing JDK, and explain what each piece does.
basics
~10 sApply 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.
What is JDK auto-provisioning in Gradle, and what makes it work?
basics
~10 sIf 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.
Where can a gradle.properties file live, and what is each location used for?
basics
~10 sTwo 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.
What does the org.gradle.parallel flag do, and how do you enable it both persistently and for a single build invocation?
basics
~10 sorg.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.
What is the difference between passing -Pname=value and -Dname=value on the Gradle command line?
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.
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')?
basics
~10 sUse 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.
If the same property is defined in the project-root gradle.properties, in GRADLE_USER_HOME, and on the command line, which value wins?
basics
~10 sHighest 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.
What does the Gradle daemon do, and how do you disable it for a single build invocation?
basics
~10 sThe 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.
What does the org.gradle.daemon.idletimeout property control, and what is its default?
basics
~10 sIt sets how long (in milliseconds) an idle Gradle daemon stays alive before shutting itself down. The default is 10800000 ms — three hours.
What is org.gradle.jvmargs and where do you set it to control the Gradle daemon's heap?
basics
~10 sorg.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.
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?
basics
~10 sThe 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.
Why is disabling (or constraining) the Gradle daemon a common recommendation on ephemeral CI agents?
basics
~10 sOn 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.