ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilbert Rebhan <...@schillbaer.de>
Subject Re: Set value if directory exists
Date Fri, 11 Sep 2009 16:14:32 GMT
Mikael Petterson schrieb:
> Hi,
> 
> How can I set the value of out.dir to /local/tmp/ if it exists.
> Currently  the second option when /tmp exists set the value out.dir  to
> /tmp/myuser
> 
> I know that /local/tmp exists.
> 
> //mike	
> 
> 	<available property="out.dir" value="/local/tmp" type="dir"
> file="/local/tmp" />
> 	<available property="out.dir" value="/tmp/${user.name}"
> type="dir" file="/tmp" />
> 	<property name="out.dir" location="." />


hi, problem is that the <available> task overwrites your property
out.dir, means it's set to /local/tmp first and then overwritten with
/tmp/${user.name}


example =

<available property="out.dir" value="/local/test" type="dir"
file="/local/test" />

<echo>nr.1 $${out.dir} == ${out.dir}</echo>

<available property="out.dir" value="/home/${user.name}" type="dir"
    file="/home/${user.name}" />

<echo>nr.2 $${out.dir} == ${out.dir}</echo>


output =

 [echo] nr.1 ${out.dir} == /local/test
[available] DEPRECATED - <available> used to override an existing property.
[available]   Build file should not reuse the same property name for
different values.
     [echo] nr.2 ${out.dir} == /home/gilreb



didn't know that available task behaves against standard ant
conventions (property immutability)
last setting of the property wins, try to use different
propertynames for your available tasks.

didn't you get a similar output "deprecated ...", which ant version
did you use ?



Regards, Gilbert

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


Mime
View raw message