ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anthony W. Marino" <anth...@AWMObjects.com>
Subject Re: property: Understanding Of Setting Values
Date Sat, 25 May 2002 00:27:00 GMT
Gotcha!
Does <property> exhibit the same behavior?

Thanks,
Anthony

> --- "Anthony W. Marino" <anthony@AWMObjects.com> wrote:
> > I don't understand your answer.  Are you saying it does set or
> > doesn't/shouldn't set using the <available> task?
>
> I'm saying <available> will reset an already set property, under any
> circumstance, anytime -- but starting at Ant1.5Beta1, it will nag you
> about using it to reset the value of an already set property. For example:
>   <target name="naughty">
>     <available property="foo" value="value1" file="${ant.file}"/>
>     <echo>foo = ${foo}</echo>
>     <available property="foo" value="value2" file="${ant.file}"/>
>     <echo>foo = ${foo}</echo>
>     <available property="foo" value="value3" file="${ant.file}"/>
>     <echo>foo = ${foo}</echo>
>   </target>
>
> Running with <1.5Beta1 will get you:
> naughty:
>      [echo] foo = value1
>      [echo] foo = value2
>      [echo] foo = value3
>
> Running with 1.5Beta1 or later will get you:
> naughty:
>      [echo] foo = value1
> [available] DEPRECATED - <available> used to override an existing
> property.
> [available]   Build file should not reuse the same property name for
> different values.
>      [echo] foo = value2
> [available] DEPRECATED - <available> used to override an existing
> property.
> [available]   Build file should not reuse the same property name for
> different values.
>      [echo] foo = value3
>
> However, if the <available> was in a separate target, and you <antcall>'d
> (or <ant>'d) to it, then it won't nag you about it, because it's not in
> the same project anymore. As a legitimate example, say you had a
> requirement that all of three files needed to be found for the build to
> run -- you could do:
>   <target name="chkFiles">
>     <antcall target="chkFile">
>       <param name="file" value="foo.txt"/>
>     </antcall>
>     <antcall target="chkFile">
>       <param name="file" value="bar.txt"/>
>     </antcall>
>     <antcall target="chkFile">
>       <param name="file" value="blixen.txt"/>
>     </antcall>
>   </target>
>
>   <target name="chkFile">
>     <available property="allThere" file="${file}"/>
>     <fail unless="allThere" message="Missing file ${file}!"/>
>   </target>
>
> which, assuming foo.txt and bar.txt exist but blixen.txt doesn't, would
> get you:
>
> BUILD FAILED
> C:\TEMP\if.xml:78: Missing file blixen.txt!
>
> (Note: Using 'unless' in the <fail> task is only good for 1.5Beta1 or
> later.)
>
> Diane
>
> =====
> (holtdl@yahoo.com)
>
>
>
> __________________________________________________
> Do You Yahoo!?
> LAUNCH - Your Yahoo! Music Experience
> http://launch.yahoo.com

-- 
Anthony W. Marino
Pres./CTO, AWM Objects
email:	anthony@AWMObjects.com
phone:	(732) 610-2441


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