@@ -89,6 +89,8 @@ public class ExecTask extends Task {
private String os;
private String os;
private File out;
private File out;
private File error;
private File error;
private boolean logError = false;
private File dir;
private File dir;
protected boolean failOnError = false;
protected boolean failOnError = false;
@@ -173,6 +175,15 @@ public class ExecTask extends Task {
this.out = out;
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.
* File the error stream of the process is redirected to.
*
*
@@ -485,7 +496,8 @@ public class ExecTask extends Task {
if (outputprop != null) {
if (outputprop != null) {
baos = new ByteArrayOutputStream();
baos = new ByteArrayOutputStream();
log("Output redirected to ByteArray", Project.MSG_VERBOSE);
log("Output redirected to property: " + outputprop,
Project.MSG_VERBOSE);
if (out == null) {
if (out == null) {
outputStream = baos;
outputStream = baos;
} else {
} else {
@@ -498,11 +510,15 @@ public class ExecTask extends Task {
errorStream = outputStream;
errorStream = outputStream;
}
}
if (logError) {
errorStream = new LogOutputStream(this, Project.MSG_WARN);
}
if (error != null) {
if (error != null) {
try {
try {
errorStream
errorStream
= new FileOutputStream(error.getAbsolutePath(), append);
= new FileOutputStream(error.getAbsolutePath(), append);
log("Error redirected to " + out , Project.MSG_VERBOSE);
log("Error redirected to " + error , Project.MSG_VERBOSE);
} catch (FileNotFoundException fne) {
} catch (FileNotFoundException fne) {
throw new BuildException("Cannot write to " + error, fne,
throw new BuildException("Cannot write to " + error, fne,
getLocation());
getLocation());
@@ -514,7 +530,8 @@ public class ExecTask extends Task {
if (errorProperty != null) {
if (errorProperty != null) {
errorBaos = new ByteArrayOutputStream();
errorBaos = new ByteArrayOutputStream();
log("Error redirected to ByteArray", Project.MSG_VERBOSE);
log("Error redirected to property: " + errorProperty,
Project.MSG_VERBOSE);
if (error == null) {
if (error == null) {
errorStream = errorBaos;
errorStream = errorBaos;
} else {
} else {