How to inline (here-document) few java code lines into a Ant script ? Please an example ?
+6
A:
I don't believe you can sensibly do it for actual Java code, but I've had a lot of success doing this with Groovy. The Groovy Ant task documentation is pretty good. For example:
<groovy>
xmlfiles = new File(".").listFiles().findAll{ it =~ "\.xml$" }
xmlfiles.sort().each { println it.toString() }
</groovy>
(You can write Groovy in a much more Java-like fashion if you want to.)
Jon Skeet
2009-03-20 08:08:42
Exactly what I am looking for, thanks a lot.
TaintedLove
2009-03-20 10:06:04
+6
A:
You can add any BSF capable language to Ant, using the <script> tag, including Javascript, Groovy, JRuby etc.
The most Java-like of these is BeanShell, and is probably what you want.
Brian Agnew
2009-03-20 08:46:28