Groovy 为什么在一个依赖项失败时执行甘特目标?
这是Groovy 为什么在一个依赖项失败时执行甘特目标?,groovy,gant,Groovy,Gant,这是build.gant的内容: target('cleanCache': 'description') { ... } target('remove': 'description') { ... File app = new File("...") if (!app.exists()) { println "Error" return -1 } ... // continue if no error ... } target('d
build.gant
的内容:
target('cleanCache': 'description') {
...
}
target('remove': 'description') {
...
File app = new File("...")
if (!app.exists()) {
println "Error"
return -1
}
...
// continue if no error
...
}
target('default': 'description') {
depends(cleanCache, remove)
}
如果我正在运行此脚本,如果targetremove
失败,我将获得预期结果:
...
BUILD FAILED
Total time: 2,21 seconds
但是如果我将实现添加到default
target,如下所示:
target('default': 'description') {
depends(cleanCache, remove)
println "Do default task"
}
当目标remove
失败时,将执行println
,结果为:
...
BUILD SUCCESSFUL
Total time: 2,20 seconds
默认
目标取决于删除
目标。如果remove
目标失败,我预计default
目标也会失败。如何做到这一点?您应该调用fail()
,而不是返回整数值来指示失败的目标