If you add failonerror="true" to the exec task it will die if your batch file fails.
To show a custom error message, you'll need to set failonerror="false" then test the result property Something like this should work... (untested) <exec resultproperty="cmdresult" failonerror="false" ... /> > <condition property="cmdsuccess"> > <equals arg1="${cmdresult}" arg2="0"/> > </condition> > <fail unless="cmdsuccess" message="You are doomed."/> On Thu, Feb 2, 2012 at 12:46 AM, Anil <a.ku...@castsoftware.com> wrote: > Hi, > > I have 5 different action in 5 target and what I want is if target1 run > into > error, stop the ANT /build at that point show error message on command > window. > > <target name="AKU" description="running an AKU batch file"> > <if> > <available file="${cast.anarun.batch}"/> > <then> > <echo message="analysing" /> > <exec > executable="${cast.anarun.batch}"/> > </then> > </if> > </Target> > > <target name="CCC" depends="AKU" description="running CCC"> > <exec executable="${cast.tcc}"/> > <input message="Please hit enter to continue OR close command > window to > quit"/> > </target> > > Even if my target AKU failed ANT continue to next target CCC. I want to > show > customized error message if AKU task failed and stop execution. > > -- > View this message in context: > http://ant.1045680.n5.nabble.com/Stop-as-soon-as-target-run-into-error-or-fail-tp5449682p5449682.html > Sent from the Ant - Users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@ant.apache.org > For additional commands, e-mail: user-h...@ant.apache.org > >