Woops bad conditional crept in there.
The fixed patch is attached.

Michael
--- BEGIN GEEK CODE BLOCK ---
Version 3.12
GCS d+(-) s:- a-- C++(+++)$ UL++++(H)(S)$ P+++$ L+++$>++++
E--- W++ N++ o++ K? !w() O? !M V? PS+ PE+++ Y+ t+ 5++ X++ 
R(+) !tv b++(++++) D++ G>++ e++> h--()(*) r+ y+()
--- END GEEK CODE BLOCK ---

Index: src/main/org/apache/tools/ant/taskdefs/Exit.java
===================================================================
RCS file: 
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Exit.java,v
retrieving revision 1.2
diff -c -r1.2 Exit.java
*** src/main/org/apache/tools/ant/taskdefs/Exit.java    2001/01/03 14:18:30     
1.2
--- src/main/org/apache/tools/ant/taskdefs/Exit.java    2001/03/07 22:30:06
***************
*** 55,79 ****
  package org.apache.tools.ant.taskdefs;
  
  import org.apache.tools.ant.*;
  
  /**
   * Just exit the active build, giving an additional message 
   * if available.
   *
   * @author Nico Seessle <[EMAIL PROTECTED]>
   */
  public class Exit extends Task { 
!     private String message;
      
!     public void setMessage(String value) { 
!         this.message = value;
      }
!     
      public void execute() throws BuildException {
!         if (message != null && message.length() > 0) { 
!             throw new BuildException(message);
!         } else {
!             throw new BuildException("No message");
          }
      }
  }
--- 55,138 ----
  package org.apache.tools.ant.taskdefs;
  
  import org.apache.tools.ant.*;
+ import java.util.Enumeration;
+ import java.util.Hashtable;
  
  /**
   * Just exit the active build, giving an additional message 
   * if available.
+  * 
+  * Can supply conditional properties.
+  * With an <Strong>if</Strong> the task will exit if the property is set.
+  * With an <Strong>unless</Strong> the task will exit if the property is not 
set.
   *
   * @author Nico Seessle <[EMAIL PROTECTED]>
+  * @author <A href="mailto:[EMAIL PROTECTED]">Michael McCallum</A>
   */
  public class Exit extends Task { 
! 
!     /** The message to display. */
!     private String message_;
! 
!     /** The if value. Will exit if this value is set. */
!     private String ifProperty_;
! 
!     /** The unless value. Will exit if this value is not set. */
!     private String unlessProperty_;
      
!     /** Test to see if the given property is set.
!     * Returns true if we should exit. That is when there is an if condition 
and the property is set.
!     * @param property The property to test.
!     * @return true if we should fail of false if we should continue. */
!     private boolean testIfProperty( String property ) {
!       // if its not set return true as we dont know if we should continue.
!       if ( property == null || property.length() == 0 ) {
!         return true;
!       }
!       return project.getProperty( property ) != null;
      }
! 
!     /** Test to see if the given property is set.
!     * Returns true if we should exit. That is when there is an unless 
condition and the property is not set.
!     * @param property The property to test. 
!     * @return true if we should fail of false if we should continue. */
!     private boolean testUnlessProperty( String property ) {
!       // if its not set return true as we dont know if we should continue.
!       if ( property == null || property.length() == 0 ) {
!         return true;
!       }
!       return project.getProperty( property ) == null;
!     }
! 
!     /** Set the message to display when executed. */
!     public void setMessage( String value ) { 
!       this.message_ = value;
!     }
! 
!     /** Set the if property. Will exit if this value is set.
!     * @param value The if value for conditional exiting. */
!     public void setIf( String value ) {
!       this.ifProperty_ = value;
!     }
! 
!     /** Set the unless property. Will exit if this value is not set.
!     * @param value The unless value for conditional exiting. */
!     public void setUnless( String value ) { 
!       this.unlessProperty_ = value;
!     }
! 
!     /** Execute this task. This will exit and print a message if the 
following conditions are met...
!     * if value is set.
!     * unless value is not set. */
      public void execute() throws BuildException {
!       if ( testUnlessProperty( unlessProperty_ ) && testIfProperty( 
ifProperty_ ) ) {
!         if ( message_ != null && message_.length() > 0 ) { 
!           throw new BuildException(message_);
!         } 
!         else {
!           throw new BuildException("No message");
          }
+       }
      }
+ 
  }

Reply via email to