This is the content of 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)
}
If I'm running this script, I will get the expected result if target remove
is failed:
...
BUILD FAILED
Total time: 2,21 seconds
But if I add implementation to default
target, like the following:
target('default': 'description') {
depends(cleanCache, remove)
println "Do default task"
}
When target remove
is failed, the println
will be executed and the result is:
...
BUILD SUCCESSFUL
Total time: 2,20 seconds
The default
target depends on remove
target. If remove
target is failed, I expect default
target is also failed. How to do that?
Instead of returning integer value to indicate failed target, you should call
fail()
.