@page title="The Ant Task" keywords="ant, ant task">
<@sect title="Description">
If you need the FMPP Ant task in a project xml (<@c>build.xml@c>), use the <@c>taskdef@c> core task:
<@prg>@prg>
Then you can use the <@c><fmpp <@r>...@r>>@c> task further down. You may remember the 4th step of <@a href="qtour.html">Quick Tour@a>. This is an Ant equivalent:
<@prg><#noparse>
#noparse>@prg>
Almost all parameters of the Ant task correspond to the <@a href="settings.html">FMPP settings@a>. If the setting value is of scalar type (as string, boolean, number) then just enter the value simply with Ant-ish syntax, not with TDD syntax. If the setting value is of more tricky type, as hash or sequence, then use <@a href="tdd.html">TDD syntax@a> for it. For hash settings the value is <@a href="tdd.html#modes">hash mode TDD@a>, and for sequence setting it is sequence mode TDD, so the brackets should be omitted, as with <@s>data@s> above.
The <@a href="configfile.html#configurationBase">configuration base@a> for the setting values given with Ant parameters is the Ant project base directory. That is, if you enter <@c>sourceRoot="src"@c>, then <@c>src@c> is interpreted relatively to the project base directory.
There is no parameter that directly corresponds to the <@s>sources@s> setting. The sources are chosen with nested <@c><fileset>@c>-style parameters and nested elements (as <@c>include@c> and <@c>exclude@c>). However, if you use the <@s>outputFile@s> setting, you can't use <@c><fileset>@c>-style stuff, and <@s>sources@s> will be specified with the <@c>sourceFile@c> parameter.
Alternatively, the <@s>data@s>, <@s>localData@s>, <@s>borders@s>, <@s>modes@s>, <@s>turns@s>, <@s>xmlRenderings@s>, <@s>outputFormatsByPath@> and <@s>freemarkerLinks@s> settings can be specified with nested elements instead of parameters. For example, this is equivalent with the above example:
<@prg><#noparse>
tdd(data/style.tdd)
birds: csv(data/birds.csv)
#noparse>@prg>
This can be useful, if the setting value is long. The content of the element can be a CDATA section, which is useful if the setting value contains HTML or XML fragments. Unlike with attributes, Ant property interpolations (<@c>$${"{foo}"}@c>) in the text are not expanded, unless you force that with the <@c>expandProperties@c> attribute of the element (<@c><data expandProperties="yes"><@r>...@r>@c>).
About the support and interpretation of FMPP settings:
- The values of settings <@s>ignoreCvsFiles@s>, <@s>ignoreSvnFiles@s> and <@s>ignoreTemporaryFiles@s> are always set to <@c>false@c>, and there is no Ant task parameter for them. This is so that they don't interfere with Ant's standard <@c>defaultExcludes@c> parameter.
- Settings <@s>echoFormat@s>, <@s>printStackTrace@s>, <@s>snip@s> and <@s>columns@s> are ignored, and there is no Ant task parameter for them.
- The <@s>quiet@s> setting implements only grades <@c>true@c> and <@c>false@c>. <@c>reallyQuiet@c> is the same as <@c>true@c>.
- All <@a href="settings.html#logging">logging related settings@a> are supported.
To access the Ant properties and other Ant specific data in the templates, you can use data loaders such as <@c>antProperty()@c>, <@c>antProperties()@c>, <@c>antProject()@c> and <@c>antTask()@c>. Read the <@a href="dataloader.html">chapter about data loaders@a> for more details.
@sect>
<@sect title="Parameters">
The FMPP task accepts the following parameters:
- <@a href="settings.html">All FMPP settings@a> except <@s>sources@s>, <@s>ignoreCvsFiles@s>, <@s>ignoreSvnFiles@s>, <@s>ignoreTemporaryFiles@s>, <@s>echoFormat@s>, <@s>printStackTrace@s>, <@s>snip@s> and <@s>columns@s>. If the setting value is of scalar type (as string, boolean, number) then just enter the value simply with Ant-ish syntax, not with TDD syntax. If the setting value is of more tricky type, as hash or sequence, then use TDD syntax for it. For hash settings the value is hash mode TDD, and for sequence setting it is sequence mode TDD, so the brackets should be omitted. The <@a href="configfile.html#configurationBase">configuration base@a> for the setting values is the Ant project base directory.
- To follow the Ant conventions, <@c>srcdir@c> and <@c>destdir@c> attribute names can be optionally used instead of <@c>sourceRoot@c> and <@c>outputRoot@c> attribute names. These are just alias names.
- Configuration file handling:
- <@c>configuration@c>: Loads a <@a href="configfile.html">configuration file@a>. The setting values given with the parameters has higher precedence.
- <@c>configurationBase@c>: Emulates that <@s>configurationBase@s> meta setting is present in configuration file with the given value.
- <@c>inheritConfiguration@c>: Emulates that <@s>inheritConfiguration@s> meta setting is present in configuration file with the given value.
- Ant <@c><fileset>@c>-style attributes (see the Ant documentation for more details). Used for specifing the value of the <@s>sources@s> setting:
- <@c>dir@c>: The directory that the patterns are relative to. If this attribute is omitted, then the FMPP source root will be used as the base. Note that regardless of the value of this attribute, all source files must be inside the source root.
- <@c>casesensitive@c>: Sets case sensitivity of the file names. (Same as the FMPP setting)
- <@c>defaultexcludes@c>: Indicates whether default excludes should be used or not (<@c>"yes"@c> or <@c>"no"@c>); default excludes are used when omitted.
- <@c>excludes@c>: comma- or space-separated list of patterns of files that must be excluded; no files (except default excludes) are excluded when omitted.
- <@c>excludesfile@c>: the name of a file; each line of this file is taken to be an exclude pattern.
- <@c>followsymlinks@c>: Shall symbolic links be followed? Defaults to true.
- <@c>includes@c>: Comma- or space-separated list of patterns of files that must be included; all files are included when omitted. Note that be default all files of the source root directory are included.
- <@c>includesfile@c>: The name of a file; each line of this file is taken to be an include pattern.
- <@c>sourceFile@c>: It can be used only if the <@s>outputFile@s> setting is specified. It specifies the value of the <@s>sources@s> setting, as a simple string (not a comma separated list) that specifies the path of a single file. <@c><fileset>@c>-style attributes/elements will be ignored.
- <@c>antTaskFailOnError@c>: Specifies if the Ant task should fail if there were errors during the execution of the processing session. Defaults to <@c>true@c>. It has nothing to do with the <@s>stopOnError@s> setting. If this parameter is <@c>true@c>, the Ant task will fail if there were any failed file processing during the processing session, even if it was skipped because <@s>stopOnError@s> was <@c>true@c> (so the session wasn't aborted). If this parameter is <@c>false@c>, then the Ant task will be successful regardless of the failed file processings or other errors during the processing session, even if the processing session was aborted. But, it never suppresses errors occurred during the initialization of the FMPP engine (i.e. errors occurred before the processing session could be stated).
Either the <@c>configuration@c> parameter, or <@c>sourceRoot@c>+<@c>outputRoot@c> parameters, or <@c>sourceFile@c>+<@c>outputFile@c> parameters are required. All other parameters are optional. When you use <@c>configuration@c>, any Ant task parameters can become optional, when the value of the coressponding settings are given in the configuration file.
<@e>Attention!@e> When you specify the <@s>sources@s> setting in a configuration file, its value will be added to the set of files and directories that the Ant task itself selects, which is, following the Ant tradition, by default all files and directories inside the source root. Thus, usually you will want to exclude all files in the Ant task, so only those specified in the configuration file will remain:
<@prg>
@prg>
@sect>
<@sect title="Nested elements">
The FMPP task accepts the following nested elements:
- Elements for attribute substitution: Using these elements is the same as if you were use the attributes (parameters) with the same name, and with the same value as the nested text (or CDATA section) of the elements. Ant property values (<@c>$${"{foo}"}@c>) are not expanded by default, but you can override this with a <@c>expandProperties="yes"@c> attribute. Note that you either give a certain setting with attribute, or with element, but not both.
- <@c>data@c>
- <@c>localData@c>
- <@c>borders@c>
- <@c>modes@c>
- <@c>turns@c>
- <@c>xmlRenderings@c>
- <@c>outputFormatsByPath@c>
- <@c>freemarkerLinks@c>
- <@c><fileset>@c>-style elements (see the Ant documentation for more details):
- <@c>patternset@c>
- <@c>include@c>: Note that be default all files inside the source root directory are included.
- <@c>exclude@c>
- <@c>includesfile@c>
- <@c>excludesfile@c>
@sect>
<@sect title="Examples">
Run processing session with the settings stored in <@c><@r><projectBaseDir>@r>/config.fmpp@c> (or <@c>fmpp.cfg@c>):
<@prg><#noparse>
#noparse>@prg>
As the previous, but override <@s>outputEncoding@s>:
<@prg><#noparse>
#noparse>@prg>
Processes all files in <@c>src/www@c> and stores the output in <@c>build/www@c>:
<@prg><#noparse>
#noparse>@prg>
Same as the previous, but processes files with extension <@c>ftl@c> only:
<@prg><#noparse>
#noparse>@prg>
Same as the previous:
<@prg><#noparse>
#noparse>@prg>
Run processing session with the settings stored in <@c><@r><projectBaseDir>@r>/src/wwwconfig.fmpp@c>, but process files with extension <@c>ftl@c> only:
<@prg><#noparse>
#noparse>@prg>
Processes a single file:
<@prg><#noparse>
#noparse>@prg>
Exposes Ant properties <@c>foo@c>, <@c>bar@c> and <@c>baaz@c> for the templates:
<@prg><#noparse>
#noparse>@prg>
Just to show something more complex...:
<@prg><#noparse>
', '#escape>', **/*.ftl)
]]>
bgColor: white
fgColor: black
antProps: antProperties()
#noparse>@prg>
@sect>
@page>