We discussed in first chapter that a build file consists of three phases: initialization, configuration, and execution, which are explained briefly as follows:
The task API mainly defines two types of closures: doFirst
(Closure closure) and doLast
(Closure closure), which internally calls doFirst(Action action)
and doLast(Action action)
. You can mention either one or both of them.
To verify the configuration phase of a task, you can execute the build script using the --dry-run
or –m
option. The --dry-run
( or –m
) option only goes through the initialization and configuration phase, not the execution phase. Try to execute the preceding build file with the --dry-run
option and you will find all the configuration statements printed on the console:
$ gradle --dry-run This is project configuration part, description is Sample Java Project This is sampleTask1 configuration statements, taskDetail is This is custom property of task1 This is sampleTask2 configuration statements :help SKIPPED BUILD SUCCESSFUL
In Gradle 2.4 version, there are some performance improvements implemented in the configuration phase. For more details, refer to the release note at https://docs.gradle.org/2.4/release-notes#significant-configuration-time-performance-improvements.
3.147.83.176