Quantcast
Channel: Gradle Forums - Latest posts
Viewing all articles
Browse latest Browse all 20575

What is the Groovy magic for this task command

$
0
0

As you said, task is a method. The method signature is:

Task task​(Map<String,​?> args, String name, Closure configureClosure)

You’re just calling that method when you write:

task myTask(type: SomeType) { configure closure }

Named arguments appear first in the method signature. Otherwise, you’re looking at the same arguments. myTask is just the value passed for the String name argument.

Now, you might say that myTask isn’t 'myTask' or "myTask", so how is it treated as a String? That’s not Groovy syntax. That’s just because Gradle is doing an AST transform and converting what would normally be a variable reference to a String when evaluating the Gradle file. Therefore, the quotes are optional, but if you don’t add them, the AST transform is effectively just adding them for you.


Viewing all articles
Browse latest Browse all 20575

Latest Images

Trending Articles



Latest Images