ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ninju Bohra <>
Subject Re: return status problem in ant.bat
Date Sat, 17 Feb 2007 17:50:05 GMT
Try calling .exitValue() after the .waitFor() returns.

It seems like both .waitFor() and .exitValue() would return the same value (based on looking
at the JAVA API) however in my experience the .exitValue() seems to give me the sub-process
value more realiably.

Process p = pb.start();

int r = p.waitFor();   // <------------------------------ this always
returns 0
if ( r == 0 ) {
    int exitValue = p.exitValue();
    if (exitValue == 0) {
    else {
else {


----- Original Message ----
From: Jose Antonio Pla Rodriguez <>
Sent: Saturday, February 17, 2007 1:33:54 AM
Subject: return status problem in ant.bat

Hello list:

I am programming a java application than execute a shell command and
gets the return status, with this value I can know if the process
success (return status equals 0) or failed (return status not equals 0).

The problem is that every time I run the ant program by a call to
ant.bat I always get cero ( 0 ) as return status, even when the build is
halted explicitly (<fail/>) or when are evident errors ( like a
execution of an inexistent target or an inexistent build.xml ) 

I get this problem in:

Windows XP SP2

Apache ant 1.6.5

I tried version 1.7.0 with seem results

Can some one tell me why the ant.bat always returns a status 0
independently of the result of the build process??

There is any way to know if a build process success or fails??

This is a snippet of my code:

ProcessBuilder pb = new ProcessBuilder(new String[]{"ant","zzzzzzz"});
//  task zzzzzzz does not exist.

Process p = pb.start();

int r = p.waitFor();   // <------------------------------ this always
returns 0

if ( r == 0 )






No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started. 

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

View raw message