ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject Re: Return code from Ant
Date Tue, 19 Mar 2002 01:18:13 GMT
--- dhay@lexmark.com wrote:
> *Sorry* to bring this up again, but I am not sure that that will stop my
> makefile running?  Won't it just echo "bad bongos" and carry on to the
> next step?
> 
> (please note, again, my knowledge of makefiles is very minimal!)

Well, this is pretty off-topic at this point, since it's more to do with
DOS batch files and make than with Ant. Also, it's hard for me to say
exactly how you should deal with this, since I don't know what your
situation really is, except that DOS is involved, and somewhere along
line, Make. And since I'm running on an NT, but under Cygwin, and I don't
have 'make' under DOS, only under Cygwin, it could well be that things
will work differently for you than they do for me diddling around with
this. But, for me, if I run 'ant[.bat]' directly from the Makefile (mind
you, running 'make' from my Cygwin bash window), I can't test a return
code from ant.bat inside the Makefile, because ant.bat ultimately exits 0,
since it does things that succeed even after the build fails (unsets some
vars, etc.)

However, if I run ant.bat from within another batch file and run -that-
from the Makefile -and- I include an 'if errorlevel 1 ...' inside that
batch file, then I can test on the return code inside the make target. 

But if I don't include the if on errorlevel, then I -can't- test on the
return code (which doesn't really make a whole lot of sense to me, why
you'd need that 'if errorlevel...', but I don't spend a whole lot of time
worrying about DOS not making much sense :), so you have to have it in
there -- you just don't actually need to do anything useful after it (and
I don't know that there's anything useful you really could do from in
there to stop the make), which is why I just did 'echo bad bongos', since
you -do- need -something- after the if -- you just need it to be anything
that does anything real.

So, for example, if I have a runant.bat that contains:
  @echo off
  ant.bat && if errorlevel 1 goto :noop
  :noop
then I can have in a Makefile:
runant :
  @runant.bat ; \
  if [ $$? -eq 1 ] ; then \
    echo put whatever commands you really want here, not an echo ; \
    exit 1 ; \
  fi
  @echo Good build!

and if the build goes badly, then 'make' will exit 1, and be done. If
everything goes okay with the build, then it'll just blow past all the
stuff in the if/then/fi, and keep on truckin'.

(Note: Make sure everything under the "runant" target is indented starting
with a tab, not spaces, if you pick&put the above.)

Hope that all makes sense,
Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

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


Mime
View raw message