What is "task" from a groovy standpoint?


(Kashyap CK) #1

newbie question - what is “task” from a groovy standpoint? I tried exploring by creating a task like this - task Hello << { println “hello” } println Hello.class

This printed out class org.gradle.api.DefaultTask_Decorated

However I could not figure out what “task” is. It does not appear to be a function since Hello becomes a symbol. I’d appreciate any pointers very much.


(Perryn Fowler) #2

Take a look at my answer to this question

TL;DR : task is a method on an instance of Project


(Peter Niederwieser) #3

There is a Groovy compiler plugin (AST transform) involved here which rewrites ‘task Hello’ to ‘project.task(“Hello”)’.


(Kashyap CK) #4

Thank you so much Perryn and Peter. Just what I was looking for.

Regards, Kashyap