ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dale Anson <dan...@germane-software.com>
Subject Re: failonerror; general solution
Date Fri, 03 Oct 2003 15:34:53 GMT
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" <jan-schroeder@gmx.net>
>>�: <dev@ant.apache.org>
>>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: dev-unsubscribe@ant.apache.org
>>>For additional commands, e-mail: dev-help@ant.apache.org
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>>For additional commands, e-mail: dev-help@ant.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message