I have made a patch to do this:
<macrodef name="is-empty-file">
<attribute name="file" />
<fragment>
<and>
<available file="@{file}" type="file" />
<length file="@{file}" length="0" />
</and>
</fragment>
</macrodef>
http://issues.apache.org/bugzilla/show_bug.cgi?id=40678
Peter
On 9/27/06, Peter Reilly <[EMAIL PROTECTED]> wrote:
On 9/26/06, Matt Benson <[EMAIL PROTECTED]> wrote:
> Peter: as you are the father of macrodef your opinion
> was one I was very interested in getting. I'm not
> sure I understood your example below. Could you
> clarify, and maybe elaborate on any ideas you have of
> what we might try to make macrodef more generic (I
> assume you mean so that it would just "work"
> regardless of its "body" contents.
Yes,
I am not too sure about the mechanism, and there would
be naming issues (esp with regard to DynamicConfigurable and it;s ikk)
One maybe be able to do something like (taking examples from ant's
build.xml)
<macrodef name="trax.avail">
<element>
<or>
<and>
<isset property="
javax.xml.transform.TransformerFactory"/>
<available
classname="${javax.xml.transform.TransformerFactory}"
classpathref="classpath"/>
</and>
<available
resource="META-INF/services/javax.xml.transform.TransformerFactory"/>
</or>
</element>
</macrodef>
<condition property="trax.impl.present ">
<trax.avail/>
</condition>
- or -
<macrodef name="exec.includes">
<elements>
<include name="**/ant"/>
<include name="**/antRun"/>
<include name="**/*.pl"/>
<include name="**/*.py"/>
<include name="**/*.py"/>
</elements>
</macrodef>
<chmod perm="ugo+x" type="file" failonerror="${chmod.fail}">
<fileset dir="${dist.bin}">
<exec-includes/>
</fileset>
</chmod>
These are a bit lame, your example is better!
<macrodef name="isEmptyFile">
<attribute name="file" />
<elements>
<and>
<available file="@{file}" type="file" />
<length file="@{file}" length="0" />
</and>
</elements>
</macrodef>
The point is that this <macrodef> does not know about
the type (if any) of the tags in the <elements>, it a macro
more like c macros.
Peter
> Worth mentioning
> is the fact that macrodef's nested "sequential"
> appears to be a convention only; an actual Sequential
> object is not used; I'm thinking this is a good thing.
>
> Thanks,
> Matt
>
> --- Peter Reilly <[EMAIL PROTECTED] > wrote:
>
> > +1,
> > It would however be nicer to make macrodef
> > more generic. To inject the UEs into the macro
> > instance.
> >
> > Like:
> > <macrodef name="engine">
> > <attribute name="impl">
> > <dom>
> > <service
> > type="javax.script.ScriptEngineFactory"
> > provider="@{impl}"/>
> > </dom>
> > </macrodef>
> >
> > <jar jarfile="x.jar">
> > <fileset dir="classes"/>
> > <engine impl="org.me.SimpleLang"/>
> > </jar>
> >
> > Do not know if it is possible.
> > Peter
> >
> > On 9/26/06, Alexey Solofnenko <[EMAIL PROTECTED]>
> > wrote:
> > >
> > > +1 Good idea, Matt.
> > >
> > > - Alexey.
> > >
> > > On 9/26/06, Matt Benson <[EMAIL PROTECTED]>
> > wrote:
> > > >
> > > > It strikes me that we don't have a utility to
> > > > declaratively build custom conditions from
> > others;
> > > > macrodef would seem the obvious choice for,
> > e.g.:
> > > >
> > > > <macrodef name="isEmptyFile">
> > > > <attribute name="file" />
> > > > <sequential>
> > > > <and>
> > > > <available file="@{file}" type="file" />
> > > > <length file="@{file}" length="0" />
> > > > </and>
> > > > </sequential>
> > > > </macrodef>
> > > >
> > > > But the result amounts to a Task: executable,
> > but
> > > > unavailable for use where conditions would be
> > > > available.
> > > >
> > > > Would it make sense to allow this by allowing a
> > nested
> > > > <condition> as an alternative to <sequential>?
> > Then
> > > > cloning the MacroInstance class to
> > MacroCondition
> > > > implements Condition, for use when <condition>
> > is
> > > > specified? Cloning the entire
> > MacroDef/MacroInstance
> > > > family to have an entirely new task feels a
> > little
> > > > extreme to me here...
> > > >
> > > > Alternative suggestions?
> > > >
> > > > TIA,
> > > > Matt
> > > >
> > > >
> > __________________________________________________
> > > > Do You Yahoo!?
> > > > Tired of spam? Yahoo! Mail has the best spam
> > protection around
> > > > http://mail.yahoo.com
> > > >
> > > >
> >
>
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > > > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
> > > --
> > > Alexey N. Solofnenko trelony at gmail.com
> > > home: http://trelony.cjb.net/
> > > Pleasant Hill, CA (GMT-8 hours usually)
> > >
> > >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]