tags:

views:

183

answers:

2

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
Exactly what I am looking for, thanks a lot.
TaintedLove
+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
precious informations, thanks a lot
TaintedLove