You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Norman Gray <no...@astro.gla.ac.uk> on 2009/08/06 20:03:46 UTC

taskdef and onerror -- possible ant 1.7.0 bug

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-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: taskdef and onerror -- possible ant 1.7.0 bug

Posted by Norman Gray <no...@astro.gla.ac.uk>.
Greetings.

On 2009 Aug 6, at 20:20, Stefan Bodewig wrote:

> This is not taskdef telling you off, it is fileset.  You'll need
> erroronmissingdir="false" on the fileset.

It turns out that @erroronmissingdir is a <fileset> attribute  
introduced in 1.7.1.

Hrumph.  I can't help feeling that the default for that should have  
been 'false', rather than 'true', but that's not an argument I fancy  
getting into.

Such is the joy of ant.  Thanks, Stefan, for this pointer.

Best wishes,

Norman


-- 
Norman Gray  :  http://nxg.me.uk
Dept Physics and Astronomy, University of Leicester, UK


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


Re: taskdef and onerror -- possible ant 1.7.0 bug

Posted by Stefan Bodewig <bo...@apache.org>.
On 2009-08-06, Scot P. Floess <sf...@nc.rr.com> wrote:

>> 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>
>> %

>> BUILD FAILED
>> /checkouts/skua.googlecode.com/trunk/code/qsac/test-build.xml:5:
>> /not/a/path not found.

This is not taskdef telling you off, it is fileset.  You'll need
erroronmissingdir="false" on the fileset.

Stefan

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


Re: taskdef and onerror -- possible ant 1.7.0 bug

Posted by "Scot P. Floess" <sf...@nc.rr.com>.
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-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@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-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org