Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Task Configuration vs Task Execution

Tags:

gradle

What is the difference between the code below?

task A {
 println 'configuration'
}

task B << {
 println 'action'
}

I believe it has something to do with evaluation.

ie task A is always evaluated whereas task B is only evaluated when its executed

like image 411
IanWatson Avatar asked Oct 14 '25 03:10

IanWatson


1 Answers

Indeed: the 'println' statement of your task A will be executed during 'configuration' phase, whereas the 'println' statement of taks B will only be executed during 'execution' phase (assuming task B is run, directly or indirectly via task dependencies)

For more info, checkout: http://www.gradle.org/docs/current/userguide/build_lifecycle.html. Section 56.2 has a nice example (also demonstrating the third phase, being the 'initialization' phase, BTW)

Note: the "<<" is a shorthand notation for "doLast"

like image 164
roomsg Avatar answered Oct 18 '25 22:10

roomsg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!