Bug 23789 - warn if <delete task contains a fileset AND a dir attribute!! The content of dir is deleted before fileset's exclude is evaluated!!!
Summary: warn if <delete task contains a fileset AND a dir attribute!! The content of ...
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.6.0
Hardware: Other other
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL: http://ant.apache.org/manual/CoreTask...
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-13 17:02 UTC by Ralf Hauser
Modified: 2008-11-24 03:57 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Hauser 2003-10-13 17:02:43 UTC
I had a simple delete task
<delete dir="${build.dir}" includeEmptyDirs="true" />
and wanted to exclude something
  excludes="**/transform/**/*.* ${ASM_jar}"
Doing that I got the DEPRECATED error and added
  <fileset dir="${build.dir}">
    <exclude name="**/transform/*.class" />
    <include name="**/*.*" />
  </fileset>
resulting in
<delete dir="${build.dir}" includeEmptyDirs="true">
  <fileset dir="${build.dir}">
    <exclude name="**/transform/*.class" />
    <include name="**/*.*" />
  </fileset>
</delete>

BUILD FAILED
file:build.xml:667: WEB-INF/classes not found.

The exclude statement came too late and all its contents were already gone!

Suggested resolution:
if a nested fileset is present, warn about deleting what is specified in "dir"
Comment 1 Stefan Bodewig 2003-10-14 08:15:48 UTC
It is perfectly legal to use both the attribute and nested filesets, a warning may
even be annoying for users that do so on purpose.
Comment 2 Ralf Hauser 2003-10-14 09:00:24 UTC
under the "fail-safe" principle, how about warning anyway and have for this
delicate task "delete" a *expert* flag that suppresses the warnings!
Comment 3 Gus Heck 2003-10-15 16:09:08 UTC
From the manual entry for the dir atribute:

The directory to delete, including all its files and subdirectories.
Note: dir is not used to specify a directory name for file; file and dir are
independent of each other.
WARNING: Do not set dir to ".", "${basedir}", or the full-pathname equivalent
unless you truly intend to recursively remove the entire contents of the current
base directory (and the base directory itself, if different from the current
working directory).

Granted, it doesn't say that dir is independant of the filesets, but since
filesets have their own dir atribute it isn't that supprising. I'd say perhaps
clarify in the manual at most. But I think the current entry is fairly clear, so
maybe not even that.