开发者

Is there a way to loop over files in ant without using ant-contrib?

I know ant-contrib ha开发者_开发问答s a for loop, but I'd rather avoid adding it to my project unless necessary. It feels like I'm missing something obvious here. I just want to execute a task for a lot of files.


If you are trying to run an external program on a bunch of files take a look at Ant's apply task.


Another option, especially if you're using Java 6, is to use <scriptdef>. A little JavaScript goes a long way.

(Theoretically <scriptdef> works prior to Java 6, but you have to include an interpreter for your selected scripting language. You might as well just use antcontrib then. Java 6 includes the Rhino JavaScript interpreter by default, so it's much easier to use.)

In fact, this is so easy to do I've found myself writing scripts for things that could be in Ant but are just very complex.


Probably the best and most complete option is to just write a <taskdef> for a Java class that you write that can do what ever you can think up. See the ant manual for more info on taskdef

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜