From 18ea21ee7d078ff1b74271b5a56c6d51dc7f0108 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Fri, 1 Jun 2001 04:50:42 +0000 Subject: [PATCH] Added failonError attribute. Submitted By: Iulian Musat git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269077 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/taskdefs/Cvs.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Cvs.java b/src/main/org/apache/tools/ant/taskdefs/Cvs.java index 87e86075c..5206d0989 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Cvs.java +++ b/src/main/org/apache/tools/ant/taskdefs/Cvs.java @@ -121,6 +121,13 @@ public class Cvs extends Task { */ private File error; + /** + * If true it will stop the build if cvs exits with error. + * Default is false. (Iulian) + */ + private boolean failOnError = false; + + public void execute() throws BuildException { // XXX: we should use JCVS (www.ice.com/JCVS) instead of command line @@ -206,7 +213,10 @@ public class Cvs extends Task { exe.setCommandline(toExecute.getCommandline()); exe.setEnvironment(env.getVariables()); try { - exe.execute(); + int retCode = exe.execute(); + /*Throw an exception if cvs exited with error. (Iulian)*/ + if(failOnError && retCode != 0) + throw new BuildException("cvs exited with error code "+ retCode); } catch (IOException e) { throw new BuildException(e, location); } finally { @@ -284,6 +294,10 @@ public class Cvs extends Task { public void setError(File error) { this.error = error; } + + public void setFailOnError(boolean failOnError) { + this.failOnError = failOnError; + } }