ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject RE: <foreach> & <propertycopy> (was 'RE: Automated source config model?')
Date Fri, 06 Sep 2002 16:37:42 GMT
In case you haven't found this yet, I just sent out a
link the other day.  Looking in the archives at my
recent posts ought to turn it up.

-Matt

--- "Vaughn, Julia" <Julia.Vaughn@cingular.com> wrote:
> Where is 'foreach' documented?
> 
> -----Original Message-----
> From: Dominique Devienne [mailto:DDevienne@lgc.com]
> Sent: Thursday, September 05, 2002 12:54 PM
> To: 'Ant Users List'
> Subject: RE: <foreach> & <propertycopy> (was 'RE:
> Automated source
> config model?')
> 
> 
> Two remarks:
> 
> 1) Normally <antcall> (used internally by <foreach>)
> passes properties to
> the called project automatically, but since it
> appears it's not in your
> case, try passing it explicitly. I discovered
> (yesterday actually!) that
> <foreach> supports nested <param>, as <antcall>
> does, although it's not
> documented. So try:
> 
> <target name="checkout-dirs"> 
>   <propertycopy name="complist"
> from="${component}.dirs" />
>   <propertycopy name="comptag" 
> from="${component}.tag" />
>   <foreach list="${complist}" target="checkout-dir"
> param="ckout.pkg">
>     <param name="comptag" value="${comptag}" />
>   </foreach>
> </target>
> 
> I assume you made sure comptag was property set by
> <propertycopy> in
> 'checkout-dirs'.
> 
> 2) 'checkout-dir-notag' might never be called, since
> <propertycopy> might
> define the comptag property anyhow, even if
> ${component}.tag doesn't
> exists???
> 
> Personnaly, since you're already using ant-contrib,
> I would simple have
> done:
> 
>   <target name="checkout-dir">
>     <if>
>       <isset property="comptag" />
>       <then>
>         <echo message="checking out ${ckout.pkg}
> with tag ${comptag}"/>
>         <cvs cvsRoot="${cvsRoot}"
>              dest="${src}"
>              command="co -P -r ${comptag}
> ${ckout.pkg}"/>
>       </then>
>       <else>
>         <echo message="NOTE: no tag defined for
> ${ckout.pkg}; checking out
> from main code line"/> 
>         <cvs cvsRoot="${cvsRoot}"
>              dest="${src}"
>             command="co -PA ${ckout.pkg}"/>
>       </else>
>     </if>
>   </target>
> 
> Hope this helps. --DD
> 
> -----Original Message-----
> From: Matt Lyon [mailto:matt@stargus.com] 
> Sent: Thursday, September 05, 2002 11:22 AM
> To: Ant Users List
> Subject: <foreach> & <propertycopy> (was 'RE:
> Automated source config
> model?')
> 
> DD,
> 
> Thanks for the information! The issue I was facing
> seemed to be due to
> property scope/flow control. I had placed a task to
> read in properties from
> an external properties file inside an init target,
> which did not allow the
> subsequent targets to work the <propertycopy> magic
> of expanding nested
> properties in that same property file which you so
> eloquently described. If
> I place the  <property file="config.properties"/> at
> the <project> level in
> my buildfile and not inside any target, that gets me
> past the problem.
> 
> However, I'm still stuck on a <propertycopy> issue.
> Using Matt McHenry's
> model again, if I have an external properties file
> that lists the following:
> 
> #The list of modules
> components=platform,ui,content
> 
> #The tag for the 'platform' module
> platform.tag=V1_0_6_183
> #The platform directories
> platform.dirs=starman/src/com/stargus/platform
> 
> #The tag for the 'ui' module
> ui.tag=V1_0_6_183
> #The ui directories
> ui.dirs=starman/src/com/stargus/web,starman/src/web
> 
> #The tag for the 'content' module
> content.tag=V1_0_7_184
> #The content directories
>
content.dirs=starman/src/com/stargus/platform/content
> 
> And a build.xml which contains the following target
> sequence:
> 
>   <!-- Targets to check out the souce code from CVS.
> --> 
>   <target name="checkout" 
>           depends="init" 
>           description="Checks out tagged directories
> listed in the
> build_config.properties file.">
>     <foreach list="${components}"
>              target="checkout-dirs"
>              param="component"/>
>   </target>
> 
>   <target name="checkout-dirs"> 
>     <propertycopy name="complist"
>                   from="${component}.dirs"/>
>     <propertycopy name="comptag"
>                   from="${component}.tag"/>
>     <foreach list="${complist}"
>              target="checkout-dir"
>              param="ckout.pkg"/>
>   </target>
> 
>   <target name="checkout-dir-tag"
>           if="comptag">
>     <echo message="checking out ${ckout.pkg} with
> tag ${comptag}"/>
>     <cvs cvsRoot="${cvsRoot}"
>          dest="${src}"
>          command="co -P -r ${comptag}
> ${ckout.pkg}"/>
>   </target> 
> 
>   <target name="checkout-dir-notag" 
>           unless="comptag">
>     <echo message="NOTE: no tag defined for
> ${ckout.pkg}; checking out from
> main code line"/> 
>     <cvs cvsRoot="${cvsRoot}"
>          dest="${src}"
>          command="co -PA ${ckout.pkg}"/>
>   </target>
> 
>   <target name="checkout-dir"
> depends=checkout-dir-tag,checkout-dir-no-tag"/>
> 
> 
> What I'm finding is that the ${complist} property
> value is passed to the
> checkout-dir tag as param ${ckout.pkg} with the
> expected <foreach>
> iterations performed, but the checkout-dir-tag
> target is never executed
> because the ${comptag} property value is either not
> getting defined by
> <propertycopy> or is not recognized by the
> checkout-dir composite target due
> to some sort of flow control or property scope
> issue. How can I force the
> setting and propagation of the ${comptag} property
> value to the subsequent
> targets?
> 
> Matt
> -----Original Message-----
> From: Dominique Devienne [mailto:DDevienne@lgc.com]
> Sent: Wednesday, September 04, 2002 5:43 PM
> To: 'Ant Users List'
> Subject: RE: Automated source config model?
> 
> 
> The <foreach> sets the 'component' param (not
> property, but the distinction
> is small), passed to the 'checkout-dirs' target.
> This target in turn doesn't
> use the 'component.dirs' property, it uses the
> 'component' property, to
> lookup the '${component}.dirs' property, where
> ${component} is resolved to
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

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


Mime
View raw message