You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2010/05/11 11:49:15 UTC

svn commit: r943068 - in /ant/core/trunk: WHATSNEW docs/manual/CoreTasks/concat.html docs/manual/CoreTasks/echo.html src/etc/testcases/taskdefs/concat.xml src/main/org/apache/tools/ant/taskdefs/Concat.java src/main/org/apache/tools/ant/taskdefs/Echo.java

Author: bodewig
Date: Tue May 11 09:49:14 2010
New Revision: 943068

URL: http://svn.apache.org/viewvc?rev=943068&view=rev
Log:
deal with read-only dest files in echo and concat.

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/docs/manual/CoreTasks/concat.html
    ant/core/trunk/docs/manual/CoreTasks/echo.html
    ant/core/trunk/src/etc/testcases/taskdefs/concat.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=943068&r1=943067&r2=943068&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue May 11 09:49:14 2010
@@ -9,8 +9,9 @@ Changes that could break older environme
    would only do so if under special circumstances.  Ant 1.8.2 now
    consistently won't replace a read-only file by default. The same is
    true for a number of other tasks.
-   The <copy> and <move> task now have a new force attribute that can
-   be used to make the task overwrite read-only destinations.
+   The <copy>, <move> and <echo> tasks now have a new force attribute
+   and <concat> has a new forceReadonly attribute that can be used to
+   make the task overwrite read-only destinations.
    Bugzilla Report 49261.
 
 Fixed bugs:
@@ -19,6 +20,10 @@ Fixed bugs:
 Other changes:
 --------------
 
+ * <concat>'s force attribute has been deprecated in favor of a new
+   overwrite attribute that is consistent with <copy>'s attribute
+   names.
+
 Changes from Ant 1.8.0 TO Ant 1.8.1 
 ===================================
 

Modified: ant/core/trunk/docs/manual/CoreTasks/concat.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/concat.html?rev=943068&r1=943067&r2=943068&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/concat.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/concat.html Tue May 11 09:49:14 2010
@@ -83,13 +83,30 @@ Resource Collection</a>s are used to
           <td valign="top">
             Specifies whether or not the file specified by 'destfile'
             should be written to even if it is newer than all source files.
-            <em>since Ant 1.6</em>.
+            <strong>deprecated, use the overwrite attribute instead</strong>
+            Defaults to &quot;yes&quot;.
+          </td>
+          <td valign="top" align="center">No</td>
+        </tr>
+        <tr>
+          <td valign="top">overwrite</td>
+          <td valign="top">
+            Specifies whether or not the file specified by 'destfile'
+            should be written to even if it is newer than all source files.
+            <em>since Ant 1.8.2</em>.
             Defaults to &quot;yes&quot;.
           </td>
           <td valign="top" align="center">No</td>
         </tr>
 
         <tr>
+          <td valign="top">forceReadOnly</td>
+          <td valign="top">Overwrite read-only destination
+            files.  <em>since Ant 1.8.2</em></td>
+          <td valign="top" align="center">No; defaults to false.</td>
+        </tr>
+
+        <tr>
           <td valign="top">encoding</td>
           <td valign="top">
             Specifies the encoding for the input files. Please see <a

Modified: ant/core/trunk/docs/manual/CoreTasks/echo.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/echo.html?rev=943068&r1=943067&r2=943068&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/echo.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/echo.html Tue May 11 09:49:14 2010
@@ -79,6 +79,12 @@ ignored</p>
     <td valign="top">encoding to use, default is ""; the local system encoding. <em>since Ant 1.7</em></td>
     <td valign="top" align="center">No</td>
   </tr>
+  <tr>
+    <td valign="top">force</td>
+    <td valign="top">Overwrite read-only destination
+      files.  <em>since Ant 1.8.2</em></td>
+    <td valign="top" align="center">No; defaults to false.</td>
+  </tr>
 </table>
 
 <h3>Examples</h3>

Modified: ant/core/trunk/src/etc/testcases/taskdefs/concat.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/concat.xml?rev=943068&r1=943067&r2=943068&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/concat.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/concat.xml Tue May 11 09:49:14 2010
@@ -110,7 +110,7 @@
     <touch file="${tmp.file.2}"/>
     <!-- concat.xml is now older than tmp.file.2
          so the following should not do anything -->
-    <concat destfile="${tmp.file.2}" force="false">
+    <concat destfile="${tmp.file.2}" overwrite="false">
       <path path="concat.xml"/>
     </concat>
   </target>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java?rev=943068&r1=943067&r2=943068&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java Tue May 11 09:49:14 2010
@@ -471,6 +471,8 @@ public class Concat extends Task impleme
     private Vector filterChains;
     /** ignore dates on input files */
     private boolean forceOverwrite = true;
+    /** overwrite read-only files */
+    private boolean force = false;
     /** String to place at the start of the concatented stream */
     private TextElement footer;
     /** String to place at the end of the concatented stream */
@@ -526,6 +528,7 @@ public class Concat extends Task impleme
         eolString = StringUtils.LINE_SEP;
         rc = null;
         ignoreEmpty = true;
+        force = false;
     }
 
     // Attribute setters.
@@ -581,15 +584,39 @@ public class Concat extends Task impleme
 
     /**
      * Force overwrite existing destination file
-     * @param force if true always overwrite, otherwise only overwrite
-     *              if the output file is older any of the input files.
+     * @param forceOverwrite if true always overwrite, otherwise only
+     *              overwrite if the output file is older any of the
+     *              input files.
      * @since Ant 1.6
+     * @deprecated use #setOverwrite instead
      */
-    public void setForce(boolean force) {
+    public void setForce(boolean forceOverwrite) {
         this.forceOverwrite = force;
     }
 
     /**
+     * Force overwrite existing destination file
+     * @param forceOverwrite if true always overwrite, otherwise only
+     *              overwrite if the output file is older any of the
+     *              input files.
+     * @since Ant 1.8.2
+     */
+    public void setOverwrite(boolean forceOverwrite) {
+        setForce(forceOverwrite);
+    }
+
+    /**
+     * Whether read-only destinations will be overwritten.
+     *
+     * <p>Defaults to false</p>
+     *
+     * @since Ant 1.8.2
+     */
+    public void setForceReadOnly(boolean f) {
+        force = f;
+    }
+
+    /**
      * Sets the behavior when no source resource files are available. If set to
      * <code>false</code> the destination file will always be created.
      * Defaults to <code>true</code>.
@@ -761,9 +788,11 @@ public class Concat extends Task impleme
         }
         try {
             //most of these are defaulted because the concat-as-a-resource code hijacks a lot:
-            ResourceUtils.copyResource(new ConcatResource(c), dest == null ? new LogOutputResource(
-                    this, Project.MSG_WARN) : dest, null, null, true, false, append, null, null,
-                    getProject());
+            ResourceUtils.copyResource(new ConcatResource(c), dest == null
+                                       ? new LogOutputResource(this, Project.MSG_WARN)
+                                       : dest,
+                                       null, null, true, false, append, null,
+                                       null, getProject(), force);
         } catch (IOException e) {
             throw new BuildException("error concatenating content to " + dest, e);
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java?rev=943068&r1=943067&r2=943068&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java Tue May 11 09:49:14 2010
@@ -47,6 +47,7 @@ public class Echo extends Task {
     protected boolean append = false;
     /** encoding; set to null or empty means 'default' */
     private String encoding = "";
+    private boolean force = false;
 
     // by default, messages are always displayed
     protected int logLevel = Project.MSG_WARN;
@@ -63,9 +64,12 @@ public class Echo extends Task {
         final String msg = "".equals(message) ? StringUtils.LINE_SEP : message;
         try {
             ResourceUtils
-                    .copyResource(new StringResource(msg), output == null ? new LogOutputResource(
-                            this, logLevel) : output, null, null, false, false, append, null, ""
-                            .equals(encoding) ? null : encoding, getProject());
+                    .copyResource(new StringResource(msg), output == null
+                                  ? new LogOutputResource(this, logLevel)
+                                  : output,
+                                  null, null, false, false, append, null,
+                                  "".equals(encoding) ? null : encoding,
+                                  getProject(), force);
         } catch (IOException ioe) {
             throw new BuildException(ioe, getLocation());
         }
@@ -148,6 +152,17 @@ public class Echo extends Task {
     }
 
     /**
+     * Whether read-only destinations will be overwritten.
+     *
+     * <p>Defaults to false</p>
+     *
+     * @since Ant 1.8.2
+     */
+    public void setForce(boolean f) {
+        force = f;
+    }
+
+    /**
      * The enumerated values for the level attribute.
      */
     public static class EchoLevel extends LogLevel {