ant-user mailing list archives

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

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>
     <condition property="path" value="${env.Path}">
         <isset property="env.Path"/>
     </condition>

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

     <available property="present" file="${file}" type="file" 
filepath="${path}"/>

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

Than call this e.g. with antcall:

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

or

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

Cheers,
André

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: 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


Mime
View raw message