bodewig 2005/04/04 00:42:28 Modified: . Tag: ANT_16_BRANCH CONTRIBUTORS WHATSNEW docs/manual/OptionalTasks Tag: ANT_16_BRANCH rpm.html src/main/org/apache/tools/ant/taskdefs/optional Tag: ANT_16_BRANCH Rpm.java Log: merge Revision Changes Path No revision No revision 1.1.2.35 +1 -0 ant/CONTRIBUTORS Index: CONTRIBUTORS =================================================================== RCS file: /home/cvs/ant/CONTRIBUTORS,v retrieving revision 1.1.2.34 retrieving revision 1.1.2.35 diff -u -r1.1.2.34 -r1.1.2.35 --- CONTRIBUTORS 17 Mar 2005 08:13:56 -0000 1.1.2.34 +++ CONTRIBUTORS 4 Apr 2005 07:42:28 -0000 1.1.2.35 @@ -219,4 +219,5 @@ Yohann Roussel Yuji Yamano Yves Martin +Zach Garner Zdenek Wagner 1.503.2.213 +4 -2 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.503.2.212 retrieving revision 1.503.2.213 diff -u -r1.503.2.212 -r1.503.2.213 --- WHATSNEW 31 Mar 2005 14:26:12 -0000 1.503.2.212 +++ WHATSNEW 4 Apr 2005 07:42:28 -0000 1.503.2.213 @@ -1,5 +1,5 @@ -Changes from Ant 1.6.3 to current Ant 1.6 CVS version -===================================================== +Changes from Ant 1.6.3beta1 to current Ant 1.6 CVS version +========================================================== Changes that could break older environments: -------------------------------------------- @@ -7,6 +7,8 @@ Other changes: -------------- +* <rpm> has new attributes failonerror and quiet. + Fixed bugs: ----------- No revision No revision 1.6.2.4 +17 -6 ant/docs/manual/OptionalTasks/rpm.html Index: rpm.html =================================================================== RCS file: /home/cvs/ant/docs/manual/OptionalTasks/rpm.html,v retrieving revision 1.6.2.3 retrieving revision 1.6.2.4 diff -u -r1.6.2.3 -r1.6.2.4 --- rpm.html 12 Nov 2004 10:38:05 -0000 1.6.2.3 +++ rpm.html 4 Apr 2005 07:42:28 -0000 1.6.2.4 @@ -31,7 +31,7 @@ <tr> <td valign="top">topDir</td> <td valign="top"> - this is the directory which will have the expected + This is the directory which will have the expected subdirectories, SPECS, SOURCES, BUILD, SRPMS. If this isn't specified, the baseDir value is used </td> @@ -45,12 +45,12 @@ </tr> <tr> <td valign="top">removeSpec</td> - <td valign="top">this will remove the spec file from SPECS</td> + <td valign="top">This will remove the spec file from SPECS</td> <td align="center" valign="top">No</td> </tr> <tr> <td valign="top">removeSource</td> - <td valign="top"> Flag (optional, default=false) + <td valign="top">Flag (optional, default=false) to remove the sources after the build. See the the <tt>--rmsource</tt> option of rpmbuild.</td> <td align="center" valign="top">No</td> @@ -66,18 +66,29 @@ </tr> <tr> <td valign="top">command</td> - <td valign="top">very similar idea to the cvs task. the default is "-bb"</td> + <td valign="top">Very similar idea to the cvs task. the default is "-bb"</td> + <td align="center" valign="top">No</td> + </tr> + <tr> + <td valign="top">quiet</td> + <td valign="top">Suppress output. Defaults to false.</td> <td align="center" valign="top">No</td> </tr> <tr> <td valign="top">output/error</td> - <td valign="top">where standard output and error go</td> + <td valign="top">Where standard output and error go</td> + <td align="center" valign="top">No</td> + </tr> + <tr> + <td valign="top">failOnError</td> + <td valign="top">Stop the buildprocess if the RPM build command exits with + a non-zero retuncode. Defaults to false</td> <td align="center" valign="top">No</td> </tr> </table> <hr> -<p align="center">Copyright © 2001-2004 The Apache Software Foundation. All rights +<p align="center">Copyright © 2001-2005 The Apache Software Foundation. All rights Reserved.</p> </body> No revision No revision 1.18.2.5 +76 -15 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.18.2.4 retrieving revision 1.18.2.5 diff -u -r1.18.2.4 -r1.18.2.5 --- Rpm.java 9 Mar 2004 17:01:41 -0000 1.18.2.4 +++ Rpm.java 4 Apr 2005 07:42:28 -0000 1.18.2.5 @@ -1,5 +1,5 @@ /* - * Copyright 2001-2004 The Apache Software Foundation + * Copyright 2001-2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,6 +89,17 @@ private File error; /** + * Halt on error return value from rpm build. + */ + private boolean failOnError = false; + + /** + * Don't show output of RPM build command on console. This does not affect + * the printing of output and error messages to files. + */ + private boolean quiet = false; + + /** * Execute the task * * @throws BuildException is there is a problem in the task execution. @@ -123,8 +134,13 @@ OutputStream outputstream = null; OutputStream errorstream = null; if (error == null && output == null) { - streamhandler = new LogStreamHandler(this, Project.MSG_INFO, - Project.MSG_WARN); + if (!quiet) { + 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 { @@ -134,8 +150,10 @@ } catch (IOException e) { throw new BuildException(e, getLocation()); } - } else { + } else if (!quiet) { outputstream = new LogOutputStream(this, Project.MSG_INFO); + } else { + outputstream = new LogOutputStream(this, Project.MSG_DEBUG); } if (error != null) { try { @@ -145,24 +163,27 @@ } catch (IOException e) { throw new BuildException(e, getLocation()); } - } else { + } else if (!quiet) { errorstream = new LogOutputStream(this, Project.MSG_WARN); + } else { + errorstream = new LogOutputStream(this, Project.MSG_DEBUG); } streamhandler = new PumpStreamHandler(outputstream, errorstream); } - Execute exe = new Execute(streamhandler, null); - - exe.setAntRun(getProject()); - if (topDir == null) { - topDir = getProject().getBaseDir(); - } - exe.setWorkingDirectory(topDir); - - exe.setCommandline(toExecute.getCommandline()); + Execute exe = getExecute(toExecute, streamhandler); try { - exe.execute(); log("Building the RPM based on the " + specFile + " file"); + int returncode = exe.execute(); + 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()); } finally { @@ -263,6 +284,29 @@ } /** + * If <code>true</code>, stop the build process when the rpmbuild command + * exits with an error status. + * @param value <code>true</code> if it should halt, otherwise + * <code>false</code>. The default is <code>false</code>. + * + * @since Ant 1.6.3 + */ + public void setFailOnError(boolean value) { + failOnError = value; + } + + /** + * If true, output from the RPM build command will only be logged to DEBUG. + * @param value <code>false</code> if output should be logged, otherwise + * <code>true</code>. The default is <code>false</code>. + * + * @since Ant 1.6.3 + */ + public void setQuiet(boolean value) { + quiet = value; + } + + /** * Checks whether <code>rpmbuild</code> is on the PATH and returns * the absolute path to it - falls back to <code>rpm</code> * otherwise. @@ -295,4 +339,21 @@ return "rpm"; } + + /** + * @since Ant 1.6.3 + */ + protected Execute getExecute(Commandline toExecute, + ExecuteStreamHandler streamhandler) { + Execute exe = new Execute(streamhandler, null); + + exe.setAntRun(getProject()); + if (topDir == null) { + topDir = getProject().getBaseDir(); + } + exe.setWorkingDirectory(topDir); + + exe.setCommandline(toExecute.getCommandline()); + return exe; + } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]