With the standard ANT tasks you can not handle a 'failing' build. Of course that's why the authors of the <exec> task provided the 'failonerror' attribute. Instead of setting it to 'true' (which results in the buildscript stopping) how about setting it to 'false' and doing the following
<target name="foo" depends="do_exec, success_only, failure_only, after_exec"> </target> <target name="do_exec"> <property name="success_code" value="0"/> <exec dir="..." executable="..." resultproperty="result_code"/> <condition property="exec_succeeded"> <equals arg1="${result_code}" arg2="${success_code}"/> </condition> </target> <target name="success_only" if="exec_succeeded"> ... </target> <target name="failure_only" unless="exec_succeeded"> .... </target> <target name="after_exec"> <text2xml src="..." destfile="..."/> </target> Now...I have nothing against <trycatch>, I have used it before and it has its place...but you may want to try using the 'resultproperty' attribute since it is available Later, Ninju ----- Original Message ---- From: martin sweitzer <[EMAIL PROTECTED]> To: user@ant.apache.org Sent: Monday, March 12, 2007 6:29:31 PM Subject: "post failure tasks" for failing targets For a cruisecontrol set up we have a task called text2xml. So for text2xml to do its magic it needs to run :-) This is problematic for something like: <target name="foo" depends=""> <exec dir="${binaries.dir}" executable="${binaries.dir}/${exampleGame.execName}" output="${compileOptions.logDir}/${exampleGame.log}.log" failonerror="true"> <arg line="${commandLineParams}"/> </exec> <text2xml srcfile = "${compileOptions.logDir}/${exampleGame.log}.log" destfile = "${compileOptions.logDir}/${exampleGame.log}_log.xml" element = "${compileOptions.projectName}" attribute = "name" value = "${exampleGame.log}" /> </target> So the exec fires off and then it has an error so the failonerror aborts the target and returns! This is more generally formed as: How do you do "post failure tasks" for failing targets when the various exec type tasks return from a failonerror="true" ? Is there some way to register a "do after this fails" delegate that I am missing? From another thread I saw the trycatch (http://ant-contrib.sourceforge.net/tasks/tasks/trycatch.html). Is that the standard way of doing the above? so if you have: <target name="a" depends="b,c,d,e,f,g,h,i,j,k,l, taskToRunLast"> You would do something like: <target name="aDoIt" depends="b,c,d,e,f,g,h,i,j,k,l"> <target name="a"> <trycatch property="foo" reference="bar"> <try> <antcall target="aDoIt" /> </try> <catch> <echo></echo> </catch> <finally> <antcall target="taskToRunLast" /> </finally> </trycatch> </target> And then for each depends that also has some "post failure task" then slap in a trycatch there also? Seems to work pretty well in my quick test case. Is this the way to go? :-) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ____________________________________________________________________________________ Don't pick lemons. See all the new 2007 cars at Yahoo! Autos. http://autos.yahoo.com/new_cars.html --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]