You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2001/10/01 16:14:22 UTC
cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/condition IsSet.java ConditionBase.java
bodewig 01/10/01 07:14:22
Modified: docs/manual/CoreTasks condition.html
src/main/org/apache/tools/ant/taskdefs/condition
ConditionBase.java
Added: src/main/org/apache/tools/ant/taskdefs/condition IsSet.java
Log:
Add new <isset> condition, simplify ConditionBase by using ProjectComponent.
Revision Changes Path
1.2 +15 -0 jakarta-ant/docs/manual/CoreTasks/condition.html
Index: condition.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/condition.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- condition.html 2001/08/09 05:48:49 1.1
+++ condition.html 2001/10/01 14:14:22 1.2
@@ -121,6 +121,21 @@
</tr>
</table>
+<h4>isset</h4>
+<p>Test whether a given property has been set in this project.</p>
+<table border="1" cellpadding="2" cellspacing="0">
+ <tr>
+ <td valign="top"><b>Attribute</b></td>
+ <td valign="top"><b>Description</b></td>
+ <td align="center" valign="top"><b>Required</b></td>
+ </tr>
+ <tr>
+ <td valign="top">property</td>
+ <td valign="top">The name of the property to test.</td>
+ <td valign="top" align="center">Yes</td>
+ </tr>
+</table>
+
<h3>Examples</h3>
<pre>
<condition property="javamail.complete">
1.2 +12 -13 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
Index: ConditionBase.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ConditionBase.java 2001/08/03 16:38:20 1.1
+++ ConditionBase.java 2001/10/01 14:14:22 1.2
@@ -59,7 +59,7 @@
import java.util.Vector;
import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
+import org.apache.tools.ant.ProjectComponent;
import org.apache.tools.ant.taskdefs.Available;
import org.apache.tools.ant.taskdefs.UpToDate;
@@ -69,17 +69,11 @@
* and the "container" conditions are in sync.
*
* @author <a href="mailto:stefan.bodewig@epost.de>Stefan Bodewig</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
-public abstract class ConditionBase {
+public abstract class ConditionBase extends ProjectComponent {
private Vector conditions = new Vector();
- private Project project;
- public void setProject(Project p) {
- this.project = p;
- }
- protected Project getProject() {return project;}
-
/**
* Count the conditions.
*
@@ -146,6 +140,13 @@
public void addOs(Os o) {conditions.addElement(o);}
/**
+ * Add an <isset> condition.
+ *
+ * @since 1.1
+ */
+ public void addIsSet(IsSet i) {conditions.addElement(i);}
+
+ /**
* Inner class that configures those conditions with a project
* instance that need it.
*
@@ -166,10 +167,8 @@
throw new NoSuchElementException();
}
- if (o instanceof Task) {
- ((Task) o).setProject(getProject());
- } else if (o instanceof ConditionBase) {
- ((ConditionBase) o).setProject(getProject());
+ if (o instanceof ProjectComponent) {
+ ((ProjectComponent) o).setProject(getProject());
}
return o;
}
1.1 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java
Index: IsSet.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.taskdefs.condition;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ProjectComponent;
/**
* Condition that tests whether a given property has been set.
*
* @author <a href="mailto:stefan.bodewig@epost.de>Stefan Bodewig</a>
* @version $Revision: 1.1 $
*/
public class IsSet extends ProjectComponent implements Condition {
private String property;
public void setProperty(String p) {property = p;}
public boolean eval() throws BuildException {
if (property == null) {
throw new BuildException("No property specified for isset condition");
}
return getProject().getProperty(property) != null;
}
}