简体   繁体   中英

In an ANT build.xml file, how can I iterate over the items in the ${env} variable?

This is in a Windows XP environment.

I'm trying to install and edit some files that have default settings. I want to update these settings use items from ${env}

Using foreach from ant-contrib , you could iterate over ${env} like:

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

I was able to do this with NAnt:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM