ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gle...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Copy.java Move.java
Date Thu, 05 Oct 2000 17:19:58 GMT
glennm      00/10/05 10:19:57

  Modified:    .        build.xml
               docs     index.html
               src/main/org/apache/tools/ant/taskdefs Copy.java Move.java
  Log:
  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.
  
  Revision  Changes    Path
  1.82      +33 -11    jakarta-ant/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/build.xml,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- build.xml	2000/10/05 09:11:05	1.81
  +++ build.xml	2000/10/05 17:19:50	1.82
  @@ -136,7 +136,9 @@
     <!-- =================================================================== -->
     <target name="main" depends="jar" description="Creates the binary structure">
        <mkdir dir="${bin.dir}"/>
  -     <copy dir="${src.bin.dir}" todir="${bin.dir}"/>
  +     <copy todir="${bin.dir}">
  +       <fileset dir="${src.bin.dir}"/>
  +     </copy>
        <chmod perm="+x">
          <fileset dir="${bin.dir}">
            <patternset refid="chmod.patterns"/>
  @@ -173,13 +175,23 @@
        <mkdir dir="${ant.dist.dir}/docs/api"/>
        <mkdir dir="${ant.dist.dir}/src"/>
   
  -     <copy dir="${src.dir}" todir="${ant.dist.dir}/src"/>
  -     <copy dir="${lib.dir}" todir="${ant.dist.dir}/lib"/>
  +     <copy todir="${ant.dist.dir}/src">
  +       <fileset dir="${src.dir}"/>
  +     </copy>
  +     <copy todir="${ant.dist.dir}/lib">
  +       <fileset dir="${lib.dir}"/>
  +     </copy>
   
        <copy file="build.xml" tofile="${ant.dist.dir}/lib/build.xml"/>
  -     <copy dir="src/bin" todir="${ant.dist.dir}/bin"/>
  -     <copy dir="${docs.dir}" todir="${ant.dist.dir}/docs"/>
  -     <copy dir="${build.javadocs}" todir="${ant.dist.dir}/docs/api"/>
  +     <copy todir="${ant.dist.dir}/bin">
  +       <fileset dir="src/bin"/>
  +     </copy>
  +     <copy todir="${ant.dist.dir}/docs">
  +       <fileset dir="${docs.dir}"/>
  +     </copy>
  +     <copy todir="${ant.dist.dir}/docs/api">
  +       <fileset dir="${build.javadocs}"/>
  +     </copy>
   
        <fixcrlf srcdir="${ant.dist.dir}/bin" includes="ant,antRun" cr="remove"/>
        <fixcrlf srcdir="${ant.dist.dir}/bin" includes="*.bat" cr="add"/>
  @@ -215,14 +227,20 @@
     <!-- =================================================================== -->
     <target name="bootstrap" depends="main" description="Installs the ant.jar library
and binary files into ant.home">
       <echo message="copying bootstrapped files into bin and lib"/>
  -    <copy dir="${lib.dir}" todir="lib"/>
  -    <copy dir="${bin.dir}" todir="bin"/>
  +    <copy todir="lib">
  +      <fileset dir="${lib.dir}"/>
  +    </copy>
  +    <copy todir="bin">
  +      <fileset dir="${bin.dir}"/>
  +    </copy>
     </target>     
   
     <target name="install" depends="dist" if="ant.install">
       <echo message="installing full copy of ant into ${ant.install}"/>
       <mkdir dir="${ant.install}"/>
  -    <copy dir="${ant.dist.dir}" todir="${ant.install}"/>
  +    <copy todir="${ant.install}">
  +      <fileset dir="${ant.dist.dir}"/>
  +    </copy>
       <chmod perm="+x">
         <fileset dir="${ant.install}/bin">
           <patternset refid="chmod.patterns"/>
  @@ -235,8 +253,12 @@
     <target name="mininstall" depends="main" if="ant.install">
       <echo message="copy minimal ant installation into ${ant.install}"/>
       <mkdir dir="${ant.install}"/>
  -    <copy dir="${lib.dir}" todir="${ant.install}/lib"/>
  -    <copy dir="${bin.dir}" todir="${ant.install}/bin"/>
  +    <copy todir="${ant.install}/lib">
  +      <fileset dir="${lib.dir}"/>
  +    </copy>
  +    <copy todir="${ant.install}/bin">
  +      <fileset dir="${bin.dir}"/>
  +    </copy>
       <chmod perm="+x">
         <fileset dir="${ant.install}/bin">
           <patternset refid="chmod.patterns"/>
  
  
  
  1.122     +8 -10     jakarta-ant/docs/index.html
  
  Index: index.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/index.html,v
  retrieving revision 1.121
  retrieving revision 1.122
  diff -u -r1.121 -r1.122
  --- index.html	2000/10/04 04:35:34	1.121
  +++ index.html	2000/10/05 17:19:55	1.122
  @@ -1176,7 +1176,7 @@
   <hr>
   <h2><a name="copy">Copy</a></h2>
   <h3>Description</h3>
  -<p>Copies a file or directory to a new file or directory.  Files are
  +<p>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 <var>overwrite</var> attribute.</p>
  @@ -1192,19 +1192,15 @@
     <tr>
       <td valign="top">file</td>
       <td valign="top">the file to copy</td>
  -    <td valign="top" align="center" rowspan="2">One of <var>file</var>
or 
  -    <var>dir</var> are required, or at least one nested fileset element.</td>
  +    <td valign="top" align="center">One of either <var>file</var> or

  +    at least one nested fileset element.</td>
     </tr>
     <tr>
  -    <td valign="top">dir</td>
  -    <td valign="top">the directory to copy</td>
  -  </tr>
  -  <tr>
       <td valign="top">tofile</td>
       <td valign="top">the file to copy to</td>
       <td valign="top" align="center" rowspan="2">With the <var>file</var>
attribute, 
  -    either <var>tofile</var> or <var>todir</var> can be used. 
With the <var>dir</var>
  -    attribute and nested filesets, only <var>todir</var> is allowed.</td>
  +    either <var>tofile</var> or <var>todir</var> can be used. 
With nested filesets, 
  +    only <var>todir</var> is allowed.</td>
     </tr>
     <tr>
       <td valign="top">todir</td>
  @@ -1241,7 +1237,9 @@
   </pre>
   <p><b>Copy a directory to another directory</b></p>
   <pre>
  -  &lt;copy dir=&quot;src_dir&quot; todir=&quot;../new/dir&quot; /&gt;
  +  &lt;copy todir=&quot;../new/dir&quot;&gt;
  +    &lt;fileset dir=&quot;src_dir&quot;/&gt;
  +  &lt;/copy&gt;
   </pre>
   <p><b>Copy a set of files to a directory</b></p>
   <pre>
  
  
  
  1.2       +4 -22     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Copy.java
  
  Index: Copy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Copy.java	2000/10/04 04:33:57	1.1
  +++ Copy.java	2000/10/05 17:19:56	1.2
  @@ -74,7 +74,6 @@
    */
   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();
  @@ -94,13 +93,6 @@
       }
   
       /**
  -     * Sets a directory to copy.
  -     */
  -    public void setDir(File dir) {
  -        this.dir = dir;
  -    }
  -
  -    /**
        * Sets the destination file.
        */
       public void setTofile(File destFile) {
  @@ -176,16 +168,6 @@
               }
           }
   
  -        // 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<filesets.size(); i++) {
               FileSet fs = (FileSet) filesets.elementAt(i);
  @@ -209,8 +191,8 @@
        * of attributes.
        */
       protected void validateAttributes() throws BuildException {
  -        if (file == null && dir == null && filesets.size() == 0) {
  -            throw new BuildException("Specify at least one source - a file, a dir, or a
fileset.");
  +        if (file == null && filesets.size() == 0) {
  +            throw new BuildException("Specify at least one source - a file or a fileset.");
           }
   
           if (destFile != null && destDir != null) {
  @@ -221,8 +203,8 @@
               throw new BuildException("One of destfile or destdir must be set.");
           }
   
  -        if (dir != null && destFile != null) {
  -            throw new BuildException("Cannot copy a directory into a file.");
  +        if (file != null && destFile != null && file.exists() &&
file.isDirectory()) {
  +            throw new BuildException("Use the dir attribute to copy directories.");
           }
   
           if (destFile != null && filesets.size() > 0) {
  
  
  
  1.2       +1 -6      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Move.java
  
  Index: Move.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Move.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Move.java	2000/10/04 04:33:59	1.1
  +++ Move.java	2000/10/05 17:19:57	1.2
  @@ -86,11 +86,6 @@
   
       public void execute() throws BuildException {
           super.execute();
  -
  -        // take care of the source directory
  -        if (dir != null && dir.exists()) {
  -            deleteDir(dir);
  -        }
       }
   
   //************************************************************************
  @@ -139,7 +134,7 @@
           }
           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());
   	   }
       }
   
  
  
  

Mime
View raw message