ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Pilz <>
Subject Re: Checking existence of a set of files
Date Mon, 21 Jul 2008 11:45:32 GMT

in old days I wrote a target which checks for the file, and then call 
this target with antcall for single or ant-contrib:foreach for lists of 
files. Example with the normal path (customize to your needs):

<target name="check.fileonpath">
     <fail unless="file" message="${file}"/>
     <property environment="env"/>
     <condition property="path" value="${env.PATH}">
         <isset property="env.PATH"/>
     <condition property="path" value="${env.Path}">
         <isset property="env.Path"/>

     <fail unless="path" message="Failure: PATH/Path not found while 
looking for ${file}"/>

     <available property="present" file="${file}" type="file" 

     <fail unless="present" message="Failure: File ${file} not found in 
     <echo message="Checked: ${file} found in PATH"/>

Than call this e.g. with antcall:

<antcall target="check.fileonpath">
	<param name="file" value="cl.exe"/>


<foreach target="check.fileonpath" list="..." param="file"/>


Lars Ræder Clausen schrieb:
> I use Ant to compile a Java module that depends on a number of jar
> files that cannot be built from within the same build file.  I have
> them all listed in a class path, but I'd like to have a precondition
> that fails if any of the jars listed do not exists -- makes the error
> much easier to understand. After perusing the Ant manual, I haven't
> seen anything that can do this.  The Available task only checks one
> file at a time, so I'd have to list all the files again. If it truly
> doesn't exist, I guess I'll have to build it myself, but it seems too
> basic to not exist. What obvious task/combination of conditions am I
> missing?
> Thanks,
> -Lars
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message