How is the order of the doFirst method determined in a gradle build script? I have the following sample script that contains two doFirst methods. I understand that they are additive, as they both execute, but the order that this occurs looks backward:
task initialize
task depTask(dependsOn: initialize)
initialize {
doFirst {
println 'processing doFirst in initialization (configuration)'
}
println 'processing initialize (configuration)'
}
depTask {
println 'processing depTask (configuration)'
}
depTask << {
println 'executing depTask (execution)'
}
initialize << {
println 'executing initialize (execution)'
}
initialize.doFirst {
println 'executing doFirst on initialize (execution)'
}
The output from this script is:
processing initialize (configuration)
processing depTask (configuration)
executing doFirst on initialize (execution)
processing doFirst in initialization (configuration)
executing initialize (execution)
executing depTask (execution)
The first "doFirst" function is defined in the initialize task. The second is defined outside of the configuration block. Why doesn't the first instance execute before the second one? The order of execution looks backward. I would have expected the first one, inside the configuration definition, to execute first. Any help understanding this would be appreciated.