ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gle...@ca.ibm.com
Subject [PATCH] Consolidated copy, move, and delete tasks
Date Fri, 08 Sep 2000 21:38:43 GMT
Hey all.

My applogies if this is coming to people as HTML (or with an HTML 
attachement).  I don't have control over how this gets sent out, so my 
appologies yet again.

One of the big wants for the next release of Ant is a consolidated set of 
copy, move, and delete tasks.  For background, send an empty email to 
ant-dev-thread.2332@jakarta-apache.org (thanks to Sefan for pointing the 
thread out).

The biggest difference between these tasks and the current delete, 
deltree, copyfile, and copydir tasks is that the fileset is _not_ 
implicit.  The drawback to this is that it breakes existing delete 
functionality.  The advantage is clarity and consistency in the use of 
filesets.

I'm affraid I deleted the email where Conor explained how to include new 
files in a patch, so I'm affraid this is coming as three files - the patch 
for Delete.java, index.html, and taskdefs/defaults.properties, and two new 
Copy.java and Move.java files.

Comments, flames, kudos welcome.

Copy
====
Copies a file or directory to a new file or directory. Files are only 
copied if the source file is newer than the destination file, or when the 
destination file does not exist. However, you can explicitly overwrite 
files with the overwrite attribute.

<copy file="some_file.txt" tofile="some_other_file.txt" />

<copy file="some_file.txt" todir="some/other/dir" />

<copy dir="src_dir" todir="../some/other/dir" />

<copy todir="../yet/another/dir">
  <fileset dir="src">
    <includes name="**/*.css" />
    <excludes name="**/*.html" />
  </fileset>
</copy>

<copy dir="src_dir" 
      todir="../some/other/dir" 
      filtering="yes"
      flatten="yes" />

Move
====
Moves a file or directory to a new file or directory, or sets of files to 
a new directory. By default, the destination file is overwritten if it 
already exists. When overwrite is turned off, then files are only moved if 
the source file is newer than the destination file, or when the 
destination file does not exist.

<move file="file.orig" tofile="../moved/file.moved" />

Note that this effectively replaces the rename task.

<move file="file.orig" todir="../moved" />

<move dir="original/directory" todir="../directory/to/move/to" />

Note that the above move will actually remove the "directory" subdirectory 
of "original".

<move todir="../directory/to/move/to">
  <fileset dir="original/dir" includes="**/*.css" />
  <fileset dir="original/otherdir" includes="**/*.html" />
</move>

<move dir="orig/dir" todir="../new/dir" filtering="yes" flatten="yes" />

Delete
======
Deletes either a single file, all files in a specified directory and its 
sub-directories, or a set of files specified by a fileset.  When 
specifying a set of files, empty directories are not removed.

<delete file="some/file/to/delete.txt" />

<delete dir="some/dir/to/delete" />

<delete>
  <fileset dir="src/dir">
    <include name="**/*.bak" />
    <exclude name="**/really/important/backup.bak" />
  </fileset>
</delete>




Glenn McAllister
Software Developer. IBM Toronto Lab, (416) 448-3805
"An approximate answer to the right question is better than the 
right answer to the wrong question." - John W. Tukey
Mime
View raw message