What are the definitions of gradle tasks in groovy?

I am completely unfamiliar with gradle and groovy, and I have problems finding information about what is actually below in groovy language

task myTask(dependsOn: 'compile') << { println 'I am not affected' } 

AFAIK {...} is a closure that seems to be transmitted regardless of what is defined before << .

Is task myTask() constructor call?

And what thing with a colon looks like a parameter?

What does << do? Is this an operator that was overloaded with gradle or is it standard groovy?

+6
groovy gradle
Aug 31 '14 at 13:37
source share
1 answer

dependsOn: 'compile' is a named argument. << is an overloaded operator that adds a task action to a task. (For more information, see the Gradle User Guide .) { ... } is a closure that implements the action of the task. myTask is a syntactically nested method call ( task(myTask(dependsOn: 'compile') << ...) ), but is written to String using the Groovy compiler plugin ( task('myTask', dependsOn: 'compile') << ... ).

+8
Aug 31 '14 at 13:57
source share



All Articles