ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rhino" <>
Subject Re: Multiple directory existence checking
Date Tue, 11 May 2004 15:11:13 GMT
I'm not positive since I am still relatively new to Ant myself but I *think*
you need to use the "Available" task to determine if a given file or
directory exists. It is a core Ant task and is documented in the Ant manual

According to the article about "Available", it is also capable of setting a
property to true if the directory exists. The article gives an example of
this technique.

If you simply use a separate "Available" task to test for the existence of
each of the three directories and set a property to true for each of the
directories which exists, you're well on your way to a solution.

Then, use the "Condition" task, which is also a core Ant task, to ensure
that the compile only starts if  all three directories exist.

Again, I'm still a newbie myself but I think this approach should work.

I may give this a try myself but I thought I'd post this first to minimize
the time you have to wait for a suggestion. If I get my experiment to work,
I'll post the technique.


----- Original Message ----- 
From: "Noel Sebastien (BIL)" <>
To: <>
Sent: Tuesday, May 11, 2004 10:12 AM
Subject: Multiple directory existence checking

Hello everyone,

I am new to this list. I did not find the solution to my problem in the FAQ
or archive. It is : how to check the existence of several directories using
a base root directory and relative paths.

<target name="checkSources">
  <property name="rootDirectory" value="/PROD/ant/workingDir/"/> <!-- is the
root directory -->
  <property name="webJavaCompileFrom"
value="relativeDir1:relativeDir2:relativeDir2"/> <!-- relativeDirN is a
directory containing Java source. It is a relative path. Thus rootDirectory
+ relativeDirN is an absolute path to the dircetory -->
  <!-- HOW TO use available task -->

<!-- Here i would like to compile Java source only if
$rootDirectory/relativeDir1 AND $rootDirectory/relativeDir2 AND
$rootDirectory/relativeDir3 ALL exist. Namely how to set the
"sourcesPresent" used below -->
<target name="webJavaCompile" depends="checkSources" if="sourcesPresent">
 <javac srcdir="${webJavaCompileFrom}" destdir="${webJavaCompileTo}"/>

Thank you in advance.


An electronic message is not binding on its sender.
Any message referring to a binding engagement must be confirmed in writing
and duly signed.

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message