Reference - Ant Task

Description

Runs the apertoGenerator.

A run of the apertoGenerator comprises the following steps:

  1. The model file is parsed.
  2. All template files are parsed.
  3. For each match template, the matched model nodes are determined, the template is expanded for each matched node and the result is stored in the so called generated file.

If the generated file does not exist yet, it will be created. If the generated file already exists, it will be skipped or overwritten.

Parameters

Attribute Description Required
modelFile Location of the model XML file. Yes
destDir Location to store generated files. (The value of the file attribute of a template tag is relative to this directory.) Yes
createBackup If set to true, a backup copy with the suffix ".backup" is created for each file, which is touched by the apertoGenerator run. Defaults to false. No
cacheFile If you specify a cache file, the apertoGenerator will store the last modified timestamps of the model, the templates and the generated files. On the next run all generated files will be skipped, for which neither the model nor the templates have changed. No
verbose If set to true, the apertoGenerator prints more messages, what it is doing. Defaults to false. No
jacobeExeFile The location of the jacobe executable. If you supply the jacobeExeFile and the jacobeCfgFile the Jacobe code beautifier is run over each generated java file. No
jacobeCfgFile The location of the jacobe configuration file. If you supply the jacobeExeFile and the jacobeCfgFile the Jacobe code beautifier is run over each generated java file. No

Parameters specified as nested elements

You must supply at least one template file via the nested element <templates>, which is a normal Ant FileSet, see Examples.

If you generate XML files, the apertoGenerator will try to format those files. If the generated XML file refers to external DTDs, you need to add a nested <xmlMapping> to map the system id of the DTD onto a real file like this:

<xmlMapping systemId="foo:/bar-2004" file="${dtd.dir}/bar.dtd" />

Examples

Here is an example, how you can integrate the apertoGenenerator into a build.xml file for Ant:

    <taskdef name="generator" classname="net.sourceforge.apertogenerator.GeneratorTask">
        <classpath location=".../apertoGenerator-2.5.1-all.jar" />
    </taskdef>

    <generator destDir="${src.dir}" modelFile="mda/model.xml" cacheFile="generator.cache">
        <templates dir="mda/templates" includes="*.tpl" />
    </generator>
    

You should always execute the generator before you compile. That's what MDA is all about.