Reputation: 569
I have two task
task Hello {
println 'Hello'
}
task World {
println 'Hello1'
}
If I run World
task Hello
will run also. If I modify my tasks in this way
task Hello {
doLast {
println 'Hello'
}
}
task World {
println 'Hello1'
}
then task Hello
won't run. How do doLast{}
or doFirst{}
sections affect running tasks in gradle?
I can't find information in gradle docs about that. Thx.
Upvotes: 0
Views: 37
Reputation: 692231
The task Hello doesn't run. It's configured.
The code inside the curly braces is the code that configures the task. This code is always executed, whatever the task you tell gradle to run. It must run so that gradle knows what the task does, on which other task it depends, which other task it finalizes, etc.
Once the configuration phase has finished, the execution phase starts. And in that phase, the task that you asked to execute is executed/ In that phase, the code passed to doLast
is being executed.
Here's the documentation.
Upvotes: 2