ForEach: How to use variables within foreach task.
Slickscorp <[email protected]> Tue, 12 Feb 2008 13:16:54 -0800 (PST)
| Newsgroups | gmane.comp.java.ant-contrib.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I have inserted 2 simplified versions of target I am using. I am
effectively trying to build a command line which will be passed to 'ssh'
based on a list of files. The problem is the 'param' does not seem to exist
outside the foreach list. For each iteration of the foreach list, I'd like
to keep the previously resulting 'param', but I dont get the desired
behaviour. I realise that I could make each of these work individually as
an ssh command but the output from ssh clutters the 'real-output', so I want
to call it as few times as possible to provide maximum readability.
<target name="brt-promote-build-command" >
<echo message="currin: ${current-command}" />
<if>
<equals arg1="${current-command}" arg2="" />
<then>
<var name="current-command" value="cd
\$$CVS/adg/${current-path} ; brt promote ${current-file}" />
</then>
<else>
<var name="current-command" value="${current-command} ; cd
\$$CVS/adg/${current-path} ; brt promote ${current-file}" />
</else>
</if>
<echo message="currout: ${current-command}" />
</target>
<target name="brt-promote" >
<var name="current-command" value="" />
<var name="current-path" value="${rel.proj.src}" />
<foreach list="MANIFEST ${files.proj.src}" param="current-file"
target="brt-promote-build-command" inheritrefs="true" inheritall="true"
delimiter=";" />
<var name="current-path" value="${rel.proj.src.config}" />
<foreach list="MANIFEST ${files.proj.src.config}"
param="current-file" target="brt-promote-build-command" inheritrefs="true"
inheritall="true" delimiter=";" />
<var name="current-path" value="${rel.infa.src.tools}" />
<foreach list="MANIFEST ${files.infa.src.tools}"
param="current-file" target="brt-promote-build-command" inheritrefs="true"
inheritall="true" delimiter=";" />
<if>
<equals arg1="${make-schedule}" arg2="yes" />
<then>
<var name="current-command" value="${current-command} ; cd
\$$CVS/adg/schedule ; brt promote schedule.xml" />
</then>
</if>
<echo message="${current-command}" />
<antcall target="brt-promote-exec" />
</target>
======== OUTPUT OF RUNNING THE SCRIPT IS BELOW
brt-promote:
brt-promote-build-command:
[echo] currin:
[echo] currout: cd \$CVS/adg/estimates/ibes/coverage ; brt promote
MANIFEST my first file list
brt-promote-build-command:
[echo] currin:
[echo] currout: cd \$CVS/adg/config/estimates/ibes/coverage ; brt
promote MANIFEST my second file list
brt-promote-build-command:
[echo] currin:
[echo] currout: cd \$CVS/adg/util/informatica ; brt promote MANIFEST my
third file list
[echo] ; cd \$CVS/adg/schedule ; brt promote MANIFEST schedule.dev.xml
I would like to see the resulting value for ${current-command}
cd \$CVS/adg/estimates/ibes/coverage ; brt promote MANIFEST my first file
list ; cd \$CVS/adg/config/estimates/ibes/coverage ; brt promote MANIFEST my
second file list ; cd \$CVS/adg/util/informatica ; brt promote MANIFEST my
third file list ; cd \$CVS/adg/schedule ; brt promote MANIFEST
schedule.dev.xml
Is there a simple way to do this?
Regards
--
View this message in context: http://www.nabble.com/ForEach%3A-How-to-use-variables-within-foreach-task.-tp15443269p15443269.html
Sent from the Ant Contrib mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/