You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Noel Sebastien (BIL)" <Se...@dexia-bil.com> on 2004/05/11 16:12:28 UTC

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 -->
</target>

<!-- 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}"/>
</target>

Thank you in advance.

Sébastien 


---------------------
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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Multiple directory existence checking

Posted by Rhino <rh...@sympatico.ca>.
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
at http://ant.apache.org/manual/index.html.

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.

Rhino

----- Original Message ----- 
From: "Noel Sebastien (BIL)" <Se...@dexia-bil.com>
To: <us...@ant.apache.org>
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 -->
</target>

<!-- 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}"/>
</target>

Thank you in advance.

Sébastien


---------------------
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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


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