diff --git a/docs/index.html b/docs/index.html index 51629d8e1..bb66caa97 100644 --- a/docs/index.html +++ b/docs/index.html @@ -900,6 +900,12 @@ preferred over the checkout command, because of speed.
<cvs cvsRoot=":pserver:anoncvs@jakarta.apache.org:/home/cvspublic" @@ -1067,6 +1073,12 @@ systems. redirected.Yes ++ failonerror +Stop the buildprocess if the command exits with a + returncode other than 0. +No +Examples
@@ -1569,6 +1581,12 @@ the one that is currently running Ant. disabled)No ++ failonerror +Stop the buildprocess if the command exits with a + returncode other than 0. Only available if fork is true. +No +Examples
<java classname="test.Main" />@@ -2077,6 +2095,12 @@ instead.1.2 No ++ failonerror +Stop the buildprocess if the command exits with a + returncode other than 0. +No +Parameters specified as nested elements
@@ -2284,6 +2308,12 @@ necessary. slashes from filenames.No ++ failonerror +Stop the buildprocess if the command exits with a + returncode other than 0. +No +Examples
<patch patchfile="module.1.0-1.1.patch" />diff --git a/src/main/org/apache/tools/ant/taskdefs/Exec.java b/src/main/org/apache/tools/ant/taskdefs/Exec.java index af1629e25..7e1c69909 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Exec.java +++ b/src/main/org/apache/tools/ant/taskdefs/Exec.java @@ -70,6 +70,7 @@ public class Exec extends Task { private File dir; private String command; protected PrintWriter fos = null; + private boolean failOnError = false; private static final int BUFFER_SIZE = 512; @@ -138,7 +139,11 @@ public class Exec extends Task { // check its exit value err = proc.exitValue(); if (err != 0) { - log("Result: " + err, Project.MSG_ERR); + if (failOnError) { + throw new BuildException("Exec returned: "+err, location); + } else { + log("Result: " + err, Project.MSG_ERR); + } } } catch (IOException ioe) { throw new BuildException("Error exec: " + command, ioe, location); @@ -163,6 +168,10 @@ public class Exec extends Task { this.out = out; } + public void setFailonerror(String fail) { + failOnError = Project.toBoolean(fail); + } + protected void outputLog(String line, int messageLevel) { if (fos == null) { log(line, messageLevel);