Reputation: 11419
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?
Upvotes: 2
Views: 1250
Reputation: 18714
You can use the failonerror attribute of the java task.
<java failonerror="true" fork="true" ... />
This will fail your build (default is "false") if the returncode is other than 0.
Or use fail with conditions
<java resultproperty="result" fork="true" ... />
<fail>
<condition>
<equals arg1="${result}" arg2="-1"/>
</condition>
</fail>
Upvotes: 5