From dev-return-65185-apmail-ant-dev-archive=ant.apache.org@ant.apache.org Thu Mar 17 12:01:23 2005 Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 88620 invoked from network); 17 Mar 2005 12:01:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 17 Mar 2005 12:01:23 -0000 Received: (qmail 90768 invoked by uid 500); 17 Mar 2005 12:01:22 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 90436 invoked by uid 500); 17 Mar 2005 12:01:21 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 90422 invoked by uid 500); 17 Mar 2005 12:01:21 -0000 Received: (qmail 90419 invoked by uid 99); 17 Mar 2005 12:01:21 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 17 Mar 2005 04:01:21 -0800 Received: (qmail 88589 invoked by uid 1146); 17 Mar 2005 12:01:19 -0000 Date: 17 Mar 2005 12:01:19 -0000 Message-ID: <20050317120119.88588.qmail@minotaur.apache.org> From: bodewig@apache.org To: ant-cvs@apache.org Subject: cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional Rpm.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N bodewig 2005/03/17 04:01:19 Modified: . CONTRIBUTORS WHATSNEW src/main/org/apache/tools/ant/taskdefs/optional Rpm.java Log: failOnError and showOutput attributes for Submitted by: Zach Garner In Ant 1.6.2 wouldn't fail even if the command failed, CVS HEAD would fail unconditionally if the command failed. If chose 1.6.2's behavior as default for failOnError (i.e. it is false by default). Revision Changes Path 1.47 +1 -0 ant/CONTRIBUTORS Index: CONTRIBUTORS =================================================================== RCS file: /home/cvs/ant/CONTRIBUTORS,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- CONTRIBUTORS 17 Mar 2005 08:10:49 -0000 1.46 +++ CONTRIBUTORS 17 Mar 2005 12:01:18 -0000 1.47 @@ -222,4 +222,5 @@ Yohann Roussel Yuji Yamano Yves Martin +Zach Garner Zdenek Wagner 1.785 +2 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.784 retrieving revision 1.785 diff -u -r1.784 -r1.785 --- WHATSNEW 17 Mar 2005 09:59:36 -0000 1.784 +++ WHATSNEW 17 Mar 2005 12:01:18 -0000 1.785 @@ -287,6 +287,8 @@ used to document packages that don't hold source files but a package.html file. Bugzilla Report 25339. +* has new attributes failonerror and showoutput attributes. + Fixed bugs: ----------- 1.25 +55 -8 ant/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java Index: Rpm.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- Rpm.java 9 Feb 2005 07:54:12 -0000 1.24 +++ Rpm.java 17 Mar 2005 12:01:19 -0000 1.25 @@ -90,6 +90,17 @@ private File error; /** + * Halt on error return value from rpm build. + */ + private boolean failOnError = false; + + /** + * Show output of RPM build command on console. This does not affect + * the printing of output and error messages to files. + */ + private boolean showoutput = true; + + /** * Execute the task * * @throws BuildException is there is a problem in the task execution. @@ -124,8 +135,13 @@ OutputStream outputstream = null; OutputStream errorstream = null; if (error == null && output == null) { - streamhandler = new LogStreamHandler(this, Project.MSG_INFO, - Project.MSG_WARN); + if (showoutput) { + streamhandler = new LogStreamHandler(this, Project.MSG_INFO, + Project.MSG_WARN); + } else { + streamhandler = new LogStreamHandler(this, Project.MSG_DEBUG, + Project.MSG_DEBUG); + } } else { if (output != null) { try { @@ -135,8 +151,10 @@ } catch (IOException e) { throw new BuildException(e, getLocation()); } - } else { + } else if (showoutput) { outputstream = new LogOutputStream(this, Project.MSG_INFO); + } else { + outputstream = new LogOutputStream(this, Project.MSG_DEBUG); } if (error != null) { try { @@ -146,8 +164,10 @@ } catch (IOException e) { throw new BuildException(e, getLocation()); } - } else { + } else if (showoutput) { errorstream = new LogOutputStream(this, Project.MSG_WARN); + } else { + errorstream = new LogOutputStream(this, Project.MSG_DEBUG); } streamhandler = new PumpStreamHandler(outputstream, errorstream); } @@ -164,10 +184,14 @@ try { log("Building the RPM based on the " + specFile + " file"); int returncode = exe.execute(); - if (returncode != 0) { - throw new BuildException("'" + - toExecute.getExecutable() + - "' failed with exit code "+returncode); + if (Execute.isFailure(returncode)) { + String msg = "'" + toExecute.getExecutable() + + "' failed with exit code " + returncode; + if (failOnError) { + throw new BuildException(msg); + } else { + log(msg, Project.MSG_ERR); + } } } catch (IOException e) { throw new BuildException(e, getLocation()); @@ -257,6 +281,29 @@ } /** + * If true, stop the build process when the rpmbuild command exits with + * an error status. + * @param value true if it should halt, otherwise + * false + * + * @since Ant 1.6.3 + */ + public void setFailOnError(boolean value) { + failOnError = value; + } + + /** + * If false, no output from the RPM build command will be logged. + * @param value true if output should be logged, otherwise + * false + * + * @since Ant 1.6.3 + */ + public void setShowoutput(boolean value) { + showoutput = value; + } + + /** * Checks whether rpmbuild is on the PATH and returns * the absolute path to it - falls back to rpm * otherwise. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org