【问题标题】:Why my ant 'for' loop does not print "Test" ten times?为什么我的 ant 'for' 循环没有打印十次“Test”?
【发布时间】:2014-09-17 17:26:57
【问题描述】:

我正在尝试在 ant 中进行循环。我使用了 ant-contrib 'for'。我想从文件中读取来创建列表。我的文件(“CounterFile.txt”)只有数字 1 到 10,每行一个。从下面的“echo”命令中,我希望它打印“Test 1”、“Test 2”、..“Test 10”。但它只打印一次“测试”。谁能解释一下为什么会这样?

<target name="Start">
    <loadfile property="CounterFile" srcfile="./CounterFile.txt"/>
    <for param="count" list="${CounterFile}" delimiter="${count.separator}">
     <sequential>
        <echo>Test @{count}</echo>              
     </sequential>
    </for>
  </target>

【问题讨论】:

标签: for-loop ant ant-contrib


【解决方案1】:

只是偶然找到了解决方案。分隔符应该有 ${line.separator} 而不是 ${count.separator}。改变这对我有用! :-)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-23
    • 2022-01-16
    • 1970-01-01
    • 1970-01-01
    • 2021-12-25
    • 1970-01-01
    相关资源
    最近更新 更多