From 9f766c7fa0d49087dcb5fa50dce049f275f3db54 Mon Sep 17 00:00:00 2001 From: glennm Date: Thu, 5 Oct 2000 17:19:57 +0000 Subject: [PATCH] Removed dir attribute from Copy and Move tasks. Now you can only copy or move entire directories with nested FileSets. Prompted by a patch submitted by Nico Seessle. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268061 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 44 ++++++++++++++----- docs/index.html | 18 ++++---- .../org/apache/tools/ant/taskdefs/Copy.java | 26 ++--------- .../org/apache/tools/ant/taskdefs/Move.java | 7 +-- 4 files changed, 46 insertions(+), 49 deletions(-) diff --git a/build.xml b/build.xml index d31fafc6a..255354a67 100644 --- a/build.xml +++ b/build.xml @@ -136,7 +136,9 @@ - + + + @@ -173,13 +175,23 @@ - - + + + + + + - - - + + + + + + + + + @@ -215,14 +227,20 @@ - - + + + + + + - + + + @@ -235,8 +253,12 @@ - - + + + + + + diff --git a/docs/index.html b/docs/index.html index 1888a91e6..a3174e71c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1176,7 +1176,7 @@ permissions.


Copy

Description

-

Copies a file or directory to a new file or directory. Files are +

Copies a file or Fileset 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.

@@ -1192,19 +1192,15 @@ To use a fileset, the todir attribute must be set.

file the file to copy - One of file or - dir are required, or at least one nested fileset element. - - - dir - the directory to copy + One of either file or + at least one nested fileset element. tofile the file to copy to With the file attribute, - either tofile or todir can be used. With the dir - attribute and nested filesets, only todir is allowed. + either tofile or todir can be used. With nested filesets, + only todir is allowed. todir @@ -1241,7 +1237,9 @@ To use a fileset, the todir attribute must be set.

Copy a directory to another directory

-  <copy dir="src_dir" todir="../new/dir" />
+  <copy todir="../new/dir">
+    <fileset dir="src_dir"/>
+  </copy>
 

Copy a set of files to a directory

diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java
index 4873afaf6..3abb064d4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Copy.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java
@@ -74,7 +74,6 @@ import java.util.*;
  */
 public class Copy extends Task {
     protected File file = null;     // the source file 
-    protected File dir = null;      // the source directory
     protected File destFile = null; // the destination file 
     protected File destDir = null;  // the destination directory
     protected Vector filesets = new Vector();
@@ -93,13 +92,6 @@ public class Copy extends Task {
         this.file = file;
     }
 
-    /**
-     * Sets a directory to copy.
-     */
-    public void setDir(File dir) {
-        this.dir = dir;
-    }
-
     /**
      * Sets the destination file.
      */
@@ -176,16 +168,6 @@ public class Copy extends Task {
             }
         }
 
-        // deal with the directory
-        if (dir != null) {
-            DirectoryScanner ds = new DirectoryScanner();
-            ds.setBasedir(dir);
-            ds.scan();          // include EVERYTHING
-
-            String[] srcFiles = ds.getIncludedFiles();
-            scan(dir, destDir, srcFiles);                   // add to fileCopyMap
-        }
-
         // deal with the filesets
         for (int i=0; i 0) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/Move.java b/src/main/org/apache/tools/ant/taskdefs/Move.java
index afb66d140..a461a105b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Move.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Move.java
@@ -86,11 +86,6 @@ public class Move extends Copy {
 
     public void execute() throws BuildException {
         super.execute();
-
-        // take care of the source directory
-        if (dir != null && dir.exists()) {
-            deleteDir(dir);
-        }
     }
 
 //************************************************************************
@@ -139,7 +134,7 @@ public class Move extends Copy {
         }
         log("Deleting directory " + d.getAbsolutePath(), verbosity);
         if (!d.delete()) {
-	       throw new BuildException("Unable to delete directory " + dir.getAbsolutePath());
+	       throw new BuildException("Unable to delete directory " + d.getAbsolutePath());
 	   }
     }