ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominique Devienne" <>
Subject RE: Counting files in a dir
Date Wed, 06 Apr 2005 13:57:23 GMT
> From: Fermin Da Costa Gomez []
> Maybe i did not explain my requirement well enough.
> The thing is that i am looping through a series of dirs and *if* they
> contain 1 or more TestStubs they need to be put in a suite.
> ...
> <foreach list="${dirs}" target="-unitTestSuite" param="dir"
> delimiter="${path.separator}" />
> ...
> <target name="-unitTestSuite">
>  <if>
>   .. Check how many files are stubs ..
>   <equals arg1="noOfFiles" arg2="0" />
>    <then>
>     <echo message="Source dir not to be included" />
>     .. and go back to the caller, *no processing*
>    </then>
>    <else>Do some processing</else>
>   </if>
> </target>
> The above snip is what i have in mind. Does it look sensible or am i
> missing some significant ant thing ;-)

The scenario you describe seem to point to file selectors. In Ant, you
usually don't loop on dirs, doing some conditional processing within the
loop, you select all the files to process using <fileset>s, which with
selectors can do this selection on just about any criteria, and then you
process this list of files unconditionally.

For example, since your example is around unit testing, I use <junit>
with a <batchtest>, which contain <fileset>s with custom selectors to
select only some tests, based on various criteria.

I'm not sure it applies to you, but I'd say it's the canonical way to do
this kind of things in Ant. --DD

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

View raw message