Gradle task config and task execution

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.

those. task A is always graded whereas task B is only graded when it is completed

+3


source to share


1 answer


Indeed: the 'println' statement of your task A will be executed during the "configuration" phase, while the "println" statement taks B will only be executed during the "run" phase (assuming that task B is run directly or indirectly through dependencies tasks)

For more information, checkout: http://www.gradle.org/docs/current/userguide/build_lifecycle.html . Section 56.2 has a good example (also demonstrating the third stage, which is the "initialization" phase, BTW)



Note: "<is shorthand for" doLast "

+4


source







All Articles