ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <peter.rei...@corvil.com>
Subject Re: failonerror; general solution
Date Fri, 03 Oct 2003 14:57:42 GMT
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


Mime
View raw message