Hi all,
I am new to this forum and sure this may have asked number of times but I couldn’t think of good keywords to search for its answer.
How Gradle translate the follwing
task('myCopy', type: Copy)
to
task myCopy(type: Copy)
None of the groovy syntax I know can help me do that. Unless, task method return a callable Task that can take named parameter.
Here are 4 ways to call task defined in Project Interface
task(args: Map<String,?>, name:String)
task(args: Map<String,?>, name:String, c:Closure)
task(name: String)
task(name: String, c:Closure)
I understand that parenthesis is option and {} is the closure body. Also AbstractProject in org.gradle.api.internal.project allow you to pass in an Object instead of a String
public Task task(Object task, Closure configureClosure) {
return task(task.toString(), configureClosure);
}
However, I still have a difficult time to see how Gradle/Groovy allow me to go from task('myCopy', type: Copy)
to task myCopy(type: Copy)
Thanks