ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Gainty" <mgai...@hotmail.com>
Subject Re: "If Ant fails, it will return a non-zero exit code" - doesn't hold any more ?
Date Tue, 16 Dec 2003 21:09:41 GMT
Evgeny
Try this
(from Perl)
my @xsl = ("java", "org.apache.tools.ant.Main.main");
system(@xsl);

Regards,
Martin

----- Original Message ----- 
From: "Evgeny Goldin" <geniek@netvision.net.il>
To: <user@ant.apache.org>
Sent: Tuesday, December 16, 2003 10:22 AM
Subject: "If Ant fails, it will return a non-zero exit code" - doesn't hold
any more ?


>
> Hello,
>
> It's being said on this list that "If Ant fails, it will return a non-zero
exit
> code". Unfortunately, it doesn't work for me:
>
> 1) I have a build.xml that fails (see below)
> 2) I call 'ant' from Perl script, using 'system()' call and expect to see
>    a non-zero exit code from ant.
> 3) What I see *is* zero.
>
> Ant v1.5.4, j2se v1.4.2, Windows 2000
>
> Here's the code:
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ build.xml
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> <?xml version="1.0" ?>
> <project name="Test" default="compile">
>     <target name="compile">
>         <fail message="AAAAAAAAA"/>
>     </target>
> </project>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~ show_exit_code.pl
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> use strict;
> use warnings;
>
> ( @ARGV == 1 ) or die "Param: command to run";
> my $command   = $ARGV[ 0 ];
> my $exit_code = ( system ( $command ) / 256 );
> print "Exit code of running [$command] is [$exit_code]\n";
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
>
> Running it:
> >perl -w show_exit_code.pl ant
> Buildfile: build.xml
>
> compile:
>
> BUILD FAILED
> file:E:/Projects/AntFailure/build.xml:5: AAAAAAAAA
>
> Total time: 2 seconds
> Exit code of running [ant] is [0]
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
>
> Running script with something else that fails (to make sure it's not
lying)
> >perl -w show_exit_code.pl "java Opa"
> Exception in thread "main" java.lang.NoClassDefFoundError: Opa
> Exit code of running [java Opa] is [1]
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~
>
> As you may see, the exit code of failing ant project is zero. Can
somebody,
> please, explain this to me ?
>
>
>
>
>
>
> ---------------------------------------------------------------------
> 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