Reputation: 27425
In a gradle build script when we declare a task as follows:
task lol
lol << {
prinln "lol's action!"
}
and execute it as gradle -q lol
it works fine. My question is why does lol
task instance is already created and NullPointerException
is not caused? Does declarartion task lol
declare and define task simultaneously?
Upvotes: 0
Views: 145
Reputation: 1356
task is actually a method on Project and task lol
is invoking that method taking advantage of the optional parens. There is some groovy magic involved to turn lol
into a String. The lol Task property on the Project then has the leftShift method invoked using the <<
operator. See operator overloading.
Upvotes: 3