RE: "macrodef" for nested elements

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

RE: "macrodef" for nested elements

Dominique Devienne
> From: [hidden email] [mailto:[hidden email]]
> I would like a way to reduce the boilerplate load in a situation such

> this:
>    <tar destfile="${build.root}/statics.tar">
>        <tarfileset dir="${build.root}/images" prefix="images"
>                          username="myuser" group="mygroup"
> mode="664"
> dirmode="775"/>
>        <tarfileset dir="${build.root}/styles" prefix="styles"
>                          username="myuser" group="mygroup"
> mode="664"
> dirmode="775"/>
>        <tarfileset dir="${build.root}/userguide"
>                          username="myuser" group="mygroup"
> mode="664"
> dirmode="775"/>
>        <tarfileset dir="${build.root}/tutorial"

>                          username="myuser" group="mygroup"
> mode="664"
> dirmode="775">
>            <include name="*.swf"/>
> </tarfileset>
>        <tarfileset dir="$"
>            username="myuser" group="mygroup" mode="664"
> dirmode="775"/>
>            </tar>
> As you can see, all but one of the attributes of the tarfileset nested
> elements are boilerplate, repeated at every instance, but there is no
> way to default these.   I thought <macrodef> might provide some help
> here, but it doesn't, since macrodef only provides bits of runnable
> tasks, not nested sets of attributes.  A less flexible alternative,
> still preferable to the above, would be to provide default values for
> the nested elements in the outer <tar> task.  <tar> doesn't, at
> present, provide this functionality.  That might be doable through
> macrodef, but does macrodef allow variable numbers of nested elements?

Others have commented on the feasibility of using macrodef/presetdef,
both of which do not really apply to your problem, but I'm going to ask
for a dummy question ;-) Why not simply do something like this:

<tar destfile="${build.root}/statics.tar">
  <tarfileset dir="${build.root}" username="myuser"
              group="mygroup" mode="664" dirmode="775">
    <include name="images/**" />
    <include name="styles/**" />
    <include name="userguide/**" />
    <include name="tutorial/*.swf" />
  <tarfileset dir="$" username="myuser"
              group="mygroup" mode="664" dirmode="775"/>

Wouldn't that do exactly what you want, since the directory name under
${build.root} and the prefix you used are the same? --DD

To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]