这是的内容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)
}
如果我正在运行这个脚本,如果目标remove失败,我将得到预期的结果:
...
BUILD FAILED
Total time: 2,21 seconds
但是,如果我将实现添加到default目标,如下所示:
target('default': 'description') {
depends(cleanCache, remove)
println "Do default task"
}
当目标remove失败时,println将被执行,结果是:
...
BUILD SUCCESSFUL
Total time: 2,20 seconds
default目标取决于remove目标。如果remove目标失败,我希望default目标也失败。怎么做?