如何将 Ant foreach 迭代与文件中的值一起使用?

发布于 2024-08-30 18:24:18 字数 432 浏览 2 评论 0原文

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

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

我很高兴编写自定义任务,并欢迎任何有关可能解决方案的建议。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寒冷纷飞旳雪 2024-09-06 18:24:18

我尝试将文件加载到属性中并对其进行迭代,对我来说效果很好:

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

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

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"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文