tags:

views:

269

answers:

2

Hi all,

I'm trying to create myself a little build script to build a project for me - creating the desired directories, downloading any needed jars via Ivy/Maven and creating some stub files.

The stub files part is what I'm not too sure on what to do. To take an example, I would want the build script to create a web.xml in a WEB-INF folder. What would be the best way to do this though? The only way I know how is to have an echo to a file and then the build script containing my stub code.

Is there a better way than this that I don't know of?

+2  A: 

As I understand it, you're proposing using echo to write files like web.xml.

It might be better to have your Ant script invoke a templating engine, such as Apache Velocity. Texen can be used to generate arbitrary text.

McDowell
+2  A: 

If you're generating or modifying XML content in Ant, I'd recommend XMLTask. It can be used to create or modify XML files whilst ensuring well-formedness, entity and encoding issues etc. The problem with plain-text-based tools is that, although they will work in many cases, they have no awareness of the limits the XML standard requires and enforces.

See here for an article on how to use XMLTask.

Disclaimer: I'm the author, so I confess a certain bias :-)

Brian Agnew
That works a treat thanks Brian as I'm mainly using XML files here.
Lee Theobald