FWIW, I've also tried to take advantage of errorlevel in DOS batch files,
and for some reason I don't recall, it was unreliable (something about once
it's set, it would not unset itself, or vice-versa). I ended up avoiding it.
Maybe it was because I was just testing my script, so messed up the DOS
environment too much!?!?! I probably was doing something wrong.

Alternatively, you might want to try starting ANT using java.exe directly.
The return code of java.exe is correctly evaluated by the makefile, and
stops or not the build, depending on makefile stuff (- in front of command,
and command line switches). Below is an extract from a Visual Studio
Makefile that does just that. Hope this helps. -DD

PS: You might need to set ANT_HOME like ant.bat does, so ANT can find the
external bat script like antRun.bat (in ${ANT_HOME}/bin) for <exec>. I'm not
using <exec> in my build file, so I didn't need it. Also the ANT doc has
stuff about starting ant directly.

# ANT ClassPath
ANT_CP=
ANT_CP=$(ANT_CP);"$(EXT_DIR)\ant-1.4.1.jar"
ANT_CP=$(ANT_CP);"$(EXT_DIR)\ant-1.4.1-jaxp.jar"
ANT_CP=$(ANT_CP);"$(EXT_DIR)\ant-1.4.1-crimson.jar"
ANT_CP=$(ANT_CP);"$(EXT_DIR)\ant-1.4.1-optional.jar"
ANT_CP=$(ANT_CP);"$(JAVA_DEV_KIT_ROOT)\lib\tools.jar"

# To find our custom build logger!
ANT_CP=$(ANT_CP);"$(JAX_DIR)\lib\classes"
ANT_CP=$(ANT_CP);"$(JAX_DIR)\lib\classes_g"

# ANT Command Line
ANT_CMD = java -cp $(ANT_CP) org.apache.tools.ant.Main \
          -emacs -logger com.lgc.jax.tools.MsdevAntBuildLogger

# Compile all the java classes (regular, experimental, test)
classes: dirs
  cd $(PROJECT) && $(ANT_CMD) -buildfile JgOcad.xml $(_MODE) classes
  cd $(MAKEDIR)

 -----Original Message-----
From:   Diane Holt [mailto:[EMAIL PROTECTED]] 
Sent:   Friday, March 15, 2002 3:24 PM
To:     Ant Users List
Subject:        RE: Return code from Ant

Hey, I found something -- ERRORLEVEL. Looks like I can capture the return
code from Ant by testing on that, and set it to a var to hold onto it.
Ie., add:

if errorlevel 1 set RC=1

after the "$JAVACMD..." lines. Then, in your makefile, you can do:

@ant.bat ; if $$RC ; then echo bad bongos ; fi

Or anyone running it from a DOS command prompt can do:

C:\> ant || echo oopsy

(I'm learning far more about DOS batch files than I ever intended to --
you owe me! :)

Diane


=====
([EMAIL PROTECTED])



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

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to