开发者

What is the core difference between ant-contrib's for and foreach?

What is the main difference between for and for each. I am working with websphere mqfte to transfer files using ant scripts.

I need my files to renamed and send to another folder as below :

eg: src : \src\*.txt the files in destination should be \dest\kk_*.cpp (The * indicates the filename. Need all the files to to renamed as follows开发者_如何学JAVA).

Can anyone help me on this???.


The main difference between for and foreach task from antcontrib =

for uses sequential like macrodef whereas foreach opens a new project scope for each iteration - like other tasks as ant, antcall, and subant.

That means because of performance issues the use of for task should be favored.

For your renaming problem => you should use copy or move task with a nested mapper as already stated by other fellows. What's the reason to act against standard ant usage !?

btw. because antcontrib development seems to be dead - last release back in 2006 : there's a new ant addon with similar features => ant flaka


Use the copy task with a glob or regexp mapper. Don't know what for and for each have to do with this question, though.


The for and foreach tasks are not part of core Ant, most likely they are the ones in the ant-contrib collection.

According to the ant-contrib for task docs:

This task is the same as the <foreach> task, except that

* it uses a nested sequential for each iteration; and
* it implements an additional "keepgoing" attribute. 

<for> makes use of ant's macrodef task, so the @{} notation is used for parameter substition.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜