【问题标题】:In an ANT build.xml file, how can I iterate over the items in the ${env} variable?在 ANT build.xml 文件中,如何迭代 ${env} 变量中的项目?
【发布时间】:2009-12-23 19:32:34
【问题描述】:

这是在 Windows XP 环境中。

我正在尝试安装和编辑一些具有默认设置的文件。我想使用 ${env} 中的项目更新这些设置

【问题讨论】:

  • 您为什么要这样做?请提供更多上下文。 Ant 不是一种脚本语言。

标签: windows ant iteration environment build.xml


【解决方案1】:

使用来自ant-contrib 的foreach,您可以迭代${env},例如:

<target name="run">
    <foreach item="String" in="${env.CLASSPATH}" delim=";" property="x">
        <echo message="${x}" />
    </foreach>
</target>

我可以用 NAnt 做到这一点:

<target name="run">
    <foreach item="String" in="${environment::get-variable('CLASSPATH')}" delim=";" property="x">
        <echo message="${x}" />
    </foreach>
</target>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2013-02-03
  • 2012-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-24
  • 1970-01-01
  • 2011-02-12
相关资源
最近更新 更多