DevOps / Gradle8 Interview Questions
1. What is Gradle?
Gradle is a build automation tool that compiles, tests, packages, and publishes software, most commonly for JVM languages (Java, Kotlin, Groovy) but also usable for C/C++, Android, and other ecosystems. Build logic is written as scripts, either in a Groovy DSL ( build.gradle ) or a Kotlin DSL ( b...
2. What is the purpose of Gradle in a build process?
Gradle's purpose is to automate everything between "source code exists" and "a tested, packaged artifact exists" — compiling code, resolving and downloading dependencies, running tests, packaging jars/apks, and optionally publishing the result to a repository, all driven by a declarative bu...
3. What are the key features introduced in Gradle 8?
Gradle 8 (spanning 8.0 through the 8.14.x line) consolidated several performance and correctness features that had been incubating in Gradle 7. Configuration cache — caches the result of the configuration phase itself, so subsequent builds can skip re-evaluating build scripts entirely when ...
4. What is the Gradle Wrapper?
The Gradle Wrapper ( gradlew / gradlew.bat ) is a small script, checked into the project's repository, that downloads and runs the exact Gradle version the project was built with — so nobody needs Gradle pre-installed, and everybody who checks out the project builds with an identical versio...
5. What are tasks in Gradle?
A task is the fundamental unit of work in a Gradle build — compiling source, running tests, copying files, packaging a jar. Every build script's real job is to define and wire together tasks, either directly or through plugins that register a standard set of them (like compileJava , test , ...
6. What are plugins in Gradle?
A plugin packages reusable build logic — new task types, conventions, extensions to configure — so a project doesn't have to hand-write common functionality like Java compilation or dependency management from scratch. Applying the java plugin, for example, instantly adds standard task...
7. Define a Gradle project?
A Gradle project is a buildable unit — typically one module or component — configured by its own build.gradle (or build.gradle.kts ) file. A build can consist of a single project, or a hierarchy of a root project plus multiple subprojects, all declared together in one settings.gradle ...
8. What is a build.gradle file used for?
build.gradle (Groovy DSL) or build.gradle.kts (Kotlin DSL) is where a project's actual build configuration lives — which plugins to apply, which dependencies to pull in, and any custom tasks or overrides needed beyond what the applied plugins already provide by convention. plugins { id 'jav...
9. What are the types of Gradle DSLs?
Gradle build scripts can be written in one of two domain-specific languages, both ultimately configuring the same underlying build model. Groovy DSL Kotlin DSL File: build.gradle File: build.gradle.kts Dynamically typed, more concise for simple scripts. Statically typed, better IDE autocompletion...
10. List the phases of a Gradle build lifecycle?
Every Gradle build, no matter how simple, moves through three fixed phases in order: Initialization — Gradle reads settings.gradle , determines which projects are part of the build (single project or multi-project), and creates a Project instance for each. Configuration — every projec...
11. What is the purpose of settings.gradle?
settings.gradle is read first, during Gradle's initialization phase, and its main purpose is to tell Gradle which projects exist in the build — the root project's name and any subprojects to include. rootProject.name = 'my-app' include 'core', 'api', 'web' // composite builds also declare i...
12. How do you apply a plugin in Gradle?
The modern, recommended way is the plugins {} block at the top of a build script, referencing the plugin by its ID: plugins { id 'java' id 'org.springframework.boot' version '3.3.0' } Core plugins (like java ) need no version since they ship with Gradle itself; community plugins from the Plugin P...
13. What are dependency configurations in Gradle?
A configuration is a named set of dependencies with a specific purpose and visibility — it controls not just what's on the classpath, but when and to whom that dependency is exposed. The Java plugin defines several standard ones: Configuration Meaning implementation Available at compile and...
14. Define the Gradle daemon?
The Gradle daemon is a long-lived background process that keeps the JVM warm (classes loaded, JIT-compiled, caches populated) between build invocations, instead of starting a fresh JVM from scratch every time you run gradle or ./gradlew . gradle --status # list running daemons gradle --stop # sto...
15. What are Gradle build scans?
A build scan is a shareable, web-hosted report of a single build invocation — every task that ran, how long each took, what was up-to-date versus rebuilt, dependency resolution details, warnings, and the full console output, all in a browsable format rather than scrollback text. ./gradlew b...
16. How do you declare a dependency in Gradle?
Dependencies are declared inside the dependencies {} block, specifying a configuration and a coordinate in group:artifact:version form (or a project reference for a module in the same build): dependencies { implementation 'org.apache. commons:commons-lang3 : 3.14.0' implementation project(' : cor...
17. What is the purpose of gradle.properties?
gradle.properties holds build-wide settings and values that shouldn't be hard-coded inside build.gradle itself — JVM memory options for the daemon, feature flags like enabling the configuration cache, or project-specific properties consumed by the build script. org.gradle.jvmargs=-Xmx2g org...
18. How do you run a specific task from the command line?
Passing the task name to gradle or the wrapper runs it, along with any tasks it depends on: ./gradlew test ./gradlew :core:build # run the build task only in the 'core' subproject ./gradlew build --parallel # run with parallel execution across independent tasks ./gradlew tasks # list all availabl...
19. Why is Gradle generally faster than Maven for incremental builds?
The speed difference mostly comes down to how each tool decides what actually needs to run. Maven's lifecycle-bound execution model runs every bound goal for a phase on every invocation by default, with much less built-in tracking of whether a given step's inputs actually changed. Gradle, by cont...
20. How does Gradle differ from Maven?
Both are JVM build tools that manage dependencies and run a structured build, but they differ in configuration style, execution model, and flexibility. Gradle Maven Build logic in Groovy or Kotlin DSL, executable code. Build logic in declarative XML (pom.xml). Task graph with explicit input/outpu...
21. What is the difference between Groovy DSL and Kotlin DSL in Gradle?
Both configure the exact same underlying Gradle object model, but they differ meaningfully in typing, tooling, and how errors surface. Groovy DSL (build.gradle) Kotlin DSL (build.gradle.kts) Dynamically typed; some errors only surface at build time. Statically typed; many errors caught by the IDE...
22. How does Gradle's configuration cache improve build performance?
Normally, every Gradle invocation re-runs the configuration phase — executing every project's build script to rebuild the task graph — even if nothing about that structure has changed since the last build. The configuration cache serializes the result of that phase (the fully resolved...
23. Why should you enable the build cache for CI pipelines?
The build cache stores each task's outputs keyed by a hash of its inputs, and reuses that output whenever the same inputs occur again — even on a completely different machine, if a shared remote cache is configured. CI runners typically start from a clean checkout with no local build histor...
24. How does Gradle determine whether a task is up to date?
Gradle compares a task's declared inputs (source files, configuration properties, dependency files) and outputs (compiled classes, generated files) against a snapshot recorded the last time that task ran successfully. If every input and output matches the previous snapshot exactly, the task is co...
25. When should you use a version catalog instead of hardcoded dependency strings?
A version catalog ( gradle/libs.versions.toml ) centralizes dependency coordinates and versions in one shared file that every subproject's build script references by alias, rather than each module hardcoding its own 'group:artifact:version' string. # gradle/libs.versions.toml [versions] junit = "...
26. What happens when two dependencies resolve to conflicting versions?
When two dependencies (directly or transitively) require different versions of the same library, Gradle doesn't fail by default — it applies conflict resolution, and by default picks the highest requested version among the candidates, a strategy generally called "latest wins." configuration...
27. Explain the execution flow of a Gradle build from invocation to completion?
Running ./gradlew build moves through the same three fixed phases every time, regardless of project size. flowchart TD A[gradlew build invoked] --> B[Daemon started or reused] B --> C[Initialization: read settings.gradle, create Project instances] C --> D[Configuration: run every project's build....
28. How can you optimize a slow Gradle build?
Slow Gradle builds usually trace back to a small set of repeatable causes, each with a fairly direct fix. Enable the configuration and build caches — skips both re-evaluating scripts and re-running tasks with unchanged inputs. Enable parallel execution ( org.gradle.parallel=true ) so indepe...
29. How do you troubleshoot a configuration cache invalidation issue?
When the configuration cache unexpectedly misses (re-runs full configuration when you expected a hit), Gradle's own reporting is the first and most reliable source of the answer rather than guessing. Run with --configuration-cache-problems=warn (or check the automatically generated HTML report af...
30. Why is task input/output declaration important for incremental builds?
Gradle's whole incremental-build model — skipping tasks that don't need to rerun — only works if a task accurately declares everything that could affect its result as an input, and everything it produces as an output. If a task silently reads a file, property, or dependency that isn't...
31. Explain the lifecycle of a Gradle task?
A task moves through creation, configuration, and (conditionally) execution, and understanding where each step happens explains a lot of otherwise-confusing Gradle behavior. flowchart TD A[tasks.register called during script evaluation] --> B[Task instance created lazily — not yet fully con...
32. How does Gradle handle transitive dependency resolution?
When a declared dependency itself depends on other libraries, Gradle pulls those transitive dependencies in automatically, recursively, building a full dependency graph rather than just the directly-declared set. Each node in that graph carries its own transitive requirements, and Gradle merges t...
33. What is the difference between the compileOnly, implementation, and api configurations?
All three affect the compile classpath, but they differ in runtime availability and visibility to downstream consumers. compileOnly implementation api Compile-time only, NOT on the runtime classpath. Compile-time AND runtime classpath, but hidden from consumers. Compile-time AND runtime classpath...
34. How do you implement a custom Gradle task?
A custom task is a Java or Groovy/Kotlin class extending DefaultTask , with its configurable inputs and outputs declared as annotated properties, and its behavior defined in a method annotated @TaskAction . abstract class GreetTask extends DefaultTask { @Input abstract Property < String > getName...
35. How does the Provider API enable lazy configuration?
The Provider API ( Provider
36. Which is better and why: buildSrc or an included build for build logic?
Both let you write custom build logic (convention plugins, shared tasks) as real, compiled code instead of copy-pasted script snippets, but they differ in one big practical way: buildSrc is automatically included and rebuilt on every single build invocation, and any change inside it invalidates t...
37. How do you integrate Java toolchains into a Gradle build?
Java toolchains let a build declare which JDK version and vendor its compilation, testing, and execution should use, independently of whatever JDK happens to be running Gradle itself — Gradle automatically locates (or, if configured, downloads) a matching JDK rather than requiring the devel...
38. Explain the internal working of Gradle's incremental build mechanism?
Underneath the simple "task skipped, marked UP-TO-DATE" message, Gradle is comparing serialized snapshots of a task's declared state against what was recorded the last time it ran. flowchart TD A[Task about to execute] --> B[Gradle snapshots current inputs: file hashes, property values] B --> C{S...
39. How do you configure a multi-project Gradle build?
A multi-project build starts with settings.gradle declaring the subprojects, then each subproject gets its own build.gradle , with shared configuration typically centralized at the root using allprojects {} / subprojects {} or, in modern Gradle, convention plugins. // settings . gradle rootProjec...
40. What is the difference between the build cache and the configuration cache?
Both are caches, but they cache different phases of the build and solve different problems. Build Cache Configuration Cache Caches task execution outputs. Caches the result of the configuration phase (the task graph itself). Skips re-running a task's action if inputs match a stored entry, locally...
41. How does Gradle support parallel task execution?
With org.gradle.parallel=true (or the --parallel flag), Gradle can execute tasks from different projects concurrently on separate worker threads, as long as the task graph shows no dependency relationship between them — two independent subprojects' compileJava tasks, for instance, have no r...
42. When would you choose a convention plugin over applying plugins directly in each module?
A convention plugin bundles a set of plugin applications and shared configuration (Java version, common dependencies, code-quality tool setup) into one reusable, versioned plugin, applied with a single id '...' line in each module, instead of repeating the same block of configuration in every mod...
43. How do you secure credentials used in a Gradle build?
Credentials (repository publishing tokens, private repository access keys, signing keys) need to stay out of committed build scripts, and Gradle provides a few standard mechanisms rather than hardcoding secrets inline. Gradle properties in the user home directory ( ~/.gradle/gradle.properties ), ...
44. Why should exclude and dependency substitution be used carefully?
Both exclude and dependency substitution let you override what Gradle would otherwise resolve for a dependency, but they act globally on the resolution graph, which means they're easy to apply too broadly and silently affect parts of the build that weren't the actual target. configurations { impl...
45. How do you configure a composite build with included builds?
A composite build lets one Gradle build transparently substitute a dependency with the output of another, separate Gradle build — useful for developing a library and the application consuming it side by side, without publishing the library to a repository first for every small change. // se...
46. Explain the execution flow of Gradle's task graph construction?
Before any task runs, Gradle has to figure out the complete, correctly-ordered set of tasks needed to satisfy what was requested on the command line, which happens once, right after configuration. flowchart TD A[Requested tasks from command line, e.g. 'build'] --> B[Resolve requested task names t...
47. How does Gradle report and handle build failures across tasks?
By default, Gradle stops the build as soon as any task fails, without starting any task that hasn't already begun — failing fast rather than continuing to burn time on a build that's already known to be broken. Tasks already running or already completed successfully aren't rolled back; the ...
48. Why doesn't a lazily-configured task run during the configuration phase?
A task registered with tasks.register(...) is deliberately not fully created or configured at the moment that line executes — Gradle only stores a lightweight reference and the configuration block as a deferred action, and actually realizes (fully configures) the task only if something in t...
49. How do you migrate a Gradle 7 build to Gradle 8?
Migrating across a major Gradle version is mostly about working through removed/deprecated APIs and adjusting to stricter defaults, and Gradle's own tooling covers most of the mechanical work. Run the built-in deprecation checks first, on Gradle 7 — ./gradlew help --warning-mode all surface...
50. What is the difference between Gradle 8 and Gradle 9?
Gradle 9.0 (released mid-2026) is the major line that followed Gradle 8's final releases (culminating around 8.14.x), and it introduces both new conventions and breaking changes on top of what 8 established. Gradle 8 Gradle 9 Configuration cache stabilizing, opt-in via a property. Configuration c...