git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@705626 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -173,6 +173,7 @@ Marcus Börger | |||||
| Mario Frasca | Mario Frasca | ||||
| Mariusz Nowostawski | Mariusz Nowostawski | ||||
| Mark Hecker | Mark Hecker | ||||
| Mark Salter | |||||
| Mark R. Diggory | Mark R. Diggory | ||||
| Martijn Kruithof | Martijn Kruithof | ||||
| Martin Landers | Martin Landers | ||||
| @@ -463,6 +463,12 @@ Other changes: | |||||
| * <cvs> and friends now support modules with spaces in their names | * <cvs> and friends now support modules with spaces in their names | ||||
| via nested <module> elements. | 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 | Changes from Ant 1.7.0 TO Ant 1.7.1 | ||||
| ============================================= | ============================================= | ||||
| @@ -704,7 +704,7 @@ | |||||
| </name> | </name> | ||||
| <name> | <name> | ||||
| <first>Marcus</first> | <first>Marcus</first> | ||||
| <last>B&ouml;rger</last> | |||||
| <last>Börger</last> | |||||
| </name> | </name> | ||||
| <name> | <name> | ||||
| <first>Mario</first> | <first>Mario</first> | ||||
| @@ -718,6 +718,10 @@ | |||||
| <first>Mark</first> | <first>Mark</first> | ||||
| <last>Hecker</last> | <last>Hecker</last> | ||||
| </name> | </name> | ||||
| <name> | |||||
| <first>Mark</first> | |||||
| <last>Salter</last> | |||||
| </name> | |||||
| <name> | <name> | ||||
| <first>Mark</first> | <first>Mark</first> | ||||
| <middle>R.</middle> | <middle>R.</middle> | ||||
| @@ -32,7 +32,8 @@ | |||||
| Concatenates one or more | Concatenates one or more | ||||
| <a href="../CoreTypes/resources.html">resource</a>s | <a href="../CoreTypes/resources.html">resource</a>s | ||||
| to a single file or to the console. The destination | 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> | ||||
| <p><strong>Since Ant 1.7.1</strong>, this task can be used as a | <p><strong>Since Ant 1.7.1</strong>, this task can be used as a | ||||
| @@ -158,7 +159,17 @@ Resource Collection</a>s are used to | |||||
| set, and the task cannot used nested text. | set, and the task cannot used nested text. | ||||
| Also the attributes encoding, outputencoding, filelastline | Also the attributes encoding, outputencoding, filelastline | ||||
| cannot be used. | cannot be used. | ||||
| The default is false. | |||||
| The default is "false". | |||||
| </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 "true". | |||||
| </td> | </td> | ||||
| <td valign="top" align="center">No</td> | <td valign="top" align="center">No</td> | ||||
| </tr> | </tr> | ||||
| @@ -479,6 +479,9 @@ public class Concat extends Task implements ResourceCollection { | |||||
| private String eolString; | private String eolString; | ||||
| /** outputwriter */ | /** outputwriter */ | ||||
| private Writer outputWriter = null; | private Writer outputWriter = null; | ||||
| /** whether to not create destinationfile if no source files are | |||||
| * available */ | |||||
| private boolean ignoreEmpty = true; | |||||
| private ReaderFactory resourceReaderFactory = new ReaderFactory() { | private ReaderFactory resourceReaderFactory = new ReaderFactory() { | ||||
| public Reader getReader(Object o) throws IOException { | public Reader getReader(Object o) throws IOException { | ||||
| @@ -520,6 +523,7 @@ public class Concat extends Task implements ResourceCollection { | |||||
| textBuffer = null; | textBuffer = null; | ||||
| eolString = StringUtils.LINE_SEP; | eolString = StringUtils.LINE_SEP; | ||||
| rc = null; | rc = null; | ||||
| ignoreEmpty = true; | |||||
| } | } | ||||
| // Attribute setters. | // Attribute setters. | ||||
| @@ -574,6 +578,17 @@ public class Concat extends Task implements ResourceCollection { | |||||
| this.forceOverwrite = force; | 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. | // Nested element creators. | ||||
| /** | /** | ||||
| @@ -733,7 +748,7 @@ public class Concat extends Task implements ResourceCollection { | |||||
| log(destinationFile + " is up-to-date.", Project.MSG_VERBOSE); | log(destinationFile + " is up-to-date.", Project.MSG_VERBOSE); | ||||
| return; | return; | ||||
| } | } | ||||
| if (c.size() == 0) { | |||||
| if (c.size() == 0 && ignoreEmpty) { | |||||
| return; | return; | ||||
| } | } | ||||
| OutputStream out; | OutputStream out; | ||||
| @@ -74,4 +74,45 @@ | |||||
| </au:assertTrue> | </au:assertTrue> | ||||
| </target> | </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> | </project> | ||||