在Ant中为foreach循环读取多个文本文件,并将行值存储为不同的属性

时间:2016-03-25 00:53:02

标签: ant foreach ant-contrib

我对蚂蚁循环有要求。

它说我有3个不同的文本文件,每个文件有3行(每行是所有文件的单字符串)。

现在我需要Ant中的foreach循环,它同时读取每个文件中第一行的所有3个文件,并相应地将值存储为3个不同的属性。这种方式对于循环的每次迭代,我可以引用一个目标,我可以将这些属性传递给目标执行。

循环将运行3次,并且每次迭代执行该目标3次。

比如说我有以下示例代码: -

<target name="read">
<loadfile property="file" srcfile="./dist/DB_Critical_Stub_Data.txt"/>
<loadfile property="fileversion" srcfile="./dist/version.txt"/>
<loadfile property="filecomponent" srcfile="./dist/component.txt"/>
<foreach list="${file},${fileversion},${filecomponent}" param="line,line1,line2" delimiter="${line.separator}" target="start-stub"/>
 </target>
 <target name="start-stub">
  <property name="stub-name" value="${line}"/>
  <property name="stub-version" value="${line1}"/>
  <property name="stub-component" value="${line2}"/>
  <startStub name="${stub-name}" version="${stub-version}" component="${stub-component"}/>
</target>

此处的任何建议/帮助都将受到高度赞赏。

0 个答案:

没有答案