Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 20558 invoked from network); 17 Jun 2004 20:33:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 17 Jun 2004 20:33:21 -0000 Received: (qmail 90674 invoked by uid 500); 17 Jun 2004 20:33:37 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 90599 invoked by uid 500); 17 Jun 2004 20:33:37 -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 90582 invoked by uid 500); 17 Jun 2004 20:33:37 -0000 Received: (qmail 90570 invoked by uid 99); 17 Jun 2004 20:33:36 -0000 Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Thu, 17 Jun 2004 13:33:36 -0700 Received: (qmail 20473 invoked by uid 1818); 17 Jun 2004 20:33:13 -0000 Date: 17 Jun 2004 20:33:13 -0000 Message-ID: <20040617203313.20472.qmail@minotaur.apache.org> From: mbenson@apache.org To: ant-cvs@apache.org Subject: cvs commit: ant/docs/manual/CoreTasks fail.html X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N mbenson 2004/06/17 13:33:13 Modified: . WHATSNEW src/main/org/apache/tools/ant Main.java src/main/org/apache/tools/ant/taskdefs Exit.java docs/manual/CoreTasks fail.html Added: src/main/org/apache/tools/ant ExitStatusException.java Log: Add status attribute to . Idea/design by Aurele Venet. Revision Changes Path 1.625 +3 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.624 retrieving revision 1.625 diff -u -r1.624 -r1.625 --- WHATSNEW 16 Jun 2004 16:41:38 -0000 1.624 +++ WHATSNEW 17 Jun 2004 20:33:13 -0000 1.625 @@ -37,6 +37,9 @@ which will allow nonexistent files specified via s to be passed to the executable. Bugzilla Report 29585. +* has a status attribute that can be used to pass an exit + status back to the command line. + Changes from Ant 1.6.1 to current Ant 1.6 CVS version ===================================================== 1.107 +9 -2 ant/src/main/org/apache/tools/ant/Main.java Index: Main.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Main.java,v retrieving revision 1.106 retrieving revision 1.107 diff -u -r1.106 -r1.107 --- Main.java 20 Apr 2004 19:27:54 -0000 1.106 +++ Main.java 17 Jun 2004 20:33:13 -0000 1.107 @@ -184,8 +184,15 @@ // expect the worst int exitCode = 1; try { - runBuild(coreLoader); - exitCode = 0; + try { + runBuild(coreLoader); + exitCode = 0; + } catch (ExitStatusException ese) { + exitCode = ese.getStatus(); + if (exitCode > 0) { + throw ese; + } + } } catch (BuildException be) { if (err != System.err) { printMessage(be); 1.1 ant/src/main/org/apache/tools/ant/ExitStatusException.java Index: ExitStatusException.java =================================================================== /* * Copyright 2004 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. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.apache.tools.ant; /** * BuildException + exit status. * * @since Ant 1.7 */ public class ExitStatusException extends BuildException { /** Status code */ private int status; /** * Constructs an ExitStatusException. * @param status the associated status code */ public ExitStatusException(int status) { super(); this.status = status; } /** * Constructs an exit exception. * @param msg the associated message * @param status the associated status code */ public ExitStatusException(String msg, int status) { super(msg); this.status = status; } /** * Get the status code * * @return int */ public int getStatus() { return status; } } 1.33 +12 -1 ant/src/main/org/apache/tools/ant/taskdefs/Exit.java Index: Exit.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Exit.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- Exit.java 29 Apr 2004 22:10:56 -0000 1.32 +++ Exit.java 17 Jun 2004 20:33:13 -0000 1.33 @@ -19,6 +19,7 @@ import org.apache.tools.ant.Task; import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.ExitStatusException; import org.apache.tools.ant.taskdefs.condition.Condition; import org.apache.tools.ant.taskdefs.condition.ConditionBase; @@ -58,6 +59,7 @@ private String message; private String ifCondition, unlessCondition; private NestedCondition nestedCondition; + private Integer status; /** * A message giving further information on why the build exited. @@ -86,6 +88,14 @@ } /** + * Set the status code to associate with the thrown Exception. + * @param i the int status + */ + public void setStatus(int i) { + status = new Integer(i); + } + + /** * Throw a BuildException to exit (fail) the build. * If specified, evaluate conditions: * A single nested condition is accepted, but requires that the @@ -126,7 +136,8 @@ } } } - throw new BuildException(text); + throw ((status == null) ? new BuildException(text) + : new ExitStatusException(text, status.intValue())); } } 1.12 +7 -0 ant/docs/manual/CoreTasks/fail.html Index: fail.html =================================================================== RCS file: /home/cvs/ant/docs/manual/CoreTasks/fail.html,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- fail.html 29 Apr 2004 21:25:40 -0000 1.11 +++ fail.html 17 Jun 2004 20:33:13 -0000 1.12 @@ -36,6 +36,13 @@ exist in the current project No + + status + Exit using the specified status code; + assuming the generated Exception is not caught, the + JVM will exit with this status. Since Ant 1.7 + No +

Parameters specified as nested elements

--------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org