ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Angeshwar Deepak <angesh...@yahoo.com>
Subject RE: How to set global properties thro for-each loop?
Date Tue, 03 Aug 2004 13:52:06 GMT
Hi,

Thanks a lot, but this works fine for me too. The
problem is I want to make the thing work, without
making use of 

<antcall target="init-props1" />

i.e. 
when Ant goes to the next target by default without a
antcall, it is not able to recognise the property set.
The new target recognises the property only if u use
an ant call and jump to a new target.

Try this and it may not work

<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>

U will see that the loop runs 2 times and only then
comes to the next target. So when it comes to 
init-props1 it simply prints ${loop.var}.

Why I want to avoid an antcall is that-I use a unless
and default which calls the top most ant target. This
results in an infinite loop!!!So I should avoid
antcall.

Anyway I am trying to solve the problem by writing a
property file outside and calling that in the build
file.

bye,
with regards,
Deepak.

--- "Inger, Matthew" <Inger@Synygy.com> wrote:

> 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
> 
> 



		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
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


Mime
View raw message