You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Mikael Petterson <mi...@ericsson.com> on 2009/09/11 13:22:21 UTC

Set value if directory exists

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="." />

Mikael Petterson
Software Designer


Ericsson AB, Stockholm, Sweden
Visiting address: Torshamnsgatan 42, Kista
Phone: +46 70 2673044 
E-mail: mikael.petterson@ericsson.com 




Re: Set value if directory exists

Posted by Gilbert Rebhan <an...@schillbaer.de>.
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


RE: Set value if directory exists

Posted by "Rebhan, Gilbert" <Gi...@huk-coburg.de>.

P.S. 

no =
<available file="/local/tmp" type="dir" property="out.dir" />
would set ${out.dir} = true but you want /local/tmp
therefore the use of the value attribute

<available property="out.dir" value="/local/tmp" type="dir"
file="/local/tmp" /> should work

maybe you don't have the appropriate rights on /local/tmp ?
Or the other <available> task is called earlier and the
out.dir property once set to /tmp/${user.name} is immutable


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


RE: Set value if directory exists

Posted by "Rebhan, Gilbert" <Gi...@huk-coburg.de>.
 
-----Original Message-----
From: Mikael Petterson [mailto:mikael.petterson@ericsson.com] 
Sent: Friday, September 11, 2009 1:22 PM
To: user@ant.apache.org
Subject: Set value if directory exists

/*
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="." />
*/

try =
<available file="/local/tmp" type="dir" property="out.dir" />


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