diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 516394b4d..14a698b45 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -173,6 +173,7 @@ Marcus Börger Mario Frasca Mariusz Nowostawski Mark Hecker +Mark Salter Mark R. Diggory Martijn Kruithof Martin Landers diff --git a/WHATSNEW b/WHATSNEW index 8392e5db0..8fcff2988 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -463,6 +463,12 @@ Other changes: * and friends now support modules with spaces in their names via nested elements. + * A new attribute "ignoreEmpty" controls how 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 ============================================= diff --git a/contributors.xml b/contributors.xml index 52b339594..8d8d9d26c 100644 --- a/contributors.xml +++ b/contributors.xml @@ -704,7 +704,7 @@ Marcus - Börger + Börger Mario @@ -718,6 +718,10 @@ Mark Hecker + + Mark + Salter + Mark R. diff --git a/docs/manual/CoreTasks/concat.html b/docs/manual/CoreTasks/concat.html index 9a4ab6082..a2c5646fd 100644 --- a/docs/manual/CoreTasks/concat.html +++ b/docs/manual/CoreTasks/concat.html @@ -32,7 +32,8 @@ Concatenates one or more resources 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.

Since Ant 1.7.1, this task can be used as a @@ -158,7 +159,17 @@ Resource Collections are used to set, and the task cannot used nested text. Also the attributes encoding, outputencoding, filelastline cannot be used. - The default is false. + The default is "false". + + No + + + ignoreempty + + Since Ant 1.8.0 + Specifies whether or not the file specified by 'destfile' + should be created if the source resource list is + empty. Defaults to "true". No diff --git a/src/main/org/apache/tools/ant/taskdefs/Concat.java b/src/main/org/apache/tools/ant/taskdefs/Concat.java index aedcd5cfd..37c2286e7 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Concat.java +++ b/src/main/org/apache/tools/ant/taskdefs/Concat.java @@ -479,6 +479,9 @@ public class Concat extends Task implements ResourceCollection { 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 @@ public class Concat extends Task implements ResourceCollection { textBuffer = null; eolString = StringUtils.LINE_SEP; rc = null; + ignoreEmpty = true; } // Attribute setters. @@ -574,6 +578,17 @@ public class Concat extends Task implements ResourceCollection { this.forceOverwrite = force; } + /** + * Sets the behavior when no source resource files are available. If set to + * false the destination file will always be created. + * Defaults to true. + * @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 @@ public class Concat extends Task implements ResourceCollection { log(destinationFile + " is up-to-date.", Project.MSG_VERBOSE); return; } - if (c.size() == 0) { + if (c.size() == 0 && ignoreEmpty) { return; } OutputStream out; diff --git a/src/tests/antunit/taskdefs/concat-test.xml b/src/tests/antunit/taskdefs/concat-test.xml index 4e2434129..140bdbc14 100644 --- a/src/tests/antunit/taskdefs/concat-test.xml +++ b/src/tests/antunit/taskdefs/concat-test.xml @@ -74,4 +74,45 @@ + + + + + + + + + + + + + + + + + + + + + + + +

+ header +
+
+ + + + + + + + + +
footer
+
+ + +