I am working on a generalized base of a validation util which I want distribute as a JAR and automate using Ant. Using Java alone, I can do something like
...
int validationResults = this.validate();
System.exit(validationResults) // via Ant: 1 = "BUILD FAILED", 0 = "BUILD SUCCESSFUL"
...
to use the validation util in scheduled builds using CI-systems.
I am however writing this in jRuby instead of Java (for learning). I have tried the below ways but they do not trigger “BUILD FAILED” in Ant.
java.lang.System.exit(1) # using "require 'java'" at the the top of the file
Kernel.exit 1
exit 1
I have seen tickets in the jRuby issue tracker about this (for example JRUBY-1650) but I have not managed to find a solution to my problem.
I am running jRuby v1.6.6 and Warbler v1.3.2. The Ant target looks like this:
<target name="validate">
<java jar="./validator.jar" fork="true" />
</target>
Is it me not doing it right, or does jRuby not support this (yet)?
I suppose you start your jRuby code from the
javaAnt task.To get Ant fail in case of a non-zero exit code from your jRuby process, you have to set the
failonerrorattribute of the java task totrue.