Groovy语言中的gradle任务定义是什么? [英] What are gradle task definitions in groovy language?

查看:160
本文介绍了Groovy语言中的gradle任务定义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对gradle和groovy都是全新的,我很难找到有关groovy语言实际内容的信息。

 任务myTask(dependsOn:'compile')<< {
println'我不受影响'
}

AFAIK {...} 部分是一个闭包,它似乎被传递给<< p>

是否对任何构造函数调用myTask()?

冒号看起来像一个参数是什么?

<< 做什么?它是一个被gradle重载的运算符还是标准的groovy?

解决方案> dependsOn:'compile '是一个命名参数。 << 是一个重载操作符,它向任务添加一个任务操作。 (有关更多信息,请参阅 Gradle用户指南。) { ...} 是实现任务操作的闭包。 myTask 在语法上是一个嵌套方法调用( task(myTask(dependsOn:'compile')<< ...) 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆