Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
Directory question

Directory question

2007-05-17       - By David Alves
Reply:     1     2     3  

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




©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.