【问题标题】:"for" task with "list" parameter in ant-contrib does not workant-contrib 中带有“list”参数的“for”任务不起作用
【发布时间】:2013-10-14 08:55:27
【问题描述】:

我的构建脚本中有这样的构造:

<for list="item1,item2,item3,item4" param="theparam">
    <!-- some stuff to do -->
</for>

执行脚本时,我得到:

For任务中使用的无效类型类net.sf.antcontrib.logic.ForTask,它没有公共的迭代器方法

我正在使用 ant-contrib 1.0b3。我在这里错过了什么?

【问题讨论】:

  • 我忘记了 ... 块。
  • 我只是做了同样的事情(嵌套循环,并没有考虑用顺序包装内部循环)。您应该将此作为答案并允许对其进行投票...我几乎忽略了此评论。

标签: for-loop ant ant-contrib


【解决方案1】:

无法重现您的问题。您使用的是哪个版本的 ANT?

示例

$ ant -version
Apache Ant(TM) version 1.9.0 compiled on March 5 2013

$ ant
Buildfile: /home/mark/build.xml

run:
     [echo] param: one
     [echo] param: two
     [echo] param: three
     [echo] param: four

BUILD SUCCESSFUL
Total time: 0 seconds

build.xml

<project name="ant-contrib-tasks" default="run">

    <taskdef resource="net/sf/antcontrib/antlib.xml"/>

    <target name="bootstrap">
        <mkdir dir="${user.home}/.ant/lib"/>
        <get dest="${user.home}/.ant/lib/ant-contrib.jar" src="http://search.maven.org/remotecontent?filepath=ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
    </target>

    <target name="run">
        <for param="theparam" list="one,two,three,four">
            <sequential>
                <echo message="param: @{theparam}"/>
            </sequential>
        </for>
    </target>

</project>

注意事项:

  • 特殊的“bootstrap”目标安装 ant-contrib 依赖项。

【讨论】:

    【解决方案2】:
    1. 确保ant-contrib 1.0b3.jar 存在于{ANT_HOME}\lib 目录中
    2. 确保这两行位于您的 build.xml 文件的顶部

    &lt;taskdef resource="net/sf/antcontrib/antcontrib.properties"/&gt;
    &lt;taskdef resource="net/sf/antcontrib/antlib.xml"/&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-22
      • 2014-08-24
      • 2011-07-04
      • 2013-12-05
      • 2014-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多