【问题标题】:Ant set list dynamically based on list size propertyAnt 根据列表大小属性动态设置列表
【发布时间】:2018-03-28 09:48:25
【问题描述】:

我有以下 Ant 脚本:

<target name="make-ears">
    <for list="1,2,3,4" param="clone-nr">
        <sequential>
            <!-- Do stuff -->
        </sequential>
    </for>
</target>

我更喜欢动态设置大小:

<property name="nr_clones" value="4" />

并且有类似的东西:

<for list="**1 to ${nr_clones}**" param="clone-nr"> <!-- ** Not working but would like to ** -->

【问题讨论】:

  • 你实际上想在循环中做什么?

标签: ant ant-contrib


【解决方案1】:

使用 Javascript 解决了这个问题:

<property name="nr_clones" value="4" />

<!-- Build list -->
<script language="javascript">
    <![CDATA[
    var start = 1;
    var end   = FileToJRKScheduler.getProperty("nr_clones");
    var list = start;
    for (i = parseInt(start) + 1; i <= end; i++) {
      list += "," + i.toString();
    }
    FileToJRKScheduler.setProperty("list_clones", list);
  ]]>
</script>

然后使用:

<for list="${list_clones}" param="clone-nr">

致谢:https://eureka.ykyuen.info/2014/01/17/apache-ant-iteration-within-a-specific-number-range/

【讨论】:

    猜你喜欢
    • 2015-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-21
    • 2014-12-10
    • 2020-01-08
    • 2020-11-02
    相关资源
    最近更新 更多