I had a similar need some time ago (to locate a lib dir too as a matter
of fact)...
Based on your example - you don't mention order of importance. I'll
assume you mean, choose ../../lib first if available otherwise choose
../lib if it's available...
<available file = "../../lib" type = "dir" property = "LIB_DIR"
value = "../../lib"/>
<available file = "../lib" type = "dir" property = "LIB_DIR"
value = "../lib"/>
So, above if ../../lib exists the property will be ../../lib - otherwise
it may be ../lib (if it exists)...
Point is, the property will be set to the correct directory - even if
both exists it will contain the first one that matched (thus my comment
about order of importance)...
Make sense?
David Alves wrote:
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
--
Scot P. Floess
27 Lake Royale
Louisburg, NC 27549
252-478-8087 (Home)
919-392-6730 (Work)
Chief Architect JPlate http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]