ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: Problems with foreach, target calls, missing properties
Date Fri, 18 Jun 2004 20:36:04 GMT
Paul:  Since you're already using <foreach> you're
obviously not averse to using ant-contrib. 
Some--myself included, for simplicity's sake--tend to
avoid it.  Anyway, the latest ant-contrib (I think
it's a dev version) will include <for>, which is a
macro-based iteration similar to <foreach>, but that
should retain set properties.

HTH,
Matt

--- "Reeves, Paul C" <pcreeve@sandia.gov> wrote:
> Folks,
> 
> I have a build file in which I iterate over a list
> and call another target
> in the same build file for each element in the list.
>  In the called-target I
> then set three properties.  However, when I return
> to the calling-target the
> properties are missing.
> 
> Does anyone understand how properties are affected
> by calling a target from
> the "foreach" task?  This behavior seems to violate
> what I thought I
> understood about property immutability, so there
> must be something I am
> missing.
> 
> Below is a snippet of code with the calling target
> (parse_config) and the
> called target (devl_version):
> 
>
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> 
>   <target name="parse_config" depends="set_file">
> ..
> ..
> ..
>         <!--Iterate over the dependency number set
> properties for -->     
>         <!--the dependencies of this project        
>              -->
> 
>         <foreach list       = "${dependency_list}" 
>                  delimiter  = ","
>                  param      = "dpd_name"
>                  target     = "devl_version"
>                  inheritall = "true"
>                  inheritrefs= "true"/>
> ..
> ..
> ..
> 
>     <echo message=" "/>
>     <echo message="After parse_config"/>
>     <echoproperties prefix="${build_project}"/>
>     <echo message=" "/>
> 
>   </target>
> 
>   <target name="devl_version">
>   
>     <!--This section of code increments a count of
> dependencies -->
>     <!--to embed in the property names              
>            -->
>     <property file = "count.txt"/>
> 
>     <var name="line_count" value="${count}"/>
>     <var name="incr"       value="1"/>
>     <var name="op"         value="+"/>
> 
>     <math result    = "result" 
>           operand1  = "${line_count}" 
>           operation = "+" 
>           operand2  = "${incr}" 
>           datatype  = "int"/>
>     
>      <!--Set properties for the dependency -->
>     <propertycopy
> name="${build_project}.dpnd.${result}.dir_root" 
>                   from = "${dpd_name}.dir_root"/>
>     <propertycopy
> name="${build_project}.dpnd.${result}.module"  
>                   from = "${dpd_name}.module"/>
>     <property    
> name="${build_project}.dpnd.${result}.version"  
>                   value = "devl"/>
>                   
>     <echo message=" "/>
>     <echo message="After devl_version"/>
>     <echoproperties prefix="${build_project}"/>
>     <echo message=" "/>
>     
>   </target>
> 
>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> HERE IS SOME OF THE OUTPUT...NOTE THAT THE THREE
> PROPERTIES THAT WERE SET IN
> THE CALLED TARGET (PGL.dpnd.1.dir_root,
> PGL.dpnd.1.module,
> PGL.dpnd.1.version)
> ARE MISSING WITH echoproperties IS CALLED FROM THE
> CALLING TARGET AFTER THEY
> HAVE
> BEEN SET
> ..
> ..
> ..
>      [echo] After devl_version
> [echoproperties] #Ant properties
> [echoproperties] #Fri Jun 18 13:39:46 MDT 2004
> [echoproperties] PGL.dpnd_projects=seismicBaseData
> [echoproperties] PGL.dpnd.1.dir_root=seismicBaseData
> [echoproperties] PGL.module=PGL
> [echoproperties] PGL.src.present=true
> [echoproperties] PGL.build_command=make
> [echoproperties] PGL.owner=jrhipp@sandia.gov
> [echoproperties] PGL.test_script=
> [echoproperties] PGL.proj_type=code
> [echoproperties] PGL.custom_build=true
> [echoproperties] PGL.language=CC
> [echoproperties] PGL.dpnd.1.module=seismicBaseData
> [echoproperties] PGL.dir_root=PGL
> [echoproperties] PGL.dpnd.1.version=devl
> 
>      [echo] After parse_config
> [echoproperties] #Ant properties
> [echoproperties] #Fri Jun 18 14:03:39 MDT 2004
> [echoproperties] PGL.dpnd_projects=seismicBaseData
> [echoproperties] PGL.module=PGL
> [echoproperties] PGL.build_command=make
> [echoproperties] PGL.owner=jrhipp@sandia.gov
> [echoproperties] PGL.test_script=
> [echoproperties] PGL.proj_type=code
> [echoproperties] PGL.custom_build=true
> [echoproperties] PGL.language=CC
> [echoproperties] PGL.dir_root=PGL
>      [echo]  
> 
> 
> Thanks a bunch,
> Paul
> 
> Paul C. Reeves, PhD
> 
> Sandia National Laboratories
> Department 5533:  
>   Next Generation Monitoring Systems
> 
> Mailing Address:
> Paul C. Reeves
> Sandia National Laboratories
> P.O. Box 5800
> Albuquerque, NM 87185-0451
> 
> pcreeve@sandia.gov
> (505) 844-4918
> (505) 844-9641 FAX
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



		
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
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