Bug 47596 - Unable to capture return code from Ant
Summary: Unable to capture return code from Ant
Alias: None
Product: Ant
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.7.1
Hardware: Other Windows Server 2003
: P4 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
Keywords: ErrorMessage
Depends on:
Reported: 2009-07-28 06:53 UTC by Larry Kriv
Modified: 2009-07-28 12:09 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Larry Kriv 2009-07-28 06:53:09 UTC
When calling Ant from a Windows *.bat file, I am unable to capture the error code from the build to make an intelligent and graceful recovery.  It appears that the bat file abuptly ends when returning from the call.

I run the following, using a non-existant xml build file, so it will get a legitimate error:

set ANT_HOME=C:\D_Drive\apache-ant-1.7.1
set PATH=%PATH%;%ANT_HOME%\bin;

echo * Error    =%errorlevel%
echo *******************
ant -f c:\temp\testAnt1.xml -diagnostics
echo *******************
echo * Error    =%errorlevel%
echo *******************

I do not get anything after the first set of stars.  I have even placed print in ant.bat to ensure that a return code is indeed being set by Ant.
Comment 1 Larry Kriv 2009-07-28 12:09:05 UTC
Realized that adding a "call" before the "ant -f ..." took care of the main problem.  Not getting a return code was the second problem.  Bug #41039 described the problem and the work-around.