diff --git a/WHATSNEW b/WHATSNEW
index 60518ca96..e930471a5 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -275,6 +275,9 @@ Other changes:
* now has a 'srcfile' attribute to allow specifying a
full-path filename.
+* , and now support append attributes to allow
+ appending the output to an existing file.
+
Changes from Ant 1.4 to Ant 1.4.1
===========================================
diff --git a/docs/manual/CoreTasks/exec.html b/docs/manual/CoreTasks/exec.html
index 8bd451290..f7b766570 100644
--- a/docs/manual/CoreTasks/exec.html
+++ b/docs/manual/CoreTasks/exec.html
@@ -50,6 +50,12 @@ systems.
redirected.
No |
+
+ append |
+ whether output should be appended to or overwrite
+ an existing file. Defaults to false. |
+ No |
+
outputproperty |
the name of a property in which the output of the
diff --git a/docs/manual/CoreTasks/java.html b/docs/manual/CoreTasks/java.html
index c961dda9c..7951e56fc 100644
--- a/docs/manual/CoreTasks/java.html
+++ b/docs/manual/CoreTasks/java.html
@@ -94,6 +94,12 @@ JVM.
| Name of a file to write the output to. |
No |
+
+ append |
+ whether output should be appended to or overwrite
+ an existing file. Defaults to false. |
+ No |
+
newenvironment |
Do not propagate old environment when new
diff --git a/docs/manual/CoreTasks/sql.html b/docs/manual/CoreTasks/sql.html
index 1cd2b4c2c..9ce04e80b 100644
--- a/docs/manual/CoreTasks/sql.html
+++ b/docs/manual/CoreTasks/sql.html
@@ -88,6 +88,12 @@ and abort execution and transaction and fail task.
| Output file for result sets (defaults to System.out) |
No (print to System.out by default) |
+
+ append |
+ whether output should be appended to or overwrite
+ an existing file. Defaults to false. |
+ No |
+
classpath |
Classpath used to load driver |
diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java
index bd5473e6d..4d90045b5 100644
--- a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java
@@ -96,6 +96,7 @@ public class ExecTask extends Task {
private String outputprop;
private String resultProperty;
private boolean failIfExecFails=true;
+ private boolean append = false;
/** Controls whether the VM (1.3 and above) is used to execute the command */
private boolean vmLauncher = true;
@@ -208,6 +209,15 @@ public class ExecTask extends Task {
failIfExecFails=flag;
}
+ /**
+ * Shall we append to an existing file?
+ *
+ * @since 1.30, Ant 1.5
+ */
+ public void setAppend(boolean append) {
+ this.append = append;
+ }
+
/**
* Do the work.
*/
@@ -342,7 +352,7 @@ public class ExecTask extends Task {
protected ExecuteStreamHandler createHandler() throws BuildException {
if(out!=null) {
try {
- fos = new FileOutputStream(out);
+ fos = new FileOutputStream(out.getAbsolutePath(), append);
log("Output redirected to " + out, Project.MSG_VERBOSE);
return new PumpStreamHandler(fos);
} catch (FileNotFoundException fne) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/Java.java b/src/main/org/apache/tools/ant/taskdefs/Java.java
index ad73bf307..6c2cd0d44 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Java.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Java.java
@@ -90,6 +90,7 @@ public class Java extends Task {
private File out;
private PrintStream outStream = null;
private boolean failOnError = false;
+ private boolean append = false;
/**
* Do the execution.
@@ -299,6 +300,15 @@ public class Java extends Task {
newEnvironment = newenv;
}
+ /**
+ * Shall we append to an existing file?
+ *
+ * @since 1.36, Ant 1.5
+ */
+ public void setAppend(boolean append) {
+ this.append = append;
+ }
+
protected void handleOutput(String line) {
if (outStream != null) {
outStream.println(line);
@@ -328,7 +338,9 @@ public class Java extends Task {
exe.setSystemProperties(command.getSystemProperties());
if (out != null) {
try {
- outStream = new PrintStream(new FileOutputStream(out));
+ outStream =
+ new PrintStream(new FileOutputStream(out.getAbsolutePath(),
+ append));
exe.execute(project);
} catch (IOException io) {
throw new BuildException(io, location);
@@ -356,7 +368,7 @@ public class Java extends Task {
Project.MSG_WARN),
null);
} else {
- fos = new FileOutputStream(out);
+ fos = new FileOutputStream(out.getAbsolutePath(), append);
exe = new Execute(new PumpStreamHandler(fos), null);
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
index 4072d8e6e..c0d12c490 100644
--- a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
+++ b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
@@ -227,6 +227,10 @@ public class SQLExec extends Task {
*/
private String encoding = null;
+ /**
+ * Append to an existing file or overwrite it?
+ */
+ private boolean append = false;
public void setCaching(boolean value){
caching = value;
@@ -377,6 +381,15 @@ public class SQLExec extends Task {
this.output = output;
}
+ /**
+ * Shall we append to an existing file?
+ *
+ * @since 1.36, Ant 1.5
+ */
+ public void setAppend(boolean append) {
+ this.append = append;
+ }
+
/**
* Set the rdbms required
*/
@@ -510,7 +523,7 @@ public class SQLExec extends Task {
try {
if (output != null) {
log("Opening PrintStream to output file " + output, Project.MSG_VERBOSE);
- out = new PrintStream(new BufferedOutputStream(new FileOutputStream(output)));
+ out = new PrintStream(new BufferedOutputStream(new FileOutputStream(output.getAbsolutePath(), append)));
}
// Process all transactions