ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hol...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Copy.java
Date Mon, 01 Apr 2002 03:49:51 GMT
holtdl      02/03/31 19:49:51

  Modified:    docs/manual/CoreTasks copy.html
               src/main/org/apache/tools/ant/taskdefs Copy.java
  Log:
  Add a 'failonerror' attr. (PR 4273)
  
  Revision  Changes    Path
  1.9       +60 -43    jakarta-ant/docs/manual/CoreTasks/copy.html
  
  Index: copy.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/copy.html,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- copy.html	10 Jan 2002 08:48:29 -0000	1.8
  +++ copy.html	1 Apr 2002 03:49:51 -0000	1.9
  @@ -9,12 +9,14 @@
   
   <h2><a name="copy">Copy</a></h2>
   <h3>Description</h3>
  -<p>Copies a file or Fileset to a new file or directory.  Files are
  +<p>Copies a file or FileSet to a new file or directory.  By default, 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>
  -<p><a href="../CoreTypes/fileset.html">FileSet</a>s are used to select
files to copy.  
  -To use a fileset, the <var>todir</var> attribute must be set.</p>
  +overwrite files with the <code>overwrite</code> attribute.</p>
  +<p><a href="../CoreTypes/fileset.html">FileSet</a>s are used to select
a
  +set of files to copy.  
  +To use a <code>&lt;fileset&gt;</code>, the <code>todir</code>
attribute
  +must be set.</p>
   <h3>Parameters</h3>
   <table border="1" cellpadding="2" cellspacing="0">
     <tr>
  @@ -25,24 +27,26 @@
     <tr>
       <td valign="top">file</td>
       <td valign="top">The file to copy.</td>
  -    <td valign="top" align="center">One of either <var>file</var> or

  -    at least one nested fileset element.</td>
  +    <td valign="top" align="center">Yes, unless a nested 
  +    <code>&lt;fileset&gt;</code> element is used.</td>
     </tr>
     <tr>
       <td valign="top">preservelastmodified</td>
       <td valign="top">Give the copied files the same last modified
  -      time as the original source files. Defaults to &quot;no&quot;.
  -      [ignored on Java 1.1]</td>
  -    <td valign="top" align="center">No</td>
  +      time as the original source files.
  +      (<em>Note</em>: Ignored on Java 1.1)</td>
  +    <td valign="top" align="center">No; defaults to false.</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 nested filesets, 
  -    if the fileset size is greater than 1 or if the only entry in the fileset is a
  -    directory or if the file attribute is already specified, only
  -    <var>todir</var> is allowed</td>
  +    <td valign="top" align="center" rowspan="2">With the <code>file</code>
  +      attribute, either <code>tofile</code> or <code>todir</code>
can be used.
  +      With nested <code>&lt;fileset&gt;</code> elements, if the set
of files
  +      is greater than 1, or if only the <code>dir</code> attribute is
  +      specified in the <code>&lt;fileset&gt;</code>, or if the
  +      <code>file</code> attribute is also specified, then only
  +      <code>todir</code> is allowed.</td>
     </tr>
     <tr>
       <td valign="top">todir</td>
  @@ -51,46 +55,58 @@
     <tr>
       <td valign="top">overwrite</td>
       <td valign="top">Overwrite existing files even if the destination
  -      files are newer. Defaults to &quot;no&quot;.</td>
  -    <td valign="top" align="center">No</td>
  +      files are newer.</td>
  +    <td valign="top" align="center">No; defaults to false.</td>
     </tr>
     <tr>
       <td valign="top">filtering</td>
  -    <td valign="top">Indicates whether token filtering using the global build file
  -                     filters should take place during the copy. Defaults to &quot;no&quot;.

  -                     Nested filtersets will be used even if this value is &quot;no&quot;</td>
  -    <td valign="top" align="center">No</td>
  +    <td valign="top">Indicates whether token filtering using the global
  +      build-file filters should take place during the copy.
  +      <em>Note</em>: Nested <code>&lt;filterset&gt;</code>
elements will
  +      always be used, even if this attribute is not specified, or its value is
  +      <code>false</code> (<code>no</code>, or <code>off</code>).</td>
  +    <td valign="top" align="center">No; defaults to false.</td>
     </tr>
     <tr>
       <td valign="top">flatten</td>
  -    <td valign="top">Ignore directory structure of source directory,
  -      copy all files into a single directory, specified by the <var>todir</var>
  -      attribute. Defaults to &quot;no&quot;. Note that you can achieve the 
  -      same effect by using a <a href="../CoreTypes/mapper.html#flatten-mapper">flatten
mapper</a></td>
  -    <td valign="top" align="center">No</td>
  +    <td valign="top">Ignore the directory structure of the source files,
  +      and copy all files into the directory specified by the <code>todir</code>
  +      attribute.  Note that you can achieve the same effect by using a
  +      <a href="../CoreTypes/mapper.html#flatten-mapper">flatten mapper</a>.</td>
  +    <td valign="top" align="center">No; defaults to false.</td>
     </tr>
     <tr>
       <td valign="top">includeEmptyDirs</td>
  -     <td valign="top">Copy empty directories included with the nested FileSet(s).
  -       Defaults to &quot;yes&quot;.</td>
  -     <td valign="top" align="center">No</td>
  +     <td valign="top">Copy any empty directories included in the FileSet(s).
  +     </td>
  +     <td valign="top" align="center">No; defaults to true.</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">failonerror</td>
  +     <td valign="top">Log a warning message, but do not stop the build,
  +       when the file to copy does not exist.
  +       Only meaningful when copying a single file.
  +     </td>
  +     <td valign="top" align="center">No; defaults to true.</td>
     </tr>
   </table>
   <h3>Parameters specified as nested elements</h3>
    
   <h4>fileset</h4>
  - <p><a href="../CoreTypes/fileset.html">FileSets</a> are used to select
files to copy.  
  - To use a fileset, the <var>todir</var> attribute must be set.</p>
  + <p><a href="../CoreTypes/fileset.html">FileSet</a>s are used to select
  +sets of files to copy.  
  + To use a fileset, the <code>todir</code> attribute must be set.</p>
    
   <h4>mapper</h4>
  - <p>You can define file name transformations by using a nested <a
  + <p>You can define filename transformations by using a nested <a
    href="../CoreTypes/mapper.html">mapper</a> element. The default mapper used by
    <code>&lt;copy&gt;</code> is the <a
  - href="../CoreTypes/mapper.html#identity-mapper">identity</a>.</p>
  + href="../CoreTypes/mapper.html#identity-mapper">identity mapper</a>.</p>
    
   <h4>filterset</h4>
  - <p><a href="../CoreTypes/filterset.html">Filtersets</a> are used to
replace tokens in files that are copied.  
  - To use a filterset just add the nested filterset elements.</P>
  + <p><a href="../CoreTypes/filterset.html">FilterSet</a>s are used to
replace
  +tokens in files that are copied.  
  + To use a FilterSet, use the nested <code>&lt;filterset&gt;</code>
element.</p>
    
     
   <h3>Examples</h3>
  @@ -98,9 +114,9 @@
   <pre>
     &lt;copy file=&quot;myfile.txt&quot; tofile=&quot;mycopy.txt&quot;/&gt;
   </pre>
  -<p><b>Copy a file to a directory</b></p>
  +<p><b>Copy a single file to a directory</b></p>
   <pre>
  -  &lt;copy file=&quot;myfile.txt&quot; todir=&quot;../some/dir/tree&quot;/&gt;
  +  &lt;copy file=&quot;myfile.txt&quot; todir=&quot;../some/other/dir&quot;/&gt;
   </pre>
   <p><b>Copy a directory to another directory</b></p>
   <pre>
  @@ -120,8 +136,8 @@
       &lt;fileset dir=&quot;src_dir&quot; excludes=&quot;**/*.java&quot;/&gt;
     &lt;/copy&gt;
   </pre>
  -<p><b>Copy a set of files to a directory appending
  -&quot;<code>.bak</code>&quot; to the file name on the fly</b></p>
  +<p><b>Copy a set of files to a directory, appending
  +<code>.bak</code> to the file name on the fly</b></p>
   <pre>
     &lt;copy todir=&quot;../backup/dir&quot; &gt;
       &lt;fileset dir=&quot;src_dir&quot; /&gt;
  @@ -130,7 +146,8 @@
   </pre>
   
   
  -<p><b>Copy a set of files to a replacing @TITLE@ with Foo Bar in all files.</b></p>
  +<p><b>Copy a set of files to a directory, replacing @TITLE@ with Foo Bar
  +in all files.</b></p>
   <pre>
     &lt;copy todir=&quot;../backup/dir&quot; &gt;
       &lt;fileset dir=&quot;src_dir&quot; /&gt;
  @@ -140,14 +157,14 @@
     &lt;/copy&gt;
   </pre>
   
  -<p><strong>Unix Note:</strong> file permissions are not retained when
files
  +<p><strong>Unix Note:</strong> File permissions are not retained when
files
   are copied; they end up with the default UMASK permissions instead. This
   is caused by the lack of any means to query or set file permissions in the
  -current Java runtimes. If you need a permission preserving copy function,
  +current Java runtimes. If you need a permission-preserving copy function,
   use &lt;exec executable="cp" ... &gt; instead. 
   
  -<hr><p align="center">Copyright &copy; 2001 Apache Software Foundation.
All rights
  -Reserved.</p>
  +<hr><p align="center">Copyright &copy; 2001,2002 Apache Software Foundation.
  +All rights Reserved.</p>
   
   </body>
   </html>
  
  
  
  1.38      +16 -4     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.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- Copy.java	6 Mar 2002 14:29:18 -0000	1.37
  +++ Copy.java	1 Apr 2002 03:49:51 -0000	1.38
  @@ -90,7 +90,7 @@
    * @author <A href="gholam@xtra.co.nz">Michael McCallum</A>
    * @author <a href="mailto:umagesh@rediffmail.com">Magesh Umasankar</a>
    *
  - * @version $Revision: 1.37 $
  + * @version $Revision: 1.38 $
    *
    * @ant.task category="filesystem"
    */
  @@ -106,6 +106,7 @@
       protected boolean flatten = false;
       protected int verbosity = Project.MSG_VERBOSE;
       protected boolean includeEmpty = true;
  +    private boolean failonerror = true;
   
       protected Hashtable fileCopyMap = new Hashtable();
       protected Hashtable dirCopyMap = new Hashtable();
  @@ -251,6 +252,14 @@
       }
   
       /**
  +     * Note errors to the output, but keep going
  +     * @param failonerror true or false
  +     */
  +     public void setFailOnError(boolean failonerror) {
  +         this.failonerror=failonerror;
  +     }
  +
  +    /**
        * Adds a set of files (nested fileset attribute).
        */
       public void addFileset(FileSet set) {
  @@ -309,10 +318,13 @@
                           Project.MSG_VERBOSE);
                   }
               } else {
  -                String message = "Could not find file "
  +                String message = "Warning: Could not find file "
                                    + file.getAbsolutePath() + " to copy.";
  -                log(message);
  -                throw new BuildException(message);
  +                if(!failonerror) {
  +                    log(message);
  +                } else {
  +                    throw new BuildException(message);
  +                }
               }
           }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message