ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesse Glick <Jesse.Gl...@netbeans.com>
Subject Re: [PATCH] Several improvements to Zip and Jar tasks - comment
Date Fri, 18 Aug 2000 10:08:22 GMT
Shane_Curcuru@lotus.com wrote:
> Excellent point - I've been meaning to make a feature request for Ant:  add
> a '-k' flag a'la make: keep going in the face of errors.
> [snip]
> I think I like the idea of making this settable on each task.  On the
> grander scale, I'm not sure the best way for a user running Ant to set
> this.

Suggestion: as a (backwards-compatible) alternative to the "depends"
attribute of <target>, make an option to insert a nested <dependencies>
element, with subelements <dependency target="xxx"/> and so on. This is
more XML-ish anyway than a comma-separated list. Now add an optional
attribute to <dependency>, failonerror, a boolean. Default "true", in
which case behave as now (BuildException from a task cancels the build).
If "false", and the *dependency* target throws a BuildException, log it
at highest (error) level, but then continue and run the current target
anyway.

Advantages of this scheme:

- Failures in a task in the middle of a target will always cancel the
rest of the target. Since targets are usually the conceptual units and
need to be sequential, this only makes sense.

- Failure mode is placed in dependencies, not targets or tasks or
anywhere else, since the basic question is whether to continue or not,
and this is a property of the dependency. For example, one target may
require another to have been successful or it too will surely fail;
other targets may want the previous target to have been run, but can
proceed without it as well.

- If you really want just one task to be failure-insensitive, you can
easily break apart the target into a pre-target, a target with that
task, and a post-target, depend on all three with the middle dependency
"soft".

- Build script authors can specify exactly which dependencies should be
hard and which soft.

- But, if it could go either way, they may use e.g.:

	<dependency target="make-docs" failonerror="${production}"/>

which will force production builds to always complete, but be more lax
for test runs. You can choose some convention for this variable name and
use it for many dependencies if you like.

- Reasonably simple model for what the attribute controls: if false, Ant
will try to run this target first, but if it does not work, it will not
stop the build. If true, it will stop the build.

Another alternative, with no core changes required, is to make
<calltarget> or whatever this is called take an optional failonerror
parameter and otherwise behave as above: if false, build exceptions from
the subtarget are logged but not rethrown. I think the functionality is
essentially the same, so this might be more attractive. Or, give
<calltarget> further target-valued attributes such as 'catch' and
'finally' which would do the obvious things (run handler code in case of
a BuildException, and clean up after the target, resp.). But this is
arguably more confusing and there is no easy way to switch the
ignore-error mode on or off using properties, as with 'failonerror'.

Comments?

-Jesse

-- 
Jesse Glick   <mailto:Jesse.Glick@netbeans.com>
NetBeans, Open APIs  <http://www.netbeans.org/>
tel (+4202) 3300-9161 Sun Micro x49161 Praha CR

Mime
View raw message