Groovy语言中的gradle任务定义是什么? [英] What are gradle task definitions in groovy language?
问题描述
我对gradle和groovy都是全新的,我很难找到有关groovy语言实际内容的信息。
任务myTask(dependsOn:'compile')<< {
println'我不受影响'
}
AFAIK {...}
部分是一个闭包,它似乎被传递给<<
p>
是否对任何构造函数调用myTask()?
冒号看起来像一个参数是什么?
<<
是一个重载操作符,它向任务添加一个任务操作。 (有关更多信息,请参阅 Gradle用户指南。) { ...}
是实现任务操作的闭包。 myTask
在语法上是一个嵌套方法调用( task(myTask(dependsOn:'compile')<< ...)$ c $但使用Groovy编译器插件( task('myTask',dependsOn:'compile')<< ...
)将其重写为字符串。
I'm completely new to both gradle and groovy and I'm having trouble to find information about what the below actually is in the groovy language
task myTask(dependsOn: 'compile') << {
println 'I am not affected'
}
AFAIK the {...}
part is a closure which seems to be passed to whatever is defined before <<
.
Is task myTask()
a call to a constructor?
And what is the thing with the colon that looks like a parameter?
What does <<
do? Is it an operator that was overloaded by gradle or is it standard groovy?
解决方案 dependsOn: 'compile'
is a named argument. <<
is an overloaded operator that adds a task action to the task. (See Gradle User Guide for more information.) { ... }
is a closure that implements the task action. myTask
is syntactically a nested method call (task(myTask(dependsOn: 'compile') << ...)
), but gets rewritten to a String using a Groovy compiler plugin (task('myTask', dependsOn: 'compile') << ...
).
这篇关于Groovy语言中的gradle任务定义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!