ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stephan beal <>
Subject Re: how to test existance of file based on pattern
Date Thu, 21 Mar 2002 10:04:36 GMT
On Wednesday 20 March 2002 22:22 pm, you wrote:
> I have the following need that I couldn't work out by myself so far:
> - In order to fire a target I need to make sure at least one Test*.java
> exist anywhere in my test source hierarchy.
> Naively I tried the following rule, but without success because
> <available/> is only capable of testing the existence of a single well
> know file at once. <available/> does not support file pattern !
> <target name = "test_cases.exists">

> 	<!-- check that at least one Test*.java exist anywhere in the test
> source hierarchy -->
> 	<available file = "${src.test}/**/Test*.java" type = "file"
> property = "test_cases_exists"/>
> </target>

i don't believe the file attribute of <available> supports wildcards, as it's 
designed to look for ONE file. You could probably use a combination of the 
tips Dominique and Diane just showed us. Something like:

  <target name="doit" depends="check_for_testcases" 
    <echo message="files = ${files}"/>

  <fileset dir="${src.test}" id="fs"/>
<!-- i don't know the syntax for fileset, but there must be something which 
lets you add file wildcards to it -->

  <target name="check_for_testcases">
    <pathconvert pathsep="," property="files" refid="fs"/>
    <condition property="tast_cases.exist">
      <not><equals arg1="${files}" arg2=""/></not>

----- stephan
Generic Universal Computer Guy -
Office: +49 (89)  552 92 862 Handy:  +49 (179) 211 97 67
"I ain't gen'rally given to physicality of that nature but it saves
a lot of arguing." -- Nanny Ogg

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

View raw message