开发者

How can I use an Ant foreach iteration with values from a file?

开发者 https://www.devze.com 2022-12-29 03:28 出处:网络
In our Ant build environment开发者_StackOverflow中文版, I have to do the same task for a number of items. The AntContrib foreach task is useful for that. However, the list is in a parameter, where I a

In our Ant build environment开发者_StackOverflow中文版, I have to do the same task for a number of items. The AntContrib foreach task is useful for that. However, the list is in a parameter, where I actually have the list in a file. How can I iterate over items in a file in an foreach-like way in Ant? Something like (pseudo-code):

<foreach target="compile-module" listFromFile="$fileWithModules"/>

I'm happy to write a custom Task, and welcome any suggestion on possible solutions.


I tried to load the file into a property and iterate over it, worked fine for me:

<loadfile property="file-content" srcFile="${fileWithModules}"/>

<foreach
    target="compile-module"
    list="${file-content}"
    delimiter="${line.separator}"
    param="your-param-used-in-target"/>
0

精彩评论

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

关注公众号