ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose Antonio Pla Rodriguez" <...@procyonsoluciones.com>
Subject RE: return status problem in ant.bat
Date Mon, 19 Feb 2007 18:41:23 GMT
Nothing, I call the exitValue() after the waitFor() returns and get the
value 0 again.

There is something else, in linux that works without problems (returns
1).

Can some body tell me what can I do??

-----Original Message----
From: Ninju Bohra [mailto:ninju_bohra@yahoo.com] 
Sent: Saturday, February 17, 2007 12:50 PM
To: Ant Users List
Subject: Re: return status problem in ant.bat

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) {
       System.out.println("OK");  
    }
    else {
        System.out.println("FAILED");
        System.exit(5);
    }
}
else {
   System.out.println("FAILED");  
   System.exit(5);
}

 


----- Original Message ----
From: Jose Antonio Pla Rodriguez <pla@procyonsoluciones.com>
To: user@ant.apache.org
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 )

   System.out.println("OK");  

else

   System.out.println("FAILED");  





Regards,



Pla.


 
________________________________________________________________________
____________
No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message