Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Please expain the syntax of the gradle task definition "<<"

Tags:

gradle

The Gradle User Guide shows a syntax for creating a task that I don't understand:

task hello << {
    println 'Hello world!'
}

What is the << doing there?
The question/answer was a little enlightening but I still don't know exactly what << is. Is << a groovy thing or a gradle thing?

like image 397
Bob Kuhar Avatar asked Oct 10 '12 20:10

Bob Kuhar


2 Answers

Bob's answer covers the Groovy side. For the Gradle portion, << corresponds to doLast on task, adding another action to the end of the task's list of actions.

like image 61
ajoberstar Avatar answered Oct 28 '22 12:10

ajoberstar


It's a groovy thing. Operators can be overloaded in Groovy by declaring a method on the object the operator is applied on. In this case, the method is leftShift().

See http://groovy.codehaus.org/Operator+Overloading for more information.

like image 27
JB Nizet Avatar answered Oct 28 '22 11:10

JB Nizet