我如何使用与价值观的Ant foreach迭代从一个文件? [英] How can I use an Ant foreach iteration with values from a file?

查看:269
本文介绍了我如何使用与价值观的Ant foreach迭代从一个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的蚂蚁建设环境,我必须做同样的任务,对一些项目。该 AntContrib的foreach任务是有用的。但是,列表是一个参数,在那里我居然有在文件列表中。我怎么可以遍历项目在文件中的蚂蚁的foreach样的方式?类似的信息(伪code):

In our Ant build environment, 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"/>

这篇关于我如何使用与价值观的Ant foreach迭代从一个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆