ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "martin sweitzer" <msewli...@gmail.com>
Subject "post failure tasks" for failing targets
Date Mon, 12 Mar 2007 22:29:31 GMT
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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message