In ant, how to apply a target on a list of files (without ant-contrib)?

*爱你&永不变心* 提交于 2019-12-23 21:24:28

问题


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>

The problem is that apply has to task attribute but only executable.

I need a solution that doesn't require ant-contrib.


回答1:


No native solution in ANT. This is the sort of problem ant-contrib was invented to solve :-(

Basically, ANT was designed to be extended by writing custom tasks to solve non-standard build problems....

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.



来源:https://stackoverflow.com/questions/9278022/in-ant-how-to-apply-a-target-on-a-list-of-files-without-ant-contrib

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!