3 回答

TA貢獻1851條經(jīng)驗 獲得超4個贊
簡短答案
<foreach>與嵌套一起使用<FileSet>
Foreach需要ant-contrib。
更新了最近的ant-contrib示例:
<target name="foo">
<foreach target="bar" param="theFile">
<fileset dir="${server.src}" casesensitive="yes">
<include name="**/*.java"/>
<exclude name="**/*Test*"/>
</fileset>
</foreach>
</target>
<target name="bar">
<echo message="${theFile}"/>
</target>
這將用$ {theFile}調(diào)用目標“欄”,生成當前文件。

TA貢獻1829條經(jīng)驗 獲得超7個贊
基本上,由于沒有<java>的擴展(還可以嗎?),與<apply>擴展<exec>的方式相同,他建議使用<apply>(當然也可以在命令行中運行Java程序)
這里有一些例子:
<apply executable="java">
<arg value="-cp"/>
<arg pathref="classpath"/>
<arg value="-f"/>
<srcfile/>
<arg line="-o ${output.dir}"/>
<fileset dir="${input.dir}" includes="*.txt"/>
</apply>
- 3 回答
- 0 關(guān)注
- 751 瀏覽
添加回答
舉報