ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daffin, Miles \(IT\)" <>
Subject RE: Delete the contents of a directory but not the directory itself
Date Fri, 12 Jan 2007 22:46:29 GMT
And to me. I assumed that when using delete with no dir attribute and a
nested fileset would not include the base dir. After all, if one uses a
fileset in the context of a copy this is what happens. Take this build
as proof:

<project name="test" basedir="." default="all">
  <property name="tmp.dir" value="tmp"/>
  <property name="from.dir" value="${tmp.dir}/fromdir"/>
  <property name="to.dir" value="${tmp.dir}/todir"/>
  <macrodef name="setup">
      <delete dir="${tmp.dir}"/>
      <mkdir dir="${from.dir}/dir1"/>
      <mkdir dir="${from.dir}/dir2"/>
      <touch file="${from.dir}/file1.txt"/>
      <touch file="${from.dir}/file2.txt"/>
  <target name="test-fileset-copy">
    <copy todir="${to.dir}" includeemptydirs="true">
      <fileset dir="${from.dir}"/>
    <available file="${to.dir}/fromdir" property="test.failed"/>
    <fail if="test.failed" message="fromdir copied to todir"/>
  <target name="test-fileset-delete">
    <delete includeemptydirs="true">
      <fileset dir="${from.dir}"/>
    <available file="${from.dir}" property="test.success"/>
    <fail unless="test.success" message="fromdir deleted!"/>
  <target name="all" depends="test-fileset-copy, test-fileset-delete"/>

I think that the way delete behaves here is wrong.

> -----Original Message-----
> From: Dominique Devienne [] 
> Sent: Friday 12 January 2007 20:47
> To: Ant Users List
> Subject: Re: Delete the contents of a directory but not the 
> directory itself
> > Explicitly saying includes="**/*" literally means only any file or 
> > directory below the basedir of the fileset.  Note that we 
> welcome any 
> > suggestions regarding where in the manual you might have 
> hoped to find 
> > this file scanning information.
> This thread picked my interest, because I didn't know the answer ;-)
> I personally assumed no includes was equivalent to "**/*", 
> which I would have guessed to include the base dir, when it doesn't.
> I would have tried "*/**", which I would interpret as: all 
> files directly in the base dir, and any sub-directories of 
> those. This also parallels the fact that * in unix shells 
> does not match ., the "base dir".
> All that to say that having to use "**/*" instead of "*/**" 
> feels counter-intuitive to me ;-) --DD
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: For 
> additional commands, e-mail:

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to
waive confidentiality or privilege. Use of this email is prohibited when received in error.

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

View raw message