Return-Path: Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: (qmail 62682 invoked from network); 5 Oct 2009 04:19:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Oct 2009 04:19:29 -0000 Received: (qmail 78218 invoked by uid 500); 5 Oct 2009 04:19:29 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 78148 invoked by uid 500); 5 Oct 2009 04:19:29 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 78139 invoked by uid 99); 5 Oct 2009 04:19:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Oct 2009 04:19:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Oct 2009 04:19:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9A45B23888E9; Mon, 5 Oct 2009 04:18:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r821676 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/Exit.java tests/antunit/taskdefs/fail-test.xml Date: Mon, 05 Oct 2009 04:18:34 -0000 To: notifications@ant.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091005041834.9A45B23888E9@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bodewig Date: Mon Oct 5 04:18:34 2009 New Revision: 821676 URL: http://svn.apache.org/viewvc?rev=821676&view=rev Log: Make fail task use the same if/unless logic as target Added: ant/core/trunk/src/tests/antunit/taskdefs/fail-test.xml (with props) Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exit.java Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exit.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exit.java?rev=821676&r1=821675&r2=821676&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exit.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exit.java Mon Oct 5 04:18:34 2009 @@ -19,6 +19,7 @@ package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.Project; +import org.apache.tools.ant.PropertyHelper; import org.apache.tools.ant.Task; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.ExitStatusException; @@ -59,7 +60,7 @@ } private String message; - private String ifCondition, unlessCondition; + private Object ifCondition, unlessCondition; private NestedCondition nestedCondition; private Integer status; @@ -73,23 +74,44 @@ } /** - * Only fail if a property of the given name exists in the current project. - * @param c property name + * Only fail if the given expression evaluates to true or the name + * of an existing property. + * @param c property name or evaluated expression + * @since Ant 1.8.0 */ - public void setIf(String c) { + public void setIf(Object c) { ifCondition = c; } /** - * Only fail if a property of the given name does not - * exist in the current project. - * @param c property name + * Only fail if the given expression evaluates to true or the name + * of an existing property. + * @param c property name or evaluated expression */ - public void setUnless(String c) { + public void setIf(String c) { + setIf((Object) c); + } + + /** + * Only fail if the given expression evaluates to false or tno + * property of the given name exists. + * @param c property name or evaluated expression + * @since Ant 1.8.0 + */ + public void setUnless(Object c) { unlessCondition = c; } /** + * Only fail if the given expression evaluates to false or tno + * property of the given name exists. + * @param c property name or evaluated expression + */ + public void setUnless(String c) { + setUnless((Object) c); + } + + /** * Set the status code to associate with the thrown Exception. * @param i the int status */ @@ -117,12 +139,10 @@ if (message != null && message.trim().length() > 0) { text = message.trim(); } else { - if (ifCondition != null && ifCondition.length() > 0 - && getProject().getProperty(ifCondition) != null) { + if (!testIfCondition()) { text = "if=" + ifCondition; } - if (unlessCondition != null && unlessCondition.length() > 0 - && getProject().getProperty(unlessCondition) == null) { + if (!testUnlessCondition()) { if (text == null) { text = ""; } else { @@ -173,10 +193,8 @@ * @return true if there is no if condition, or the named property exists */ private boolean testIfCondition() { - if (ifCondition == null || "".equals(ifCondition)) { - return true; - } - return getProject().getProperty(ifCondition) != null; + return PropertyHelper.getPropertyHelper(getProject()) + .testIfCondition(ifCondition); } /** @@ -185,10 +203,8 @@ * or there is a named property but it doesn't exist */ private boolean testUnlessCondition() { - if (unlessCondition == null || "".equals(unlessCondition)) { - return true; - } - return getProject().getProperty(unlessCondition) == null; + return PropertyHelper.getPropertyHelper(getProject()) + .testUnlessCondition(unlessCondition); } /** Added: ant/core/trunk/src/tests/antunit/taskdefs/fail-test.xml URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/fail-test.xml?rev=821676&view=auto ============================================================================== --- ant/core/trunk/src/tests/antunit/taskdefs/fail-test.xml (added) +++ ant/core/trunk/src/tests/antunit/taskdefs/fail-test.xml Mon Oct 5 04:18:34 2009 @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Propchange: ant/core/trunk/src/tests/antunit/taskdefs/fail-test.xml ------------------------------------------------------------------------------ svn:eol-style = native