A build fails, if a BuildException occurs during task execution.
This is the case on some tasks when they "find" some mistakes like <javac> and
invalid java source.
An other example is <junit> with failing tests, but here you can specify
whether the build should fail or failing test should just be reporting using
<junit haltonfailure|haltonerror>.
With <fail> you can directly throw a BE and the build will halt.
I am not sure, but I think you can "overwrite" this behaviour using
-k(eep-going).
ant -h
ant [options] [target [target2 [target3] ...]]
Options:
-keep-going, -k execute all targets that do not depend
on failed target(s)
Here Ant would report the failing tasks/targets and try the next target which
dont rely on a prior successful target.
It is not unusual to keep the failure-status in a property and react on that.
<target name="test" depends="compile">
<junit failureproperty="junit.failed"
<target name="checkstyle">
<cs:checkstyle failOnViolation="false"
failureProperty="checkstyle.failed"
<target name="pmd">
<pmd:pmd failuresPropertyName="pmd.failed"
<target name="findbugs">
<fb:findbugs errorProperty="findbugs.failed"
<target name="metrics" depends="-checkmetrics" unless="metrics.failed">
<echo>All metrics passed</echo>
</target>
<target name="-checkmetrics" depends="test,checkstyle,pmd,findbugs">
<condition property="metrics.failed"><or>
<isset property="junit.failed"/>
<isset property="pmd.failed"/>
<isset property="findbugs.failed"/>
<isset property="checkstyle.failed"/>
</or></condition>
</target>
Jan
> -----Ursprüngliche Nachricht-----
> Von: John5342 [mailto:[EMAIL PROTECTED]
> Gesendet: Donnerstag, 2. Oktober 2008 21:39
> An: Ant Users List
> Betreff: Re: How to stop ant execution if one target fails
>
> If the names of the targets are indeed what they do then most
> of them should
> probably always be done in a particular order in which case
> make each one
> depend on the next similar to the following.
>
> <target name="jar" depends="build" ....>
> ....
> </target>
>
> Then if you were to run "ant jar" then build will be automatically run
> before jar and if build fails then jar will not be run. You
> should be able
> to do this for most of your targets and then all required targets will
> always be automatically run and you only call the target you
> actually need.
>
> Hope that helps you.
>
> John.
>
> 2008/10/2 Dean Del Ponte <[EMAIL PROTECTED]>
>
> > I'm using ant to build my project. When running ant from
> the command line,
> > I'm passing in multiple targets. For example:
> >
> > ant -verbose clean build jar findbugs pmd
> >
> > Ant will execute the targets clean, build, jar, findbugs,
> and pmd in that
> > order.
> >
> > My problem is that if one of the targets fail, ant
> continues with the next
> > target. I would like it to stop execution if one fails.
> >
> > For example, if the "jar" target fails, ant should not call
> the findbugs
> > and pmd targets.
> >
> > Any help is appreciated.
> >
> > Dean Del Ponte
> > Software Consultant, Cornerstone Consulting, Inc.
> > www.cornerstone.net
> > Our Experts. Your Edge
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]