I found many thread about handling test fails but I did not find a way to stop ant if a “java” ant task finishes with the class returning -1 (or any other error value).
I do not want to use junit task because it is not a unit test as the user has to enter some input. The class in its main method checks the code on the basis of the input and eventually returns an error calling System.exit(-1).
In that case I need to stop ant.
Is there a way to do it?
You can use the failonerror attribute of the java task.
This will fail your build (default is "false") if the returncode is other than 0.
Note: You need to run with fork="true".
Or use fail with conditions