在 ant 中,如何将目标应用于文件列表(没有 ant-contrib)? [英] In ant, how to apply a target on a list of files (without ant-contrib)?
问题描述
基本上,我想模拟 apply
任务,但不是将 executable
传递给它,我想传递一个 ant 任务并想出类似的东西:
Basically, I would like to mimic apply
task but instead of passing to it anexecutable
, I would like to pass an ant task and come up with something like:
<project>
<target name="my-task">
<!--target definition-->
<target/>
<target name="my-task-on-files">
<apply task="my-task">
<srcfile/>
<targetfile/>
<fileset dir="." includes="*.xml"/>
</apply>
</target>
</project>
问题是 apply
有 task
属性,但只有 executable
.
The problem is that apply
has to task
attribute but only executable
.
我需要一个不需要 ant-contrib
的解决方案.
I need a solution that doesn't require ant-contrib
.
推荐答案
在 ANT 中没有本机解决方案.这就是 ant-contrib 被发明用来解决的问题:-(
No native solution in ANT. This is the sort of problem ant-contrib was invented to solve :-(
基本上,ANT 旨在通过编写自定义任务来扩展以解决非标准构建问题......
Basically, ANT was designed to be extended by writing custom tasks to solve non-standard build problems....
就我个人而言,我认为一旦您的构建需要复杂的逻辑,就该嵌入成熟的编程语言了.我选择的工具是 groovy,因为它与 ANT 紧密集成.此外,我使用 ivy 来管理我的构建的第 3 方依赖项,因此自动将 groovy 添加到类路径是不行的艰辛.
Personally, I think once your build needs complex logic, it's time to embed a full blown programming language. My tool of choice is groovy, due to it's tight integration with ANT. Furthermore, I use ivy to manage my build's 3rd party dependencies, so automatically adding groovy to the classpath is no hardship.
这篇关于在 ant 中,如何将目标应用于文件列表(没有 ant-contrib)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!