Gradle
Gradle's model: a programmable build in Groovy or Kotlin, a task DAG, configurations for dependencies, plugins, and aggressive incrementality and caching. Interviewers ask because Gradle rewards people who understand its lifecycle and punishes those who only copy snippets.
on this pageshowhide
guide
overview
~2 minGradle is a build tool whose build files are programs. A settings script decides which projects take part in a build, each build script configures one project, and the outcome is a directed graph of tasks that Gradle runs while skipping every task it can prove has nothing new to do. Interviewers probe it because two people can hand in the same working build file with very different understanding behind it: one knows when each line runs, what makes a task skippable and which classpath a dependency reaches; the other copied the file and hopes. A good Gradle answer names the phase a line runs in, the inputs and outputs a task declares, and the configuration a dependency is declared into. The hub follows the shape of a build. [Lifecycle and execution model](/topics/dev-gradle-lifecycle-execution) covers the phases, the command line and the daemon, and [build scripts and DSL](/topics/dev-gradle-build-scripts-dsl) the language layer those phases evaluate. [Tasks and the task graph](/topics/dev-gradle-tasks) is the unit of work everything else hangs on. [Dependency management](/topics/dev-gradle-dependency-management) and [plugins](/topics/dev-gradle-plugins) supply what most real builds are made of. [Multi-project builds](/topics/dev-gradle-multi-project-builds) scale the model across modules, and [build cache and performance](/topics/dev-gradle-build-cache-performance) explains how Gradle avoids work and how to measure it. [Authoring plugins, tasks and extensions](/topics/dev-gradle-authoring-extensions) treats build logic as software. The delivery end is [testing integration](/topics/dev-gradle-testing) and [publishing and artifacts](/topics/dev-gradle-publishing); the surroundings are [wrapper, distribution and build environment](/topics/dev-gradle-wrapper-toolchains), [tooling and IDE integration](/topics/dev-gradle-tooling-ide), and [ecosystem and interop](/topics/dev-gradle-ecosystem-android), where the Android, Kotlin and Spring Boot plugins begin. Junior rounds stay close to the file in front of you: what the settings script is for, what a task outcome label means, `implementation` against `api`, how to run one test. Senior rounds turn diagnostic: why the build is slow, why the cache misses on CI, why a dependency resolved to an unexpected version, and why a `subprojects {}` block should become a convention plugin. Staff and principal rounds are about the build as a platform that many teams share, where reproducibility, configuration time and supply-chain checks are design decisions. Learn the three phases first, then tasks with their inputs and outputs; almost every later topic is one of those two ideas applied. Dependency configurations come next, and performance and plugin authoring make sense only once all three hold.
primer
### A build runs in three phases **Initialization** reads the settings script and decides which projects exist. **Configuration** evaluates build scripts and assembles the task graph. **Execution** runs the actions of the requested tasks and whatever they depend on. Every line of build logic runs in a particular phase, and a large share of Gradle bugs is a line living in the wrong one: a side effect that fires on every invocation, a value read before a plugin has set it, a slow lookup that taxes even `./gradlew help`. When an interviewer asks "when does this line run?", this is what is being tested. ### Tasks form a graph, not a list A task is a unit of work with actions, inputs and outputs. Gradle orders tasks through edges: hard dependencies that pull another task into the build, softer ordering rules that only sequence tasks already scheduled, and finalizers that run afterwards. Passing one task's output into another task's input creates the edge for you, so a hand-written `dependsOn` between a producer and its consumer often means the wiring between them is missing. ### Work avoidance rests on declarations Work avoidance means Gradle declines to run a task because it can prove the result would not change. It fingerprints what the task declares it reads and writes, compares that with the last run or with the build cache, and then skips, restores or executes. The proof is only as good as the declaration: - an **undeclared input** produces stale output that nobody notices until release; - a **machine-specific input**, such as an absolute path or a timestamp, produces cache misses across machines; - an **overlapping output**, two tasks writing the same directory, defeats caching for both. Incremental builds, the build cache and the configuration cache all inherit this one discipline, so a performance answer usually starts with what a task declares. ### Dependencies live in configurations A dependency is never simply "added to the project". It is declared into a configuration, and the configuration decides which classpaths and which downstream consumers see it. Some configurations are buckets you declare into, some are classpaths Gradle resolves, and some are what the project offers to others. Resolution builds a graph, settles version conflicts by Gradle's own rules rather than Maven's, and selects a **variant** of each module by matching attributes. That variant model is why one library can expose different API and runtime views, and why publishing is where it becomes visible. ### Plugins supply the behaviour Core Gradle knows projects, tasks, configurations and the lifecycle. Plugins add almost everything else: compiling Java, running tests, publishing, packaging an Android app. A plugin is code that registers tasks, configurations and **extensions**, the blocks users write to configure it. Separating plugin behaviour from Gradle behaviour is a recurring ask, especially with the Android, Kotlin and Spring Boot plugins, which bring large models of their own. ### Configure lazily Modern build logic registers tasks instead of creating them and connects values through providers instead of reading them early. A registered task that this invocation does not need is never configured at all. A lazy property is computed only when it is needed, after every script has had its chance to set it, and it remembers which task produces its value. Eager APIs still work, which is why old snippets survive, but they cost configuration time and are a common reason a build cannot use the configuration cache. ### Build logic is software Logic shared across projects belongs in **convention plugins**, kept in an included build or `buildSrc`, compiled, testable and applied by id. The older habit of `allprojects {}` and `subprojects {}` blocks reaching into other projects couples them, hides where a setting came from, and works against configuration-time features that assume each project configures itself. Senior interviews push on this distinction often. ### Reproducibility is pinned, not assumed The wrapper pins the Gradle version, toolchains pin the JDK that compiles and tests, catalogs and lock files pin dependency versions, and verification metadata checks what was downloaded. A build that only works on one machine has usually left one of these to chance.
- Project
- The unit Gradle configures: one directory with its build script, tasks, configurations and extensions. A build contains a root project and any number of subprojects.
- Settings script
- The file evaluated during initialization that names the root project and includes subprojects. It also holds build-wide settings such as plugin and dependency repositories.
- Task
- A unit of work with actions, declared inputs and declared outputs. Gradle schedules tasks in a graph and decides per task whether it needs to run.
- Task graph
- The directed acyclic graph of tasks built at the end of configuration, containing the requested tasks and everything they depend on.
- Task action
- The code a task executes during the execution phase, as opposed to the code that configures the task.
- Lifecycle task
- A task with no actions of its own, such as build or check, that exists to aggregate other tasks under one name.
- Up-to-date check
- Gradle's comparison of a task's current input and output fingerprints with those of its previous run, used to skip work that would produce the same result.
- Build cache
- A local or shared store of task outputs keyed by a hash of the task's inputs and implementation, letting a build reuse outputs produced on another branch or machine.
- Configuration cache
- A cache of the configured task graph. When it hits, Gradle skips the configuration phase entirely and goes straight to execution.
- Configuration
- A named set of dependencies with a role: declared into, resolved into a classpath, or offered to consumers. implementation and runtimeClasspath are examples.
- Variant
- One published form of a module, described by attributes such as usage or target platform. Gradle selects the variant whose attributes match what the consumer requests.
- Version catalog
- A central, usually TOML, list of dependency and plugin coordinates that build scripts reference through generated accessors.
- Plugin
- Reusable build logic applied to a project by id. It registers tasks, configurations and extensions; nearly all practical build behaviour comes from plugins.
- Extension
- An object a plugin adds to a project and exposes as a named block in the build script, through which users configure that plugin.
- Convention plugin
- A plugin written inside the build, often as a precompiled script, that packages shared configuration so many projects apply it by id.
- Provider
- A lazily computed value. Properties built on providers let tasks be wired together without reading values early, and they carry task dependencies along.
- Composite build
- A build that includes other complete builds, substituting their projects for binary dependencies. It is also how build logic is often organised.
- Gradle wrapper
- A small committed script and properties file that download and run a pinned Gradle version, so every machine builds with the same one.
- Toolchain
- A declared JDK requirement that Gradle uses to compile, test and run code, independent of the JDK that runs Gradle itself.
- Daemon
- A long-lived background JVM that runs builds, keeping loaded classes and caches warm between invocations so later builds start faster.
Follow one invocation of `./gradlew build`. The wrapper finds or downloads the pinned Gradle distribution and hands the request to a daemon. Initialization evaluates the settings script, which names the projects and the repositories plugins come from. Configuration then evaluates each project's build script: plugins are applied, and they register tasks, configurations and extensions, which the rest of the script adjusts. The requested name is resolved to tasks, and Gradle follows their edges, whether written by hand or inferred from wired inputs, to produce the task graph. Execution walks that graph. Before each task runs, Gradle fingerprints its inputs and decides whether the task is up to date, can be restored from the build cache, or must execute; independent tasks can run in parallel. When the configuration cache is enabled and nothing that affects configuration has changed, the second run skips straight to execution. The ideas meet in a few lines of build logic: a typed task with declared inputs and outputs, registered lazily, fed by another task's output. ```kotlin abstract class Bundle : DefaultTask() { @get:InputFiles abstract val sources: ConfigurableFileCollection @get:OutputFile abstract val archive: RegularFileProperty @TaskAction fun bundle() { /* runs only in the execution phase */ } } val bundle = tasks.register<Bundle>("bundle") { // configured only if needed sources.from(tasks.named("compileJava")) // edge inferred from the wiring archive.set(layout.buildDirectory.file("bundle.zip")) } tasks.named("assemble") { dependsOn(bundle) } // aggregate it under assemble ``` No explicit edge to `compileJava` is written, yet Gradle knows to run it first; the annotations are what let the task be skipped or restored from cache; the registration means a build that never asks for `assemble` never configures it. The rest of the hub attaches to that walk. Dependency resolution runs when a task needs a classpath, using the configurations plugins created. A multi-project build is one task graph across projects, with project dependencies supplying the edges. Testing and publishing are tasks contributed by plugins, publishing exposing the variant model to other builds. The IDE configures the build through the Tooling API during sync, without running its tasks, which is why a slow configuration phase is felt every time a project is imported. The script syntax itself, Groovy or the typed Kotlin DSL, lives in [DSL languages](/topics/dev-gradle-build-scripts-dsl-dsl-languages).
- Lifecycle and Execution Model →
The three phases and the daemon: the model every other section assumes when it asks when a line runs.
- Build Scripts and DSL →
How settings and build scripts are organised, and what each kind of script is allowed to decide.
- Tasks and Task Graph →
Tasks, their dependencies and their declared inputs and outputs, the core of Gradle and of up-to-date checks.
- Dependency Management →
Configurations, catalogs and conflict resolution, where Gradle departs most from what newcomers expect.
- Multi-Project Builds →
Scaling the model across modules with project dependencies, convention plugins and composite builds.
- Build Cache and Performance →
Work avoidance, both caches and honest measurement, once tasks and dependencies are clear.
Putting real work, such as file reads, network calls or
printlndebugging, in a task's configuration block and being surprised that it runs on every invocation, even./gradlew help.Writing a task that reads or writes files it never declares, then trusting UP-TO-DATE or FROM-CACHE results that were computed from incomplete information.
Assuming Gradle resolves version conflicts the way Maven does; see Resolution and Conflicts before explaining why a version changed.
Declaring everything as
apito make a compile error go away, which leaks internal libraries onto consumers' compile classpaths and slows their builds.Sharing configuration through
allprojects {}orsubprojects {}in a new build instead of convention plugins, the habit modern Gradle most wants unlearned.Reaching for
dependsOnto fix ordering when the real defect is that one task's output was never wired into the other task's input.Calling
.get()on a provider during configuration, which reads a value before other scripts have set it and gives up the laziness the API exists for.Treating a slow build as one number: separate configuration time from execution time and measure with a build scan or profile before tuning anything.
Blaming Gradle for behaviour that belongs to a plugin, such as Android variants or Spring Boot's executable jar; name which component owns the behaviour first.
This guide assumes Gradle 8.x and 9.x and writes examples in the Kotlin DSL. Many production builds are older, and interviewers who maintain them ask what changed along the way: - **6.7** introduced Java toolchains, which separated the JDK that runs Gradle from the JDK that compiles and tests the code. - **7.0** removed the long-deprecated `compile` and `runtime` configurations, so answers built around them describe a Gradle that no longer exists. - **7.4** made version catalogs stable. - **8.1** declared the configuration cache stable. - **8.2** made the Kotlin DSL the default for newly generated builds; Groovy scripts remain fully supported. - **9.0** requires Java 17 or newer to run Gradle itself, moves build scripts to Kotlin 2 and Groovy 4, and positions the configuration cache as the recommended way to run builds. The Java 17 floor applies to the JVM that runs the build, not to the code being built: a toolchain can still compile for an older release. When an answer depends on version, such as whether an API is still eager, whether a plugin is configuration-cache compatible, or which DSL a snippet uses, say which Gradle you mean.
Gradle sits among the JVM build tools, and interviewers expect you to place it. **Apache Maven** is the usual comparison: a fixed lifecycle described declaratively in XML, against Gradle's programmable task graph. Maven's predictability and smaller surface are its strengths; Gradle's are incremental work avoidance, caching and the freedom to model unusual builds. The two also settle version conflicts by different rules, which is worth naming when a migration is discussed. **Bazel** targets very large, often polyglot repositories and trades convenience for strict, hermetic, explicitly declared builds. **sbt** remains common for Scala, and **Ant** survives in older systems. Gradle is also the engine underneath other ecosystems. Android builds are Gradle builds driven by the Android Gradle Plugin, and Kotlin JVM and Multiplatform projects build through the Kotlin Gradle Plugin from JetBrains, so many candidates meet Gradle through those plugins first. Spring Boot ships its own plugin for executable archives. **Develocity**, from Gradle Inc., the company behind Gradle, adds build scans, a shared remote cache and build analytics on top. Within any of these, the questions below still come back to the core: phases, tasks, declared inputs and configurations. [Ecosystem and Interop](/topics/dev-gradle-ecosystem-android) covers where each plugin's model begins.
explore
- Build Scripts and DSL85 questions
- DSL Languages30 questions
- Script File Types30 questions
- Script Building Blocks25 questions
- Tasks and Task Graph103 questions
- Task Declaration & Registration36 questions
- Task Dependencies & Ordering27 questions
- Inputs, Outputs & Up-to-Date20 questions
- Task Actions & Graph API20 questions
- Dependency Management179 questions
- Declaring Dependencies30 questions
- Versions and Catalogs36 questions
- Resolution and Conflicts41 questions
- Repositories and Metadata42 questions
- Artifact Transforms10 questions
- Verification and Integrity20 questions
- Plugins72 questions
- Applying Plugins31 questions
- Plugin Management21 questions
- Core Plugin Families20 questions
- Multi-Project Builds100 questions
- Project Structure & Layout30 questions
- Cross-Project Dependencies20 questions
- Shared Configuration30 questions
- Composite Builds20 questions
- Build Cache and Performance146 questions
- Incremental Work Avoidance25 questions
- Build Cache30 questions
- Configuration Cache30 questions
- Parallelism And Daemon Performance35 questions
- Measurement And Profiling26 questions
- Lifecycle and Execution Model93 questions
- Build Lifecycle Phases27 questions
- Lifecycle Hooks and Listeners20 questions
- Command-Line Invocation31 questions
- Daemon Invocation15 questions
- Authoring Plugins, Tasks and Extensions186 questions
- Testing Integration111 questions
- The Test Task25 questions
- JVM Test Suites25 questions
- Framework Wiring20 questions
- Selection & Reporting20 questions
- Coverage & Plugin Testing21 questions
- Publishing and Artifacts95 questions
- Publication Models25 questions
- Components and Variants30 questions
- Repositories and Credentials25 questions
- Signing15 questions
- Wrapper, Distribution and Build Environment115 questions
- Wrapper & Distribution25 questions
- Version Management15 questions
- JVM Toolchains35 questions
- Properties & Environment20 questions
- Daemon JVM Tuning20 questions
- Tooling and IDE Integration66 questions
- Tooling API26 questions
- IDE Integration20 questions
- Logging and Console20 questions
- Ecosystem and Interop62 questions
- JVM Packaging Plugins31 questions
- Ecosystem Plugins Overview31 questions
questions
1 413 · 13 sectionsWhat is the buildscript {} block in a Gradle build script, and what goes inside it?
basics
~10 sbuildscript {} configures the build script itself: it declares repositories {} and dependencies { classpath(...) } that put plugin and helper jars on the classpath the script needs to compile and run.
Why must the plugins {} block appear first in a build.gradle(.kts) file, and what happens if you put code before it?
basics
~10 sThe plugins {} block must be the first statement (after any buildscript/pluginManagement). Gradle parses it specially and early to resolve plugins. Putting other code before it causes a build failure.
What is the dependencyResolutionManagement {} block, and which Gradle build file does it belong in?
basics
~10 sIt is a block in settings.gradle(.kts) — not build.gradle — where you centrally declare repositories and version catalogs for the whole build instead of repeating them in each module.
What is a Gradle extension, and how does adding one give a plugin its own configuration block in the build script?
basics
~10 sAn extension is an object a plugin registers via project.extensions.create("name", Type::class.java). Gradle then exposes a build-script block named after it (e.g. name { ... }) that configures that object.
What are Gradle's extra (ext) properties, and how do you declare and read them in a build script?
basics
~20 sExtra properties are arbitrary user-defined key/value pairs attached to a Gradle object. You set them with ext { key = value } (Groovy) or by extra (Kotlin) and read them back by name later in the script.
In a Gradle task definition, what is the difference between code in the configuration block and code inside doFirst{}/doLast{}, and when does each run?
basics
~10 sConfiguration-block code runs during the configuration phase for every build invocation. doFirst{}/doLast{} are action closures that run only in the execution phase, and only if the task actually executes.
What does task.onlyIf {} do in Gradle, and what happens to a task whose onlyIf predicate returns false?
basics
~10 sonlyIf {} attaches a predicate evaluated right before the task runs. If it returns false, Gradle skips the task's actions and reports it as SKIPPED. If true (or absent), the task executes normally.
What is the difference between the tasks a user requested on the command line and the tasks Gradle actually schedules and executes?
basics
~10 sRequested tasks are the names you type on the command line (e.g. gradle build). Executed tasks are those plus all their dependencies, which Gradle computes and runs in dependency order.
What is gradle.taskGraph.whenReady{} and when does the closure it registers actually run?
basics
~10 swhenReady registers a callback that runs once Gradle has finished building the task execution graph for the build, after configuration but before any task executes.
What does the Gradle `init` task do, and how do you use it to scaffold a new project?
basics
~20 sgradle init is a built-in task from the build-init plugin that scaffolds a new Gradle project: it generates build/settings scripts, a sample source layout, and the Gradle wrapper, prompting you (or via flags) for project type, DSL, and test framework.
You try to resolve `implementation` and get an error that it cannot be resolved. Why, and what should you resolve instead?
basics
~10 simplementation is a declaration bucket — isCanBeResolved is false — so it has no resolution result. Resolve compileClasspath or runtimeClasspath, which extend from it.
What is the `dependencies {}` block in a Gradle build script, and how do you add a dependency to a specific configuration inside it?
basics
~10 sThe dependencies {} block is where you declare a module's dependencies. Inside it you call a configuration name like implementation(...) with the dependency coordinates (group:name:version) to attach a dependency to that configuration.
How do `testImplementation` and `testRuntimeOnly` relate to the main source set's configurations, and when do you use each?
basics
~20 stestImplementation adds a dependency to the test compile + runtime classpath (e.g. JUnit, Mockito). testRuntimeOnly adds it only to the test runtime classpath (e.g. the JUnit Platform launcher engine). Test classpaths also extend the main ones.
How do you exclude a single transitive dependency that is pulled in by one specific dependency in Gradle?
basics
~10 sAttach an exclude block to that one dependency, naming the unwanted artifact by group and/or module. Only that dependency's transitive graph is affected.
What does the string dependency notation 'group:name:version' mean in Gradle, and how do you declare such a dependency?
basics
~10 sIt's the shorthand for a module's coordinates: group (org), name (artifact), version. You declare it inside a configuration, e.g. implementation("org.apache.commons:commons-lang3:3.14.0").
In a multi-project Gradle build, what does declaring a plugin with `apply false` in the root build script do, and why would you do it?
basics
~10 sapply false adds the plugin to the build's classpath and resolves its version, but does NOT apply (activate) it to the root project. Subprojects can then apply it by id with no version.
What is the legacy apply(plugin = "...") syntax in Gradle, and how does it differ from the modern plugins {} DSL?
basics
~20 sapply(plugin = "...") is the old imperative way to apply a plugin by ID anywhere in the build script. The modern plugins {} DSL is a declarative block at the top that Gradle understands ahead of time.
What is the plugins {} block in a Gradle build script, and how do you apply a core plugin and a community plugin with it?
basics
~10 sThe plugins {} block is the declarative way to apply Gradle plugins. Use id("...") for a plugin, adding version "..." for community plugins. Core plugins like java need no version.
How do you declare a plugin and its version in the plugins {} block, and where does Gradle resolve that plugin from?
basics
~10 sUse id("com.example.foo") version "1.2.3" inside plugins {}. Gradle resolves the plugin from the Gradle Plugin Portal (or repositories declared in settings' pluginManagement) by looking up its marker artifact.
What lifecycle tasks does the Gradle 'base' plugin contribute, and what does each one mean?
basics
~10 sThe base plugin adds 'assemble' (build all artifacts), 'check' (run all verification like tests), 'build' (assemble + check together), and 'clean' (delete the build directory).
In a Gradle composite build, what happens to a dependency on a published module when you include the producing build with includeBuild?
basics
~10 sGradle automatically substitutes the published module coordinates with the local included build's project. Instead of downloading the artifact from a repository, it builds and uses the local source.
What is a composite build in Gradle, and how do you wire one using includeBuild?
basics
~10 sA composite build combines otherwise independent Gradle builds into one. You wire it by adding includeBuild('../other-build') to settings.gradle.kts; Gradle then treats the included build as part of the current build.
What must the in-development plugin build declare so that a consumer including it can apply the plugin by its id?
basics
~10 sThe plugin build must apply the java-gradle-plugin plugin and declare the plugin id and implementationClass in a gradlePlugin { plugins { register(...) } } block. That generates the marker the consumer's id resolves against.
How do you run a task that lives in an included build from the command line in a Gradle composite build?
basics
~10 sPrefix the task path with the included build's name: ./gradlew :includedBuildName:some:task. The leading segment is the build name (its directory name unless overridden), not a project in the root build.
In a Gradle multi-project build, how do you make one subproject depend on another subproject so it can use its classes and outputs?
basics
~10 sAdd a project dependency in the consumer's build file, e.g. implementation(project(":lib")). Gradle builds :lib first and puts its compiled output and dependencies on the consumer's classpath.
What does it mean for a Gradle task to be cacheable, and what is the minimum required to make a task's outputs reusable from the build cache?
basics
~10 sA cacheable task can store its outputs in the build cache and restore them later instead of re-running. It needs the @CacheableTask annotation and fully declared inputs and outputs.
How do you turn the Gradle build cache on, and what is the simplest way to make it the default for everyone on the project?
basics
~10 sSet org.gradle.caching=true in the project's gradle.properties so it is on for every build and every developer, or pass --build-cache on a single command to enable it just for that run.
When you run a Gradle build, what does the FROM-CACHE outcome next to a task mean, and how does it differ from UP-TO-DATE and executed?
basics
~10 sFROM-CACHE means Gradle restored the task's outputs from the build cache instead of running it. UP-TO-DATE means outputs were already on disk and unchanged. Executed means the task actually ran.
Where does Gradle's local build cache store its entries by default, and what does it actually hold?
basics
~10 sBy default the local build cache lives in ~/.gradle/caches/build-cache-1. It stores the outputs of cacheable tasks keyed by a hash, so a later build can reuse them instead of re-running the task.
Where in a Gradle project do you configure the push/pull split for the remote build cache, and at what point in the build lifecycle does that configuration take effect?
basics
~20 sIn settings.gradle(.kts), inside the buildCache { remote<HttpBuildCache> { ... } } block. It takes effect very early — during settings evaluation, before any project is configured — because the cache must be ready before tasks run.
What is Gradle's continuous build (-t/--continuous), and how does it differ from running a task once?
basics
~10 sContinuous build runs gradle -t <task> (or --continuous). Gradle stays alive, watches the task inputs, and automatically re-runs the requested tasks whenever a relevant input file changes, instead of exiting after one run.
What does the built-in `dependencies` task do, and how do you scope it to a single configuration?
basics
~10 sgradle dependencies prints the resolved dependency trees for each configuration. Use --configuration <name> (e.g. runtimeClasspath) to limit the output to one configuration instead of dumping every one.
How do you exclude a specific task from a Gradle build invocation, and what exactly does excluding it do to its dependencies?
basics
~10 sUse -x or --exclude-task with the task name, e.g. gradle build -x test. Gradle removes that task — and any task needed only by it — from the execution graph for this run.
Which command-line flags control Gradle's log verbosity, and how do they relate to one another?
basics
~10 sUse --quiet (-q) for less output, --info (-i) for more, and --debug (-d) for everything. They set the log level; only one applies, with --debug the most verbose and --quiet the least.
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 via project.property("name"). -D sets a JVM system property, read via System.getProperty("name"). -P is Gradle-specific; -D is standard JVM.
How do you enable JaCoCo code-coverage reporting in a Gradle build, and what does applying the jacoco plugin give you?
basics
~10 sAdd jacoco to the plugins {} block. Gradle then adds a jacocoTestReport task and a jacoco {} extension, and instruments your tests so coverage data is collected when you run test.
What is Gradle TestKit's GradleRunner, and how do you use it to functionally test a Gradle plugin?
basics
~20 sGradleRunner is the TestKit entry point that runs a real Gradle build against a temporary project directory. You create it, point it at a project dir, pass arguments, and call build() to execute and inspect the result.
What does the jacocoTestCoverageVerification task do in a Gradle build, and how do you make it fail the build when coverage drops below a threshold?
basics
~10 sIt's a JaCoCo plugin task that checks coverage against rules you define in violationRules. If coverage is below the configured minimum, the task fails, which fails the build.
What is the JUnit BOM and why would you use `testImplementation(platform("org.junit:junit-bom:..."))` in a Gradle build instead of pinning each JUnit artifact's version individually?
basics
~20 sThe JUnit BOM is a Bill of Materials that declares one consistent version for all JUnit modules (Jupiter, Platform, Vintage). Importing it with platform(...) lets you list JUnit dependencies without versions, so they all align.
How do you tell Gradle's Test task to run JUnit 5 (Jupiter) tests instead of the default JUnit 4 runner?
basics
~10 sCall useJUnitPlatform() on the test task. By default Gradle uses the JUnit 4 runner, so you must opt into the JUnit Platform for Jupiter tests to be detected and executed.
How do the archiveBaseName, archiveVersion, and archiveClassifier properties on an archive task (like Jar) combine to form the final published artifact file name?
basics
~10 sGradle assembles the name as [baseName]-[appendix]-[version]-[classifier].[extension]. So baseName 'app', version '1.0', classifier 'sources' produces app-1.0-sources.jar. Empty parts are skipped along with their dash.
Where in the build script do you attach a custom artifact, and what's the minimal correct snippet to add a fat JAR to a Maven publication?
basics
~10 sInside publishing { publications { ... } }, on the publication, call artifact(tasks.named("fatJar")). That single line adds the fat JAR as an extra file on that publication's coordinates.
How do you make a Gradle Java library publish a sources jar and a javadoc jar alongside the main artifact?
basics
~10 sInside the java { } block call withSourcesJar() and withJavadocJar(). Gradle registers sourcesJar and javadocJar tasks and attaches them to the java component, so they publish automatically.
What is the Gradle Module Metadata (the `.module` file), and what does it describe that a traditional Maven POM cannot?
basics
~20 sIt's a JSON file (module.module) Gradle publishes alongside the POM. It describes a module's variants, their dependencies, and attributes — richer info than a flat POM can express, so Gradle can pick the right variant when resolving.
What is a SoftwareComponent in Gradle, and how does it relate to what gets published?
basics
~10 sA SoftwareComponent describes what a project produces for publication (its artifacts and dependencies). The MavenPublication's from(components.java) reads a component to populate the artifacts and POM/metadata that get published.
Wrapper, Distribution and Build Environment
all 115 Wrapper, Distribution and Build Environment questions →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.
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 applying the 'eclipse' plugin to a Gradle build give you, and which files does it generate?
basics
~10 sApplying eclipse adds tasks that generate Eclipse metadata files: .project and .classpath (and .settings). You run ./gradlew eclipse to create them and cleanEclipse to remove them.
What actually happens when your IDE runs a 'Gradle sync', and why can it take much longer than just opening files?
basics
~20 sSync runs the build's initialization and configuration phases through Gradle's Tooling API to discover projects, tasks, dependencies and source sets, then feeds that model to the IDE. It does not run your tasks, but it does execute build-script code.
What are Gradle's console output modes (--console=plain/rich/auto), and what does each one do?
basics
~20 sGradle has three console modes. plain gives flat text with no colors or progress bar. rich forces colors and the animated progress bar. auto (the default) picks rich when attached to a terminal, plain otherwise.
Walk me through the CLI flags that change Gradle's log verbosity and what each one does.
basics
~10 s-q/--quiet shows only errors and important messages; -i/--info adds informational detail like up-to-date reasons; -d/--debug shows everything including internals and timestamps. No flag means the default LIFECYCLE level.
What is Gradle's default log level when you run a build, and what kind of output does it show?
basics
~10 sThe default level is LIFECYCLE. It shows task execution progress, the BUILD SUCCESSFUL/FAILED line, and user-facing messages — but hides INFO and DEBUG detail to keep output concise.
What is the android { } DSL block, and what is its role once AGP is applied?
basics
~20 sandroid { } is the configuration extension AGP registers when you apply it. Inside it you set things like compileSdk, namespace, and defaultConfig. It configures AGP's tasks; without AGP applied, the block does not exist.
What is the Android Gradle Plugin (AGP), and how does it relate to Gradle itself?
basics
~20 sAGP is a Gradle plugin you apply with com.android.application (or com.android.library). Gradle is the generic build engine; AGP teaches Gradle how to build an Android app — compile, package an APK/AAB, and run Android-specific tasks.
What are build types in the Android Gradle Plugin (AGP), and what do the default `debug` and `release` build types represent?
basics
~10 sBuild types are AGP configurations for how an app is built. AGP ships two by default: debug (debuggable, no shrinking) and release (optimizable, shrinkable, signable for distribution).
What is the Jib Gradle plugin and how does it build a container image differently from a typical Dockerfile-based build?
basics
~10 sJib is a Gradle plugin (com.google.cloud.tools.jib) that builds an OCI/Docker image for a JVM app directly from your build, with no Dockerfile and no Docker daemon. You run a task like jib or jibDockerBuild.
What is the Kotlin Multiplatform Gradle plugin, and how do you declare the platforms a module should compile for?
basics
~10 sApply the org.jetbrains.kotlin.multiplatform plugin, then open a kotlin { } block and call target functions like jvm(), js(), and iosX64(). Each call adds a platform the module compiles for.