I have a set of goals, each of which does essentially the same thing, except for each, contains a specific patternset on which its tasks are performed. I want to collapse these goals into one "reusable" target, which instead accepts a set of files "as a parameter."
For example, this
<target name="echo1">
<foreach item="File" property="fn">
<in>
<items>
<include name="*.config"/>
</items>
</in>
<do>
<echo message="${fn}" />
</do>
</foreach>
</target>
<target name="echo2">
<foreach item="File" property="fn">
<in>
<items>
<include name="*.xml"/>
</items>
</in>
<do>
<echo message="${fn}" />
</do>
</foreach>
</target>
<target name="use">
<call target="echo1"/>
<call target="echo2"/>
</target>
will be replaced by
<patternset id="configs">
<include name="*.config"/>
</patternset>
<patternset id="xmls">
<include name="*.xml"/>
</patternset>
<target name="echo">
<foreach item="File" property="fn">
<in>
<items>
<patternset refid="${sourcefiles}"/>
</items>
</in>
<do>
<echo message="${fn}" />
</do>
</foreach>
</target>
<target name="use">
<property name="sourcefiles" value="configs"/>
<call target="echo"/>
<property name="sourcefiles" value="xmls"/>
<call target="echo"/>
</target>
, refid , nant-dev, , , echo, patternset ${sourcefiles}, test.
NAnt-, ? NAnt as-is, ?