I would write a custom Ant task.
Once you start writing you own tasks you will find that Ant gets a lot more fun and easy to use. You don't need strange solutions that are hard to understand.
Once the task is written you would just do something like: