ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ninju Bohra <ninju_bo...@yahoo.com>
Subject Re: Directory question
Date Fri, 18 May 2007 05:16:52 GMT
Hello,

The fact the properties values are not propagated across <antcall> is by design...

One possible solution would be...

<target name="set_path" depends="determine_location, add_dir_one, add_dir_two"/>

<target name="determine_location">
    <available file="../lib" type="dir" property="use_dir_one" />
    <available file="../../lib" type="dir" property="use_dir_two" />
</target>

<target name="add_dir_one" if="use_dir_one">
    <property name="path_to_lib" location="../lib"/>
</target>
 
<target name="add_dir_two" if="use_dir_two">
    <property name="path_to_lib" location="../../lib"/>
</target>
 
Now, I don't like this solution but it works.

Later,

Ninju
----- Original Message ----
From: David Alves <dalves@brnphoenix.com>
To: user@ant.apache.org
Sent: Thursday, May 17, 2007 8:57:31 PM
Subject: Directory question


I'd like to include a lib directory in my classpath. The problem is I
don't know where the lib directory will be. It will either be ../../lib
or ../lib, relative to my current path. Is there a way to set a property
to whichever of those two exists?

For example:

/lib
/foo/build.xml
property would be set to ../lib


/lib
/foo/bar/build.xml
property would be set to ../../lib


Here's my attempt, but it doesn't work because properties set inside
subant tasks aren't set when subant exits.

      <target name="findcommon">
            <echo>Finding common directory...</echo>
            <available file="../../lib" type="dir" property="two_up" />
            <antcall target="two" />
            <antcall target="one" />
            <echo>Path to lib set to: ${path_to_lib}</echo>
      </target>

      <target name="two" if="two_up">
            <echo>Two folders up...</echo>
            <property name="path_to_lib" location="../../lib"/>
      </target>

      <target name="one" unless="two_up">
            <echo>One folder up...</echo>
            <property name=" path_to_lib" location="../lib"/>
      </target-->

Thanks in advance for your help!



Regards,

David Alves


       
____________________________________________________________________________________Sick sense
of humor? Visit Yahoo! TV's 
Comedy with an Edge to see what's on, when. 
http://tv.yahoo.com/collections/222

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


Mime
View raw message