You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Wannheden, Knut" <kn...@paranor.ch> on 2003/03/19 15:18:14 UTC

templating buildfiles

Hi,

I am sure there are other users out there who manage some kind of templates
for Ant buildfiles.  I know that there are many ways to do this, ranging
from manual customization of a template, to using XML entities, through
fully automated template instantiation using a template engine.

I would like to use a template engine where I can set some variables which
are substituted in the template.  Also simple flow control mechanisms to
control what output is generated would be nice to have.

I have myself tried many different tools to use buildfile templates for our
software projects.  It has been quite frustrating at times and I have still
not found a tool that suits my needs perfectly.

I would like to use a templating engine like Velocity, FreeMarker, or JSP.
But they all seem to have their drawbacks and advantages.  Most template
engines either:
 - seem to have problems with the syntax of Ant properties (as the engines
think they're actually references to variables in the template language),
 - are limited to HTML and XML generation (OK, that's not really a problem
if it's only going to be used for Ant buildfiles),
 - are obscure enough in syntax to make the template unreadable to the point
where having a template doesn't make very much sense,
 - too heavyweight or hard to use standalone as they're entirely geared
towards web application development,
 - don't support dynamic templating (instead the templates have first to be
compiled to Java classes),
 - or of course a combination of the above.

So I've ended up using the JET engine from the EMF framework
(http://eclipse.org/emf/).  It has a JSP-ish syntax (<%=...%>) which doesn't
conflict with Ant properties (${...}).  Unfortunately some parts rely the
Eclipse runtime, so it's not trivial to use in standalone mode.  And there's
no documentation besides the source code.

I'd like to know what other Ant users think about buildfile templates, what
tools they use, and what experiences they've gathered.

Cheers,

--
knut