ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: cvs commit: ant/src/etc/testcases/taskdefs fail.xml
Date Thu, 29 Apr 2004 22:08:53 GMT
The way Peter originally suggested to fix this was the
simplest.  I originally coded up that change in
December or January, I think... it didn't strike me as
a BC issue because I didn't think about the
possibility that someone would want to extend
Exit/<fail>... oh, well...

-Matt


--- mbenson@apache.org wrote:
> mbenson     2004/04/29 14:25:40
> 
>   Modified:   
> src/testcases/org/apache/tools/ant/taskdefs
> FailTest.java
>                docs/manual/CoreTasks fail.html
>               
> src/main/org/apache/tools/ant/taskdefs Exit.java
>                src/etc/testcases/taskdefs fail.xml
>   Log:
>   Restore Task inheritance to Exit/<fail>.
>   
>   Revision  Changes    Path
>   1.15      +15 -2    
>
ant/src/testcases/org/apache/tools/ant/taskdefs/FailTest.java
>   
>   Index: FailTest.java
>  
>
===================================================================
>   RCS file:
>
/home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/FailTest.java,v
>   retrieving revision 1.14
>   retrieving revision 1.15
>   diff -u -r1.14 -r1.15
>   --- FailTest.java	28 Apr 2004 18:08:47 -0000	1.14
>   +++ FailTest.java	29 Apr 2004 21:25:40 -0000	1.15
>   @@ -138,7 +138,7 @@
>        public void testNested5() {
>           
> expectSpecificBuildException("testNested5",
>                "it is required to fail :-)",
>   -            "Too many conditions:  2");
>   +            "Only one nested condition is
> allowed.");
>        }
>    
>        public void testNested6() {
>   @@ -147,4 +147,17 @@
>               
> "testNested6\ntestNested6\ntestNested6");
>        }
>    
>   - }
>   +    public void testNested7() {
>   +        String specificMessage = "A single nested
> condition is required.";
>   +
>   +        char[] c = {'a', 'b'};
>   +        StringBuffer target = new
> StringBuffer("testNested7x");
>   +
>   +        for (int i = 0; i < c.length; i++) {
>   +            target.setCharAt(target.length() - 1,
> c[i]);
>   +           
> expectSpecificBuildException(target.toString(),
>   +                "it is required to fail :-)",
> specificMessage);
>   +        }
>   +    }
>   +
>   +}
>   
>   
>   
>   1.11      +11 -8    
> ant/docs/manual/CoreTasks/fail.html
>   
>   Index: fail.html
>  
>
===================================================================
>   RCS file:
> /home/cvs/ant/docs/manual/CoreTasks/fail.html,v
>   retrieving revision 1.10
>   retrieving revision 1.11
>   diff -u -r1.10 -r1.11
>   --- fail.html	28 Apr 2004 18:08:47 -0000	1.10
>   +++ fail.html	29 Apr 2004 21:25:40 -0000	1.11
>   @@ -41,10 +41,10 @@
>    <h3>Parameters specified as nested elements</h3>
>    
>    <p>As an alternative to the
> <i>if</i>/<i>unless</i> attributes,
>   -  conditional failure can be achieved using a
> single nested condition.
>   -  For a complete list of core conditions, as well
> as information
>   -  about custom conditions, see <a
> href="conditions.html">here</a>.<br />
>   -  <b>Since Ant 1.6.2</b>
>   +  conditional failure can be achieved using a
> single nested
>   +  &lt;condition&gt; element, which should contain
> exactly one
>   +  core or custom condition.  For information
> about conditions, see
>   +  <a href="conditions.html">here</a>.<br
> /><b>Since Ant 1.6.2</b>
>    </p>
>    
>    <h3>Examples</h3>
>   @@ -79,12 +79,15 @@
>    build.xml:2: unless=thisdoesnotexist
>    </pre>
>    
>   -A simple example using conditions to achieve the
> same effect:
>   +Using a condition to achieve the same effect:
>   +
>    <pre>
>      &lt;fail&gt;
>   -     &lt;not&gt;
>   -       &lt;isset
> property=&quot;thisdoesnotexist&quot;/&gt;
>   -     &lt;/not&gt;
>   +     &lt;condition&gt;
>   +       &lt;not&gt;
>   +         &lt;isset
> property=&quot;thisdoesnotexist&quot;/&gt;
>   +       &lt;/not&gt;
>   +     &lt;/condition&gt;
>       &lt;/fail&gt;
>    </pre>
>    
>   
>   
>   
>   1.31      +39 -11   
> 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.30
>   retrieving revision 1.31
>   diff -u -r1.30 -r1.31
>   --- Exit.java	28 Apr 2004 18:08:47 -0000	1.30
>   +++ Exit.java	29 Apr 2004 21:25:40 -0000	1.31
>   @@ -17,6 +17,8 @@
>    
>    package org.apache.tools.ant.taskdefs;
>    
>   +import java.util.Vector;
>   +import org.apache.tools.ant.Task;
>    import org.apache.tools.ant.BuildException;
>    import
> org.apache.tools.ant.taskdefs.condition.Condition;
>    import
>
org.apache.tools.ant.taskdefs.condition.ConditionBase;
>   @@ -42,9 +44,21 @@
>     *
>     * @ant.task name="fail" category="control"
>     */
>   -public class Exit extends ConditionBase {
>   +public class Exit extends Task {
>   +
>   +    private class NestedCondition extends
> ConditionBase implements Condition {
>   +        public boolean eval() {
>   +            if (countConditions() != 1) {
>   +                throw new BuildException(
>   +                    "A single nested condition is
> required.");
>   +            }
>   +            return
> ((Condition)(getConditions().nextElement())).eval();
>   +        }
>   +    }
>   +
>        private String message;
>        private String ifCondition, unlessCondition;
>   +    private NestedCondition nestedCondition;
>    
>        /**
>         * A message giving further information on
> why the build exited.
>   @@ -129,6 +143,19 @@
>        }
>    
>        /**
>   +     * Add a condition element.
>   +     * @return <CODE>ConditionBase</CODE>.
>   +     * @since Ant 1.6.2
>   +     */
>   +    public ConditionBase createCondition() {
>   +        if (nestedCondition != null) {
>   +            throw new BuildException("Only one
> nested condition is allowed.");
>   +        }
>   +        nestedCondition = new NestedCondition();
>   +        return nestedCondition;
>   +    }
>   +
>   +    /**
>         * test the if condition
>         * @return true if there is no if condition,
> or the named property exists
>         */
>   @@ -156,21 +183,22 @@
> 
=== message truncated ===



	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

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


Mime
View raw message