ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: Possible bug in Delete task
Date Thu, 04 Jul 2002 09:02:12 GMT
On Sun, 30 Jun 2002, Diane Holt <> wrote:

> A user posted a question about using <delete> with
> 'includeEmptyDirs' set, and from looking at, I don't see
> it ever handling this -- but the doc seems to say it can (but maybe
> I missed how it's supposed to work).

The task assumes that your include pattern matches the directories to
remove - i.e. the dirs are part of getIncludedDirectories.

Let's say you have

<delete includeemptydirs="true">
  <fileset dir="foo">
    <include name="**/*.java" />

and a structure like


Is bar going to be removed?  If yes, why?  If not, why not?

I'm not saying that the task's current behavior is correct, just that
it is one possible interpretation among several alternatives.  We
probably have to understand which behavior we want and document (and
potentially implement) it.

> I've modified so it does it now, but I had to do some
> (maybe kind of weird?) things to get the potentially empty
> directories from the fileset into the "dirs" array

Hmm, yes.  Some points.

Your code uses Java 2 collection methods, no big deal.

You can avoid reversing the directory list you are putting together by
using Vector#insertElementAt(obj, 0) instead of Vector#add(obj).
After that you are done with two straight System.arraycopy calls.
Performance may suffer, but it looks cleaner.

I didn't actually scan for it, but some of your lines didn't look
properly indented.  You are not using tabs, are you? 8-)

You'd probably have to ensure you are not adding directories that are
explicitly excluded by accident.  Something like

<delete includeemptydirs="true">
  <fileset dir="foo">
    <include name="**/*.java" />
    <exclude name="baz" />

Your code would delete baz.


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

View raw message