ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Inger, Matthew" <In...@Synygy.com>
Subject RE: How to set global properties thro for-each loop?
Date Tue, 03 Aug 2004 13:30:54 GMT
I've tried this scenario with Ant 1.6.2, and AntContrib from CVS,
and it worked perfectly fine (without having the extra <property>
to set).

<project name="test" basedir="." default="init-props">

<taskdef resource="net/sf/antcontrib/antcontrib.properties">
  <classpath>
    <fileset dir="e:/home/inger/ant-contrib/build/lib" includes="*.jar" />
  </classpath>
</taskdef>

<target name="init-props">
  <foreach list="logging,appintegration"
           target="test.loop"
           param="loop.var"
           inheritall="true"
           inheritrefs="true"/>
</target>

<target name="test.loop">
   <echo message="TEST1: loop.var=${loop.var}" />
   <antcall target="init-props1" />
</target>


<target name="init-props1" >
    <echo>
      ********* Project home: ${loop.var}
    </echo>
</target>


</project>


Output:

Buildfile: test.xml

init-props:

test.loop:
     [echo] TEST1: loop.var=logging

init-props1:
     [echo]
     [echo]       ********* Project home: logging
     [echo]

test.loop:
     [echo] TEST1: loop.var=appintegration

init-props1:
     [echo]
     [echo]       ********* Project home: appintegration
     [echo]

BUILD SUCCESSFUL
Total time: 1 second


-----Original Message-----
From: Angeshwar Deepak [mailto:angeshwar@yahoo.com]
Sent: Tuesday, August 03, 2004 7:04 AM
To: user@ant.apache.org
Subject: How to set global properties thro for-each loop?




Hi,

I have modified my build file as

<target name="init-props">
<foreach list="logging,appintegration"
target="test.loop" param="loop.var" inheritall="true"
inheritrefs="true"/>
</target>

  <target name="test.loop">
   <echo message="TEST1: loop.var=${loop.var}" />
   <property name="loops.var" value="${loop.var}" />
   <antcall target="init-props1" />
</target>


    <target name="init-props1" >
	<echo>
	********* Project home: ${loops.var}
	</echo>
.....
</target>

This works perfectly fine.
But I dont want to specify the
   <antcall target="init-props1" />
statement but instead let ant directly come 
to the next target i.e. init-props1 and 
still hold the value of property loop.var

So I want something like this

<target name="init-props">
<foreach list="logging,appintegration"
target="test.loop" param="loop.var" inheritall="true"
inheritrefs="true"/>
</target>

  <target name="test.loop">
   <echo message="TEST1: loop.var=${loop.var}" />
   <property name="loops.var" value="${loop.var}" />

</target>

    <target name="init-props1" >
	<echo>
	********* Project home: ${loops.var}
	</echo>
.....
</target>

This does'nt work. i.e. I cannot see any
data for ${loops.var}. How to set the property in
such a case and continue to execute all the
tasks for each param in the for-each loop.

bye,
with regards,
Deepak.

=====
-----------------------------------------------
 
Deepak Angeswar, 

Home: 
Pfaffenwaldring 48 C / 202, 
70569 Stuttgart, Germany. 
Ph: 
Home: 049-0711-1225292 
Mobile: 049-0176-24039227 

Office: 
Work Student- 
DaimlerChrysler AG 
ITI/TP, 
Building R+V Gebäude, 
Eichwiesenring 14, 
70567 Stuttgart, Germany. 
Email Id: deepak.angeswar@daimlerchrysler.com



	
		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message