ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dennis Wheeler <>
Subject returning build failed error code from ant.bat
Date Tue, 10 Jun 2003 22:49:05 GMT
Searching through the archives, I found this question asked many times,
however I found no satisfying answers -- including one response
claiming that a bug was written and closed as "don't know how to fix"

The problem:
 running ant.bat from another script, such as make. If ant fails, the
build script still continues. How do I detect these build failures when
ant.bat always returns true?

The solution:
 in effect, I've already answered my own question -- it's the javacmd
(or any other command) that is in fact returning a proper error code,
but the batch file is not trapping nor responding to it, so ant.bat
just happily continues and always returns true.

modify ant.bat to trap for and respond to errors, for example
  "%_JAVACMD%" blah blah blah || if errorlevel 1 exit 1
  goto end

Now if the javacmd fails, if errorlevel will detect the error and we'll
return a non-true exit code from the batch file so the the makefile or
other wrapper script can detect the error.

Of course, a more elegant fix would be to have a proper errorhandling
subroutine to clean up various environment variables and such, but I'll
leave that as an exercise to the reader.

Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message