ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Wannheden" <>
Subject Re: [new tasks] presetdef and macrodef
Date Fri, 15 Aug 2003 15:35:35 GMT
> >
> > One thing you could do here is redefine <javac> itself
> > by doing something like:
> >
> >    <taskdef name="orig.javac" classname="org.ant.....Javac"/>
> >    <presetdef name="javac">
> > <orig.javac debug="${debug}" deprecation="${deprecation}"/>
> >    </presetdef>
> >
> > which would realize your desired effect. This could be done internally
> > by <presetdef/> when for example no name attribute is given.
> This could also be done by:
>     <presetdef name="javac">
>   <javac debug="${debug}" deprecation="${deprecation}"/>
>     </presetdef>

I was hoping that would be possible.

> You will however get a warning that the previous definition
> of javac has been overridden.
> I am thinking of adding an override attribute to allow suppressing
> this warning.

Sounds reasonable.

So instead of using a whole lot of standard user properties to make sure
that all tasks across all buildfiles use the same attribute values (e.g.
${debug}) I can simply <include> a presets.xml buildfile in every project.
Or maybe <presetdef>s could even be inherited when using <ant> or <subant>?

> >
> > It would be interesting to know what would happen if I write:
> >
> >    <my.javac debug="true"> ... </my.javac>
> >
> > would it use the value given in <presetdef> or that given in the actual
> > task? If the later, it means that the values given in <presetdef> would
> > default values for the task, which sounds much better.
> > Maybe we could rename it <defaultdef/>. :-)
> In this case what will happen is that javac#setDebug() gets called twice.
> First with the default value and second with "true". The effect
> this has depends on the task/type in question. Some tasks set a flag
> when an attribute is set and do not allow it to be set again.

Maybe not quite what one would expect.  But I suppose most tasks could be
rewritten to pick up the value when it's set the second time.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message