diff --git a/docs/manual/CoreTasks/exec.html b/docs/manual/CoreTasks/exec.html index 9028c7b4a..dc634acb9 100644 --- a/docs/manual/CoreTasks/exec.html +++ b/docs/manual/CoreTasks/exec.html @@ -64,6 +64,15 @@ Windows executable and is not aware of Cygwin conventions. redirected. No + + logError + This attribute is used when you wish to see error output in Ant's + log and you are redirecting output to a file/property. The error + output will not be included in the output file/property. If you + redirect error with the "error" or "errorProperty" + attributes, this will have no effect. + No + append whether output and error files should be appended to or overwritten. diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java index 88aa7fd78..77cef2ade 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java @@ -89,6 +89,8 @@ public class ExecTask extends Task { private String os; private File out; private File error; + + private boolean logError = false; private File dir; protected boolean failOnError = false; @@ -173,6 +175,15 @@ public class ExecTask extends Task { this.out = out; } + /** + * Controls whether error output of exec is logged. This is only useful + * when output is being redirected and error output is desired in the + * Ant log + */ + public void setLogError(boolean logError) { + this.logError = logError; + } + /** * File the error stream of the process is redirected to. * @@ -485,7 +496,8 @@ public class ExecTask extends Task { if (outputprop != null) { baos = new ByteArrayOutputStream(); - log("Output redirected to ByteArray", Project.MSG_VERBOSE); + log("Output redirected to property: " + outputprop, + Project.MSG_VERBOSE); if (out == null) { outputStream = baos; } else { @@ -498,11 +510,15 @@ public class ExecTask extends Task { errorStream = outputStream; } + if (logError) { + errorStream = new LogOutputStream(this, Project.MSG_WARN); + } + if (error != null) { try { errorStream = new FileOutputStream(error.getAbsolutePath(), append); - log("Error redirected to " + out, Project.MSG_VERBOSE); + log("Error redirected to " + error, Project.MSG_VERBOSE); } catch (FileNotFoundException fne) { throw new BuildException("Cannot write to " + error, fne, getLocation()); @@ -514,7 +530,8 @@ public class ExecTask extends Task { if (errorProperty != null) { errorBaos = new ByteArrayOutputStream(); - log("Error redirected to ByteArray", Project.MSG_VERBOSE); + log("Error redirected to property: " + errorProperty, + Project.MSG_VERBOSE); if (error == null) { errorStream = errorBaos; } else { diff --git a/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java b/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java index d68152cdc..4efe0a8e4 100644 --- a/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java +++ b/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without