I am using a bat program to invoke ant after setting some environment variables; then the following code to run and check the return code: call ant if errorlevel 1 ( set /A failed += 1 if "%ignore%" == "" goto bad ) Even though the results of the ant build say "BUILD SUCCESSFUL" the errorlevel returned is 1 and not 0. If I use the -v parameter to ant ("call ant -v") it returns the correct return code (0 on success, 1 on failure).
Its not that Ant's return code is invalid, it is that Ant doesnt set one indicating whether it succeeded or failed. That has been a policy decision in the past, mainly for Win9x compatilbity. If you can come with a patch for ant.bat that works on both the WinXP and Win9x platforms, then we can fix it. Tip: the perl and python entry points do set the return value properly.
Steve, the same way we broke BC with Java 1.1, could we consider breaking BC for Win9x in ant.bat? I would think having a specific ant9x.bat script would be enough, no? I'd be +1 to have ant.bat properly propagate the 'correct' return code. --DD
If we want to write a script specific for WinNT, we could just call it ant.cmd which will work for NT (or is it XP) but not for 9x. That will preserve BC and solve the issue. No?
(For example,) when I look at my XP config (on a new machine), %PATHEXT% is set to pick up .BAT -before- .CMD, so just placing an NT-specific ant.cmd file in $ANT_HOME/bin wouldn't (I predict) solve the issue. I think one of my kids might still have a 9x version of one sort or another; if so I could try to do this... but after having had a look at the batch file I can say it won't be pretty. -Matt
hmm... secondly, I imagine that the final solution need not work identically on both platforms; i.e.: the 9x result might not have all the behavior of the NT version, as long as the final batch file runs on both platforms... ;)
If it were up to me, I'd abandon win9x support altogether. But I know the eclipse and netbeans team try and support it, which is why the fact that <property env> is broken still niggles me. Maybe we could have the batch file do something different with error codes on the two platforms. I have a win9x vmware image for testing...
All I know to do at this point is modify the batch file to do the right thing on NT, and dodge those commands on Win9x. There are additional complications related to the structure of the batch file, but they are nothing major; pretty much the only detrimental effect will be ugliness. The batch will still be crippled but functional on Win9x.
I agree with Matt. -:) So we would document that ant.bat returns a significant return code on Windows platforms other than Win9x.
*** This bug has been marked as a duplicate of 13655 ***