ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "broken connection" <brokenconnect...@gmail.com>
Subject Help with iteration in for loop
Date Tue, 03 Jul 2007 13:57:37 GMT
Hi Friends,
Is there any way to control iteration in ant. I want to put an if-else
condition in the for loop to control the action depending upon the iteration
count.I tried this:

build.xml
<project name="test" default="test_iteration">
 <taskdef resource="net/sf/antcontrib/antlib.xml" />
  <property name="prop_file" value="value.properties"/>

 <target name="test_iteration">
 <property file="${prop_file}"/>

 <for list="1,2" param="argvalue" >
    <sequential>
       <!-- use property file to increment counter -->
       <propertyfile file="value.properties">
           <entry key="count" type="int" operation="+" value="1" />
       </propertyfile>

   <echo>counter: ${count}</echo>

    </sequential>
 </for>

 </target>
</project>

value.properties file:
count=0

After I execute this,I get this as output:

C:\Documents and Settings\Desktop\test>ant
Buildfile: build.xml

test_iteration:
[propertyfile] Updating property file: C:\Documents and
Settings\hjhutty\Desktop
\test\value.properties
     [echo] counter: 0
[propertyfile] Updating property file: C:\Documents and
Settings\hjhutty\Desktop
\test\value.properties
     [echo] counter: 0

BUILD SUCCESSFUL
Total time: 1 second

value.properties=2

Can somebody explain me,why ${count} still displays 0 in the second
iteration,though the properties file has been updated.

Please help.
Thanks

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message