What's the difference in use case between this and the try/catch from ant-contrib or antelope? I'd suggest grabbing the try/catch from either, and making it a core task. Just judging from the e-mail that I get, the try/catch task in antelope is one of the main reasons people download it.

Contrast this usage with Peter's example:
<project>
  <mkdir dir="classes"/>
  <javac srcdir="src" destdir="classes"/>
  <taskdef name="try" classname="...whatever"/>

  <target name="test">
    <try messageproperty="failed">
      <fail>This should fail</fail>
      <echo>This will not be reached</echo>
      <catch>
         <echo>failed is ${failed}</echo>
      </catch>
    </try>
  </target>
</project>

FYI, I'll be posting a new antelope distribution to sourceforge this weekend that has been updated for Ant 1.6.

Dale


peter reilly wrote:
Here is a task that does some like that:

package task;

import org.apache.tools.ant.taskdefs.Sequential;


public class NoFail extends Sequential { private String failureProperty; public void setFailureProperty(String name) { this.failureProperty = name; } public void execute() { try { super.execute(); } catch (Throwable t) { if (failureProperty != null) { getProject().setNewProperty( failureProperty, "true"); } } } }

Usage:
<project>
  <mkdir dir="classes"/>
  <javac srcdir="src" destdir="classes"/>
  <taskdef name="nofail" classname="task.NoFail"
           classpath="classes"/>

  <target name="test">
    <nofail failureproperty="failed">
      <fail>This should fail</fail>
      <echo>This will not be reached</echo>
    </nofail>
    <echo>failed is ${failed}</echo>
  </target>
</project>


Peter

On Friday 03 October 2003 15:43, Emmanuel Feller wrote:

I agree, it is a good option in my mind.

+1 :)

Emmanuel
----- Message d'origine -----
De : "Jan Schroeder" <[EMAIL PROTECTED]>
ï: <[EMAIL PROTECTED]>
Envoyï: vendredi 3 octobre 2003 16:38
Objet : failonerror; general solution


There are a few new entries in bugzilla regarding handling

of


BuildExceptions.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23540

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23581


Also, some tasks already implement some "failonerror"

attribute (e.g.


<java>).

What about creating a container task instead.
Like:

<nofail failureproperty="part.failed">
   <patch .../>
   <echo ../>
   <antcall />
</nofail>

That way all tasks automatically have something like

"failonerror" + you


actually know if the part failed and can take an

appropriate build path


from here on.


Jan


----------------------------------------------------------

-----------


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

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



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



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



Reply via email to