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)
}
如果我正在运行此脚本,如果target
remove
失败,我将获得预期结果:

...
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()
,而不是返回整数值来指示失败的目标