From 5ddfc9ea915a39428fe1c7f01ee7a4e265123a68 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig
<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);