peterreilly    2004/06/08 09:19:27

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/taskdefs Delete.java
               docs/manual/CoreTasks delete.html
  Log:
  Add deleteonexit attribute to <delete>
  
  Revision  Changes    Path
  1.619     +2 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.618
  retrieving revision 1.619
  diff -u -r1.618 -r1.619
  --- WHATSNEW  7 Jun 2004 12:26:03 -0000       1.618
  +++ WHATSNEW  8 Jun 2004 16:19:27 -0000       1.619
  @@ -215,6 +215,8 @@
   
   * Add implicit nested element to <macrodef>. Bugzilla Report 25633.
   
  +* Add deleteonexit attribute to <delete>.
  +
   Changes from Ant 1.6.0 to Ant 1.6.1
   =============================================
   
  
  
  
  1.53      +21 -2     ant/src/main/org/apache/tools/ant/taskdefs/Delete.java
  
  Index: Delete.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Delete.java,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- Delete.java       9 Mar 2004 16:48:04 -0000       1.52
  +++ Delete.java       8 Jun 2004 16:19:27 -0000       1.53
  @@ -69,6 +69,7 @@
       private int verbosity = Project.MSG_VERBOSE;
       private boolean quiet = false;
       private boolean failonerror = true;
  +    private boolean deleteOnExit = false;
   
       /**
        * Set the name of a single file to be removed.
  @@ -126,6 +127,16 @@
            this.failonerror = failonerror;
        }
   
  +    /**
  +     * If true, on failure to delete, note the error and set
  +     * the deleteonexit flag, and continue
  +     *
  +     * @param deleteOnExit true or false
  +     */
  +     public void setDeleteOnExit(boolean deleteOnExit) {
  +         this.deleteOnExit = deleteOnExit;
  +     }
  +
   
       /**
        * If true, delete empty directories.
  @@ -540,9 +551,17 @@
               }
               try {
                   Thread.sleep(DELETE_RETRY_SLEEP_MILLIS);
  -                return f.delete();
               } catch (InterruptedException ex) {
  -                return f.delete();
  +                // Ignore Exception
  +            }
  +            if (!f.delete()) {
  +                if (deleteOnExit) {
  +                    int level = quiet ? Project.MSG_VERBOSE : 
Project.MSG_INFO;
  +                    log("Failed to delete " + f + ", calling deleteOnExit" + 
f, level);
  +                    f.deleteOnExit();
  +                    return true;
  +                }
  +                return false;
               }
           }
           return true;
  
  
  
  1.20      +10 -0     ant/docs/manual/CoreTasks/delete.html
  
  Index: delete.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/delete.html,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- delete.html       9 Feb 2004 21:50:05 -0000       1.19
  +++ delete.html       8 Jun 2004 16:19:27 -0000       1.20
  @@ -130,6 +130,16 @@
         Default excludes are used when omitted.</td>
       <td valign="top" align="center">No</td>
     </tr>
  +  <tr>
  +    <td valign="top">deleteonexit</td>
  +    <td valign="top">
  +      Indicates whether to use File#deleteOnExit() if there is a
  +      failure to delete a file, this causes the jvm to attempt
  +      to delete the file when the jvm process is terminating.
  +      The default is false.
  +      <em>Since Ant 1.6.2</em>
  +    <td valign="top" align="center">No</td>
  +  </tr>
   </table>
   <h3>Examples</h3>
   <pre>  &lt;delete file=&quot;/lib/ant.jar&quot;/&gt;</pre>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to