You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Evgeny Goldin <ge...@netvision.net.il> on 2003/12/16 17:17:32 UTC

Re[2]: "If Ant fails, it will return a non-zero exit code" - doesn't hold any more ?

SB> As you are using Perl anyway, try runant.pl instead.

Whops, I didn't notice that one. Thank you !

MG> my @xsl = ("java", "org.apache.tools.ant.Main.main");
MG> system(@xsl);

I think it'll also work. But for our needs - we'll just make sure nothing is
launched from batch file after the Ant's java process.





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


Re: "If Ant fails, it will return a non-zero exit code" - doesn't hold any more ?

Posted by Evgeny Goldin <ge...@netvision.net.il>.
SB> err, well, yes - but you've also removed all hooks that clean up your
SB> environment.

Sure, removing the clean-up code does have it's side effects but let it be if it
returns me the correct exit code now.

SB> The real problem - AFAIU and I know virtually nothing about Windows
SB> batch programming - is that you can't store the exit code of Java and
SB> exit the batch file with that code at a later stage (at least not in a
SB> way that works on Win9x).

That would be the cleanest solution and I wouldn't mind using it. I bet ant.bat
developers wouldn't mind either :) Can anybody suggest how to do that (Windows
2000 if that matters) or it's a 100% dead end ?


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


Re: "If Ant fails, it will return a non-zero exit code" - doesn't hold any more ?

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 16 Dec 2003, Evgeny Goldin <ge...@netvision.net.il> wrote:

> After I removed everything after first "%_JAVACMD%" in :runAnt label
> (to make sure "%_JAVACMD%" is the latest operation executed) - the
> exit code I received from running 'ant' has become 1 for failed
> projects.

err, well, yes - but you've also removed all hooks that clean up your
environment.

The real problem - AFAIU and I know virtually nothing about Windows
batch programming - is that you can't store the exit code of Java and
exit the batch file with that code at a later stage (at least not in a
way that works on Win9x).

Stefan

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


Re: "If Ant fails, it will return a non-zero exit code" - doesn't hold any more ?

Posted by Evgeny Goldin <ge...@netvision.net.il>.
That's strange, my previous message doesn't seem to appear on list, so I'll
repeat it here. I think I've found the problem, taking a look on ant.bat:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:runAnt
"%_JAVACMD%" %ANT_OPTS% -classpath "%LOCALCLASSPATH%" "-Dant.home=%ANT_HOME%"
org.apache.tools.ant.Main %ANT_ARGS% %ANT_CMD_LINE_ARGS%
goto end

:runAntWithJikes
"%_JAVACMD%" %ANT_OPTS% -classpath "%LOCALCLASSPATH%" "-Dant.home=%ANT_HOME%"
"-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.Main %ANT_ARGS% %ANT_CMD_LINE_ARGS%
goto end

:end
set LOCALCLASSPATH=
set _JAVACMD=
set ANT_CMD_LINE_ARGS=

if "%OS%"=="Windows_NT" @endlocal

:mainEnd
if exist "%HOME%\antrc_post.bat" call "%HOME%\antrc_post.bat"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So my thought is following: since running Java isn't the latest operation in
the batch file - all following operations simply overwrite the exit code of java
process which is indeed 1 when it fails. But since following operations do succeed -
what is finally returned to the outside world is *their* exit code, not java's
(never was a batch-files pro, so this is only a guess).

After I removed everything after first "%_JAVACMD%" in :runAnt label (to make sure
"%_JAVACMD%" is the latest operation executed) - the exit code I received from running
'ant' has become 1 for failed projects.



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