Is the path defined by default?
On Thu, 6 Aug 2009, Norman Gray wrote:
Greetings.
The @onerror attribute to <taskdef> doesn't seem to work as advertised. Is
this a bug (and whether it is or not, can anyone suggest a workaround?)
Consider the following build.xml
% cat test-build.xml
<project name='test'>
<path id='nonexistent.classpath'>
<fileset dir='/not/a/path' includes='jar.jar'/>
</path>
<taskdef name='task' classname='one.two.BuckleMyShoe' onerror='ignore'>
<classpath refid='nonexistent.classpath'/>
</taskdef>
</project>
%
Note that the classpath mentioned contains a non-existent directory, and note
the presence of the @onerror attribute. When run, I get:
% ant -version
Apache Ant version 1.7.0 compiled on July 18 2008
% ant -f test-build.xml
Buildfile: test-build.xml
BUILD FAILED
/checkouts/skua.googlecode.com/trunk/code/qsac/test-build.xml:5: /not/a/path
not found.
Total time: 0 seconds
%
<taskdef> is a variant of <typedef>, and the documentation for that
<http://ant.apache.org/manual/CoreTasks/typedef.html> says of @onerror:
The action to take if there was a failure in defining the type. The values
are fail: cause a build exception; report: output a warning, but continue;
ignore: do nothing. since Ant 1.6 An additional value is failall: cause all
behavior of fail, as well as a build exception for the resource or file
attribute if the resource or file is not found.since Ant 1.7 The default is
fail.
In the above case, there is indeed a failure to define the task (of course,
because the classpath doesn't exist), but the failure is not ignored.
I can't find any mention of this in the bugparade, searching for 'onerror'.
Can someone confirm that this is indeed a bug rather than an eccentric
feature (in which case I'll add a report to the bugparade).
Why, you may be asking, would I want to ignore this? The above error stops
ant working, even when the targets being built do not require the task in
question. In the real case, I want to build a project's documentation,
without installing all the support libraries required to build the actual
software.
Is there a workaround? I can't find any way of defining the path
conditionally, nor can I find a way of defining a property conditionally (in
the real case, the /not/a/path is the value of a property).
At the moment, the only workaround I have is to comment out this part of the
build.xml, and that's ... not easily automatable.
Thanks for any pointers. Best wishes,
Norman
--
Norman Gray : http://nxg.me.uk
Dept Physics and Astronomy, University of Leicester, UK
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org
Scot P. Floess
27 Lake Royale
Louisburg, NC 27549
252-478-8087 (Home)
919-890-8117 (Work)
Chief Architect JPlate http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim
Architect Keros http://sourceforge.net/projects/keros
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org