Search code examples
xmlantboilerplate

apache ant build.xml


Is it possible to create files on the fly using apache ant - currently I have my apache ant build.xml downloading all my JS script dependencies.

What I am want to do now is create some HTML templates is this possible. I cannot find a task or antlib that does this.

Can any point me in the correct direction?


Solution

  • It is possible to create files with Ant, FreeMarker provides an ant task for this. Its name is FreemarkerXmlTask, detail description and sample ant task is provided in the link.
    Please note that depending on the API version (mostly between 2.2 and later) the data model wrapping may result into Document(with NodeList) or Node(Free Marker variable .node), this meant some changes on the Free Marker Template we were writing.
    However if we are using Declarative Processing the changes required in the template would be less as we can process the data model by recursion (<#recurse>), need to adjust only few things e.g.the root node.

    i found the java doc very helpful to understand and use the task better - freemarker.ext.ant.FreemarkerXmlTask