GppFilter

Description

Groovy Template-enabled filter for preprocessing.

GppFilter is an Ant filter that processes its input using the Groovy Template Engine. It can be used with any filter chain-capable tasks such as Copy, LoadFile, LoadProperties, and Move.

Note that for most preprocessing uses with Copy, GppCopy provides a handy shortcut.

Parameters

GppFilter does not currently have any parameters at this time.

Parameters Specified as Nested Elements

config

By specifying this nested element, you can configure the Groovy Template Engine and Context used when preprocessing. See GppConfig for a detailed description.

Examples

Note that there was a big change (for the better, IMHO) in Ant 1.6.x with respect to the treatment of non-builtin filters that allows them to be treated on par with builtin filters. As a result, configuration between 1.5.x and 1.6.x is different.

    <!-- Ant 1.6.x and later -->
    <copy todir="output" overwrite="true" >
      <fileset dir="${src}" includes="*.html.gpp" />
      <mapper type="glob" from="*.html.gpp" to="*.html" />
      <filterchain>
        <gpp:filter/>
      </filterchain>
    </copy>
	
    <!-- Ant 1.5.x and previous -->
    <copy todir="output" overwrite="true" >
      <fileset dir="${src}" includes="*.html.gpp" />
      <mapper type="glob" from="*.html.gpp" to="*.html" />
      <filterchain>
        <filterreader classname="groovytools.ant.gpp.GppFilter"/>
      </filterchain>
    </copy>

preprocess all files with a .html.gpp extension in the ${src} directory to the output directory with a .html extension.

    <!-- Ant 1.6.x and later (nested config) -->
    <copy todir="output" overwrite="true" >
      <fileset dir="${src}" includes="*.html.gpp" />
      <mapper type="glob" from="*.html.gpp" to="*.html" />
      <filterchain>
        <gpp:filter xmlns:gpp="antlib:groovytools.ant.gpp" >
          <config>
            <context>
              <property key="foo" value="bar"/>
            </context>
          </config>
        </gpp:filter>
      </filterchain>
    </copy>
    <!-- Ant 1.6.x and later (standalone config) -->
    <gpp:config id="gppconfig0">
      <context>
        <property key="foo" value="bar"/>
      </context>
    </gpp:config>

    <copy todir="output" overwrite="true" >
      <fileset dir="${src}" includes="*.html.gpp" />
      <mapper type="glob" from="*.html.gpp" to="*.html" />
      <filterchain>
        <gpp:filter xmlns:gpp="antlib:groovytools.ant.gpp" >
          <config refid="gppconfig0"/>
        </gpp:filter>
      </filterchain>
    </copy>
    <!-- Ant 1.5.x and previous -->
    <gpp:config id="gppconfig0">
      <context>
        <property key="foo" value="bar"/>
      </context>
    </gpp:config>

    <copy todir="output" overwrite="true" >
      <fileset dir="${src}" includes="*.html.gpp" />
      <mapper type="glob" from="*.html.gpp" to="*.html" />
      <filterchain>
        <filterreader classname="groovytools.ant.gpp.GppFilter">
          <param type="config" value="gppconfig0" />
        </filterreader>
      </filterchain>
    </copy>

preprocess all files with a .html.gpp extension in the ${src} directory to the output directory with a .html extension.