如何将 Ant foreach 迭代与文件中的值一起使用? [英] How can I use an Ant foreach iteration with values from a file?

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

问题描述

在我们的 Ant 构建环境中,我必须对许多项目执行相同的任务.AntContrib foreach task 对此很有用.但是,列表在一个参数中,我实际上在文件中拥有列表.如何在 Ant 中以类似 foreach 的方式迭代文件中的项目?类似(伪代码):

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天全站免登陆