ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r705626 - in /ant/core/trunk: CONTRIBUTORS WHATSNEW contributors.xml docs/manual/CoreTasks/concat.html src/main/org/apache/tools/ant/taskdefs/Concat.java src/tests/antunit/taskdefs/concat-test.xml
Date Fri, 17 Oct 2008 14:16:26 GMT
Author: bodewig
Date: Fri Oct 17 07:16:26 2008
New Revision: 705626

URL: http://svn.apache.org/viewvc?rev=705626&view=rev
Log:
allow control over whether <concat> creates a file when there are no resources.  Submitted
by Mark Salter.  PR 46010.

Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/contributors.xml
    ant/core/trunk/docs/manual/CoreTasks/concat.html
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java
    ant/core/trunk/src/tests/antunit/taskdefs/concat-test.xml

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=705626&r1=705625&r2=705626&view=diff
==============================================================================
Binary files - no diff available.

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=705626&r1=705625&r2=705626&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Oct 17 07:16:26 2008
@@ -463,6 +463,12 @@
  * <cvs> and friends now support modules with spaces in their names
    via nested <module> elements.
 
+ * A new attribute "ignoreEmpty" controls how <concat> deals when
+   there are no resources to concatenate.  If it is set to false, the
+   destination file will be created regardless, which reinstates the
+   behavior of Ant 1.7.0.
+   Bugzilla Report 46010.
+
 Changes from Ant 1.7.0 TO Ant 1.7.1
 =============================================
 

Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=705626&r1=705625&r2=705626&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Fri Oct 17 07:16:26 2008
@@ -704,7 +704,7 @@
   </name>
   <name>
     <first>Marcus</first>
-    <last>B&amp;ouml;rger</last>
+    <last>Börger</last>
   </name>
   <name>
     <first>Mario</first>
@@ -720,6 +720,10 @@
   </name>
   <name>
     <first>Mark</first>
+    <last>Salter</last>
+  </name>
+  <name>
+    <first>Mark</first>
     <middle>R.</middle>
     <last>Diggory</last>
   </name>

Modified: ant/core/trunk/docs/manual/CoreTasks/concat.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/concat.html?rev=705626&r1=705625&r2=705626&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/concat.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/concat.html Fri Oct 17 07:16:26 2008
@@ -32,7 +32,8 @@
         Concatenates one or more 
         <a href="../CoreTypes/resources.html">resource</a>s
         to a single file or to the console. The destination
-        file will be created if it does not exist.
+        file will be created if it does not exist unless the resource
+        list is empty and ignoreempty is true.
       </p>
 
       <p><strong>Since Ant 1.7.1</strong>, this task can be used as a
@@ -158,7 +159,17 @@
             set, and the task cannot used nested text.
             Also the attributes encoding, outputencoding, filelastline
             cannot be used.
-            The default is false.
+            The default is &quot;false&quot;.
+          </td>
+          <td valign="top" align="center">No</td>
+        </tr>
+        <tr>
+          <td valign="top">ignoreempty</td>
+          <td valign="top">
+          <em>Since Ant 1.8.0</em>
+            Specifies whether or not the file specified by 'destfile'
+            should be created if the source resource list is
+            empty. Defaults to &quot;true&quot;.
           </td>
           <td valign="top" align="center">No</td>
         </tr>

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=705626&r1=705625&r2=705626&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 Fri Oct 17 07:16:26
2008
@@ -479,6 +479,9 @@
     private String eolString;
     /** outputwriter */
     private Writer outputWriter = null;
+    /** whether to not create destinationfile if no source files are
+     * available */
+    private boolean ignoreEmpty = true;
 
     private ReaderFactory resourceReaderFactory  = new ReaderFactory() {
         public Reader getReader(Object o) throws IOException {
@@ -520,6 +523,7 @@
         textBuffer = null;
         eolString = StringUtils.LINE_SEP;
         rc = null;
+        ignoreEmpty = true;
     }
 
     // Attribute setters.
@@ -574,6 +578,17 @@
         this.forceOverwrite = force;
     }
 
+    /**
+     * 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>.
+     * @param ignoreEmpty if false honour destinationfile creation.
+     * @since Ant 1.8.0
+     */
+    public void setIgnoreEmpty(boolean ignoreEmpty) {
+        this.ignoreEmpty = ignoreEmpty;
+    }
+
     // Nested element creators.
 
     /**
@@ -733,7 +748,7 @@
             log(destinationFile + " is up-to-date.", Project.MSG_VERBOSE);
             return;
         }
-        if (c.size() == 0) {
+        if (c.size() == 0 && ignoreEmpty) {
             return;
         }
         OutputStream out;

Modified: ant/core/trunk/src/tests/antunit/taskdefs/concat-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/concat-test.xml?rev=705626&r1=705625&r2=705626&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/concat-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/concat-test.xml Fri Oct 17 07:16:26 2008
@@ -74,4 +74,45 @@
     </au:assertTrue>
   </target>
 
+  <target name="testIgnoreEmptyFalseFileIsCreated">
+    <mkdir dir="${input}"/>
+    <mkdir dir="${output}"/>
+    <concat destfile="${output}/TESTDEST" append="true" ignoreEmpty="false">
+      <filelist dir="${input}" files="thisfiledoesnotexist"/>
+    </concat>
+    <au:assertFileExists file="${output}/TESTDEST"/>
+  </target>
+	
+  <target name="testIgnoreEmptyTrueFileIsNotCreated">
+    <mkdir dir="${input}"/>
+    <mkdir dir="${output}"/>
+    <concat destfile="${output}/TESTDEST" append="true" ignoreEmpty="true">
+      <filelist dir="${input}" files="thisfiledoesnotexist"/>
+    </concat>
+    <au:assertFileDoesntExist file="${output}/TESTDEST"/>
+  </target>
+	
+  <target name="testIgnoreEmptyFalseFileIsCreatedIncludesHeader">
+    <mkdir dir="${input}"/>
+    <mkdir dir="${output}"/>
+    <concat destfile="${output}/TESTDEST" ignoreEmpty="false">
+      <filelist dir="${input}" files="thisfiledoesnotexist"/>
+      <header filtering="false" trim="yes">
+	header
+      </header>
+    </concat>
+    <au:assertFileExists file="${output}/TESTDEST"/>
+    <au:assertResourceContains resource="${output}/TESTDEST" value="header"/>
+  </target>
+	
+  <target name="testIgnoreEmptyFalseFileIsCreatedIncludesFooter">
+    <mkdir dir="${input}"/>
+    <mkdir dir="${output}"/>
+    <concat destfile="${output}/TESTDEST" ignoreEmpty="false">
+      <filelist dir="${input}" files="thisfiledoesnotexist"/>
+      <footer filtering="no">footer</footer>
+    </concat>
+    <au:assertFileExists file="${output}/TESTDEST"/>
+    <au:assertResourceContains resource="${output}/TESTDEST" value="footer"/>
+  </target>
 </project>



Mime
View raw message