I am aware of the difference between passing in a configuration closure and defining an action for a task. I believe you can't use <<
in a configuration closure because it seems like a syntax error:
task wrong {
<< { println "From doLast" }
}
But. Why can't I use leftShift
as an equivalent of <<
in the above configuration closure? In an even more clear test case, why doesn't the following buildfile output the line From leftShift - inside
?
defaultTasks 'tryout'
task tryout {
doLast { println "From doLast" }
leftShift { println "From leftShift - inside" }
}
tryout.leftShift { println "From leftShift - outside" }
Of course, this is not a real problem, as I can simply use doLast. I'm just trying to broaden my understanding of Gradle. Thanks!