Build Phases
Phase 1. Initialization
- Detects the settings.gradle(.kts) file.
- Creates a Settings instance.
- Evaluates the settings file to determine which projects (and included builds) make up the build.
- Creates a Project instance for every project.
Phase 2. Configuration
- Evaluates the build scripts, build.gradle(.kts), of every project participating in the build.
- Creates a task graph for requested tasks.
Phase 3. Execution
- Schedules and executes the selected tasks.
- Dependencies between tasks determine execution order.
- Execution of tasks can occur in parallel.
예시
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[settings.gradle]
rootProject.name = 'basic'
println 'This is executed during the initialization phase.'
[build.gradle]
println 'This is executed during the configuration phase.'
tasks.register('configured') {
println 'This is also executed during the configuration phase, because :configured is used in the build.'
}
tasks.register('test') {
doLast {
println 'This is executed during the execution phase.'
}
}
tasks.register('testBoth') {
doFirst {
println 'This is executed first during the execution phase.'
}
doLast {
println 'This is executed last during the execution phase.'
}
println 'This is executed during the configuration phase as well, because :testBoth is used in the build.'
}
- The following command executes the test and testBoth tasks specified above. Because Gradle only configures requested tasks and their dependencies, the configured task never configures: ```
gradle test testBoth This is executed during the initialization phase.
Configure project : This is executed during the configuration phase. This is executed during the configuration phase as well, because :testBoth is used in the build.
Task :test This is executed during the execution phase.
Task :testBoth This is executed first during the execution phase. This is executed last during the execution phase.
BUILD SUCCESSFUL in 0s 2 actionable tasks: 2 executed ```
참고자료
- https://docs.gradle.org/current/userguide/build_lifecycle.html