You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Dominique Devienne <DD...@lgc.com> on 2005/05/02 19:02:40 UTC
RE: "macrodef" for nested elements
> From: scohen@javactivity.org [mailto:scohen@javactivity.org]
>
> I would like a way to reduce the boilerplate load in a situation such
as
> 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"
prefix="userguide"
> username="myuser" group="mygroup"
> mode="664"
> dirmode="775"/>
> <tarfileset dir="${build.root}/tutorial"
prefix="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>
<tarfileset dir="$" username="myuser"
group="mygroup" mode="664" dirmode="775"/>
</tar>
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: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org