Tuesday, February 05, 2008

Code Generation under Apache Ant

I was using Perl scripts to do Java code generation with Apache Ant. Based on an XML file, we'd generate *.java files. The tricky part is implementing a clean target.

Ant makes it easy to do really simply things like compile java. It's quite a brain-bender to do other things.

The code generation outputs a text file with all the files that it created. Ant doesn't really have an easy way of duplicating what I would have done with Unix shell: /bin/rm `cat [file]`. It is further complicated by the deep path structure that Java likes to have for its packages.

The real way of doing it with ant was to copy the XML files into the build directory and code generate there. Then you can just remove the build directory.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home