diff --git a/WHATSNEW b/WHATSNEW index ca2160ebc..c355e6f18 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -127,6 +127,9 @@ Fixed bugs: * ExecTask executes checkConfiguration() even though os does not match. Bugzilla report 31805. +* Concat task instance could not be run twice. + Bugzilla report 31814. + Changes from Ant 1.6.1 to Ant 1.6.2 =================================== diff --git a/src/main/org/apache/tools/ant/taskdefs/Concat.java b/src/main/org/apache/tools/ant/taskdefs/Concat.java index 8a7cdcf92..e1845cb70 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Concat.java +++ b/src/main/org/apache/tools/ant/taskdefs/Concat.java @@ -93,7 +93,7 @@ public class Concat extends Task { /** Stores the binary attribute */ private boolean binary = false; - + // Child elements. /** @@ -237,7 +237,6 @@ public class Concat extends Task { textBuffer.append(text); } - /** * Add a header to the concatenated output * @param header the header @@ -311,9 +310,9 @@ public class Concat extends Task { } /** - * This method performs the concatenation. + * This method checks the attributes and performs the concatenation. */ - public void execute() { + private void checkAndExecute() { // treat empty nested text as no text sanitizeText(); @@ -422,6 +421,17 @@ public class Concat extends Task { } } + /** + * execute the concat task. + */ + public void execute() { + try { + checkAndExecute(); + } finally { + resetTask(); + } + } + /** * Reset state to default. */ @@ -439,6 +449,14 @@ public class Concat extends Task { header = null; } + /** + * reset the used variables to allow the same task + * instance to be used again. + */ + private void resetTask() { + sourceFiles.clear(); + } + private void checkAddFiles(File base, String[] filenames) { for (int i = 0; i < filenames.length; ++i) { File file = new File(base, filenames[i]); @@ -471,7 +489,7 @@ public class Concat extends Task { "Unable to open " + destinationFile + " for writing", t); } - for (Iterator i = sourceFiles.iterator(); i.hasNext(); ) { + for (Iterator i = sourceFiles.iterator(); i.hasNext();) { File sourceFile = (File) i.next(); try { in = new FileInputStream(sourceFile);