DevOps / Gradle8 Interview Questions
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 aProjectinstance for each. - Configuration — every project's build script is executed, which registers tasks and builds up the task graph, but does not yet run any task's actual action.
- Execution — Gradle determines which tasks from the graph actually need to run (based on what was requested and up-to-date checks) and executes them in dependency order.
Understanding this split matters in practice: code written directly inside a task's configuration block runs during the configuration phase on every single build invocation, even if that task never actually executes, which is why expensive logic belongs inside a doLast/doFirst action or behind the lazy Provider API instead of at the top level of a task registration.
More Related questions...
