I just created the improvement in Apache Bug Database.
There is the proposed patch to fix it.
Add an append attribute and timeout attribute to the java command.
append to add to output file if specified.
timeout to stop the command if running for too long.
Java.java modified as well as java.html (corresponding documentation).
Thomas
Index: docs/manual/CoreTasks/java.html
===================================================================
RCS file: /home/cvspublic/jakarta-ant/docs/manual/CoreTasks/java.html,v
retrieving revision 1.6
diff -u -r1.6 java.html
--- docs/manual/CoreTasks/java.html 2001/11/27 20:17:02 1.6
+++ docs/manual/CoreTasks/java.html 2001/12/04 03:42:35
@@ -94,6 +94,16 @@
<td valign="top">Name of a file to write the output to.</td>
<td align="center" valign="top">No</td>
</tr>
+ <tr>
+ <td valign="top">append</td>
+ <td valign="top">Append to the output file if specified.</td>
+ <td align="center" valign="top">No - default is false.</td>
+ </tr>
+ <tr>
+ <td valign="top">timeout</td>
+ <td valign="top">Stop the command if it doesn't finish within the
specified time (given in milliseconds).</td>
+ <td align="center" valign="top">No</td>
+ </tr>
</table>
<h3>Parameters specified as nested elements</h3>
<h4>arg and jvmarg</h4>
Index: src/main/org/apache/tools/ant/taskdefs/Java.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java,v
retrieving revision 1.30
diff -u -r1.30 Java.java
--- src/main/org/apache/tools/ant/taskdefs/Java.java 2001/10/28 21:26:29
1.30
+++ src/main/org/apache/tools/ant/taskdefs/Java.java 2001/12/04 03:42:35
@@ -86,6 +86,8 @@
private File out;
private PrintStream outStream = null;
private boolean failOnError = false;
+ private boolean append = false;
+ private Integer timeout = null;
/**
* Do the execution.
@@ -268,6 +270,28 @@
cmdl.setVmversion(value);
}
+ /**
+ * Shall we append to an existing file?
+ */
+ public void setAppend(boolean append) {
+ this.append = append;
+ }
+
+ /**
+ * Timeout in milliseconds after which the process will be killed.
+ */
+ public void setTimeout(Integer value) {
+ timeout = value;
+ }
+
+ /**
+ * Create the Watchdog to kill a runaway process.
+ */
+ protected ExecuteWatchdog createWatchdog() throws BuildException {
+ if (timeout == null) return null;
+ return new ExecuteWatchdog(timeout.intValue());
+ }
+
protected void handleOutput(String line) {
if (outStream != null) {
outStream.println(line);
@@ -297,7 +321,7 @@
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);
@@ -323,10 +347,10 @@
if (out == null) {
exe = new Execute(new LogStreamHandler(this, Project.MSG_INFO,
Project.MSG_WARN),
- null);
+ createWatchdog());
} else {
- fos = new FileOutputStream(out);
- exe = new Execute(new PumpStreamHandler(fos), null);
+ fos = new FileOutputStream(out.getAbsolutePath(), append);
+ exe = new Execute(new PumpStreamHandler(fos),
createWatchdog());
}
exe.setAntRun(project);
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>