ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: <foreach> & <propertycopy> (was 'RE: Automated source config model?')
Date Thu, 05 Sep 2002 18:13:35 GMT
You can easily check for that case using:

<condition or if>
  <equals arg1="${comptag}" arg2="$${comptag}" />
</condition or if>

You could also use a pseudo-tag called 'head', and check for the value
specifically. And that would allow to add a

<fail message="..." unless="comptag" />

to fail with a nice message if comptag ends up really being not defined!

Cheers, --DD

-----Original Message-----
From: Matt Lyon [mailto:matt@stargus.com] 
Sent: Thursday, September 05, 2002 12:52 PM
To: Ant Users List
Subject: RE: <foreach> & <propertycopy> (was 'RE: Automated source config
model?')

Diane,

Yes it was. Thanks. However, I'm actually not out of the woods yet, as it
turns out, contrary to my previous response (a rush to irrational
exuberance, perhaps?).

I'm still wrestling with the ${comptag} property value. It appears that I
have a bit of a catch-22. It seems that I need to set the nested <param
name="comptag" value="${comptag}"/> element in my <foreach task> in my
"checkout-dirs" target to pass this along to the subsequent "checkout-dir"
target to get it to recognize the tags, because if I don't, the target sees
${comptag} as not defined and checks out from the main code line. However,
if I do so and comment out one of the ${component}.tag values in my
properties file, it causes the value to be passed in as ${comptag}, which
results in:
checkout-dir:
     [echo] checking out starman/src/com/stargus/web with tag ${comptag}
      [cvs] cvs [server aborted]: no such tag ${comptag}

Let me post the two targets I've got now:

  <target name="checkout-dirs"> 
    <propertycopy name="complist"
                  from="${component}.dirs"/>
    <propertycopy name="comptag"
                  from="${component}.tag"
                  silent="true"/>
    <echo message="complist is set to ${complist}"/>
    <echo message="comptag is set to ${comptag}"/>
    <foreach list="${complist}"
             target="checkout-dir"
             param="ckout.pkg">
      <!--param name="comptag" value="${comptag}"/-->
    </foreach>
  </target>

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

Basically, the requirement is that I need to be able to define named value
pairs (tags and srcdirs), have ant iterate over them, and checkout the
srcdirs from the defined tag, or from the main code line if the tag is not
defined. So I either need to figure out how to make isset in my <if> task
recognize when comptag is not set to a legitimate value or perhaps figure
out how to get ${comptag} passed without having to use a nested <param>
element.

Matt
-----Original Message-----
From: Diane Holt [mailto:holtdl@yahoo.com]
Sent: Thursday, September 05, 2002 1:38 PM
To: Ant Users List
Subject: RE: <foreach> & <propertycopy> (was 'RE: Automated source
config model?')


--- Matt Lyon <matt@stargus.com> wrote:
> That rocks! Thanks for the help. If I use your second suggestion in
> conjunction with my original "checkout-dirs" target (sans the nested
> <param> you suggested, which also works!) I get exactly the
> functionality I was looking for. I'm still a little puzzled as to why I
> needed the nested <param> element to pass ${comptag} to checkout-dir
> target explicitly in scenario 1, but since I have something that works
> now, I won't bother banging my head against that one right now. Thanks
> again...

When I fix the two typo's you had in your listing, this is what I get
(changed the <cvs> stuff to just echo out the 'co' command line):
checkout-dir-tag:
  command="co -P -r V1_0_6_183 starman/src/com/stargus/platform"

checkout-dir-tag:
  command="co -P -r V1_0_6_183 starman/src/com/stargus/web"

checkout-dir-tag:
  command="co -P -r V1_0_6_183 starman/src/web"

checkout-dir-tag:
  command="co -P -r V1_0_7_184 starman/src/com/stargus/platform/content"

That's what you wanted, right?

Diane

=====
(holtdl@yahoo.com)



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


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

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