ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn McAllister <>
Subject Re: removing directories
Date Tue, 23 Jan 2001 19:58:11 GMT
Josh Sugnet wrote:

> Nico,
>     thank you for the clarification, but I dont think I was clear enough in my
> original post on what I am trying to do.   Abetter examples is the following.
> Suppose I have a directory named src in which I have a large source module
> checked out from a CVS repository.  At every directory level in the src
> directory tree, there is a CVS directory.  In shell, removing all these CVS
> direcoties from the source tree without removing any of the source files and
> directories can be done easily by doing a find and piping it to rm, something
> like `find src -name "CVS"|xargs rm -rf`.    The src module is left behind
> intact, only all of the CVS directories are removed.  What is the best way to
> do this same operation in ant?  It seems like the fileset element only allows
> you to specify patterns of files and not directories.   Any info is
> apprecieated.

What you are trying to do isn't supported in 1.2.  It is in 1.3alpha as of

Lets assume you have your source tree rooted in ${src.dir}.  So, to get rid of
all the files in the CVS directories you would do the following:

  <fileset dir="${src.dir}" usedefaultexcludes="no">
    <include name="**/CVS/**" />

The usedefaultexcludes attribute controls whether the set of things to exclude by
default are included when you create the fileset.  This comes from a lot of
source trees having CVS directories that we just never want to copy.  However,
there is the odd time when you want *everything*.  In that case, use the
usedefaultexcludes attribute.

Unfortunately, it leaves the CVS directories behind.  In the current CVS version
of Ant, you could say

<delete includeEmptyDirs="yes">
  <fileset dir="${src.dir}" usedefaultexcludes="no">
    <include name="**/CVS/**" />

and that would do it.

The only other way to get the result you want with Ant 1.2 is to do the

<copy todir="${tmp.dir}">
  <fileset dir="${src.dir}" />        <!-- includes everything by default EXCEPT
cvs stuff -->

<delete dir="${src.dir}" />

<move todir="${src.dir}">
  <fileset dir="${tmp.dir}" />

Not nice, but it works.

Glenn McAllister

View raw message