I'm dont want to commit these until people have had a look at the changes
and are happy with them.
Apart from some tabs to spaces conversion , the two big changes here are
1. you can specify a resultproperty that saves the result value into an
(undefined) property. Obviously only of relevance if failonerror=false
2. when failonerror=false, failure to exec a task does not break the build,
only report an error message [and leave the resultproperty untouched]. This
addresses bug 5025; that failonerror didnt catch all failure modes of the
task.
Comments? Opinions?
Index: ExecTask.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ExecTask.java,v
retrieving revision 1.17
diff -r1.17 ExecTask.java
94a95
> private String resultProperty;
180a182,202
> * fill a property in with a result.
> * when no property is defined: failure to execute
> * @since 1.5
> */
> public void setResultProperty(String resultProperty) {
> this.resultProperty=resultProperty;
> }
>
> /**
> * helper method to set result property to the
> * passed in value if appropriate
> */
> protected void maybeSetResultPropertyValue(int result) {
> String res=Integer.toString(result);
> if(resultProperty!=null
> && project.getProperty(resultProperty) == null) {
> project.setProperty(resultProperty,res);
> }
> }
>
> /**
198c220
< throw new BuildException("The directory you specified does not
exist");
---
> throw new BuildException("The directory you specified does not
> exist");
201c223
< throw new BuildException("The directory you specified is not a
directory");
---
> throw new BuildException("The directory you specified is not a
> directory");
258d279
<
259a281
> maybeSetResultPropertyValue(err);
290c312,316
< throw new BuildException("Execute failed: " + e, e, location);
---
> if (failOnError) {
> throw new BuildException("Execute failed: ",e, location);
> } else {
> log("Execute failed: "+e.toString(), Project.MSG_ERR);
> }
312,315c338,341
< // try {
< baos = new ByteArrayOutputStream();
< log("Output redirected to ByteArray", Project.MSG_VERBOSE);
< return new PumpStreamHandler(baos);
---
> // try {
> baos = new ByteArrayOutputStream();
> log("Output redirected to ByteArray", Project.MSG_VERBOSE);
> return new PumpStreamHandler(baos);
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>