【发布时间】:2014-06-06 18:59:52
【问题描述】:
运行构建脚本时出现错误:
task pullInDeps(dependsOn: copyMod, description: 'Pull in all the module dependencies for the module into the nested mods directory') {
if (pullInDeps == 'true') {
setSysProps()
def args = ['pulldeps', moduleName]
Starter.main(args as String[])
}
}
但是,我运行的时候没有报错:
task pullInDeps(dependsOn: copyMod, description: 'Pull in all the module dependencies for the module into the nested mods directory') << {
if (pullInDeps == 'true') {
setSysProps()
def args = ['pulldeps', moduleName]
Starter.main(args as String[])
}
}
注意:区别在于定义任务时的doLast{} 围绕if statement 完成的,它可以工作。并且在使用 doFirst{} 时有效
--这是来自 vert.x gradle-template-example (但将其添加到我自己的项目中)。
我真的只是想更好地理解 gradle/groovy,因为我已经解决了这个问题。
编辑:
错误:
* What went wrong:
A problem occurred evaluating script.
> Could not find property 'Starter' on task ':pullInDeps'.
我不确定为什么 leftShift 或 doFrist/Last() 对 Starter 有影响。
【问题讨论】: