【问题标题】:Read one word line from a text file and store that in a variable in ant build file从文本文件中读取一个字行并将其存储在 ant 构建文件中的变量中
【发布时间】:2016-03-22 20:31:43
【问题描述】:

请在下面找到示例 ant 文件:-

<taskdef resource="net/sf/antcontrib/antlib.xml">
    <classpath>
    <pathelement location="../.ant/antcontrib.jar"/>
    </classpath>
    </taskdef>
    <loadfile property="file" srcfile="./dist/DB_Critical_Stub_Data.txt"/>
    <target name="read" depends="check-stub-status">
    <for param="line" list="${file}" delimiter="${line.separator}">
    <sequential>
    <antcall target="start-stub">
    </antcall>
    </sequential>
    </for>
    </target>
    <target name="start-stub">
    <startStub domain="..." environment="..." name="@{line}" securityToken="..." serverURL="..." dedicatedEngine="false"/>
    </target>

只要循环运行,我如何在名称中输入值(在 start-stub 目标下)。换句话说,param="line" 应该在每次从文本文件中读取一行时将值填充到名称字段中。由于文本文件有 15 行,每行是一个单词,所以 param="line" 无论如何都只存储每一行​​单词。我希望将它传递给整个循环的 start-stub 目标下的 name 字段,以便为 name 执行所有 15 行单词。

【问题讨论】:

    标签: ant build.xml ant-contrib


    【解决方案1】:

    我实际上使用 foreach 使其工作,然后将 "${line}" 传递给名称字段。 为此,我还删除了 antcall target 并在 foreach 语句中简单地引用了 target="start-stub" 。 现在可以使用了

    【讨论】:

      猜你喜欢
      • 2017-11-05
      • 2020-02-09
      • 2020-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-22
      • 1970-01-01
      • 2020-08-11
      相关资源
      最近更新 更多