[EMAIL PROTECTED] wrote:
Author: mbenson
Date: Thu Aug 31 12:04:12 2006
New Revision: 439014
URL: http://svn.apache.org/viewvc?rev=439014&view=rev
Log:
Auto-discover built-in conditions added >= 1.7 from the accompanying antlib so
we can stop adding junk setters to ConditionBase.
+
+ /**
+ * Create a dynamically discovered condition. Built-in conditions can
+ * be discovered from the org.apache.tools.ant.taskdefs.condition
+ * antlib.
+ * @param name the condition to create.
+ */
+ public Object createDynamicElement(String name) {
+ Object cond = ComponentHelper.getComponentHelper(getProject())
+ .createComponent(CONDITION_ANTLIB + name);
+ if (!(cond instanceof Condition)) {
+ return null;
+ }
+ log("Dynamically discovered '" + name + "' " + cond,
+ Project.MSG_DEBUG);
+ add((Condition) cond);
+ return cond;
+ }
+
}
hmm. What happens to third party tasks that extend this and already have
dynamic binding stuff built in. I dont know of any, though I've done two
extensions myself, <failingwaitfor> and some little toy one to count
conditions for the book
package org.antbook.conditions;
import org.apache.tools.ant.taskdefs.condition.ConditionBase;
import org.apache.tools.ant.taskdefs.condition.Condition;
import java.util.Enumeration;
public class CountConditions extends ConditionBase {
public void execute() {
int passes=0;
int failures=0;
Enumeration conditions = getConditions();
while (conditions.hasMoreElements()) {
Condition c = (Condition) conditions.nextElement();
boolean pass=c.eval();
if(pass) {
passes++;
} else {
failures++;
}
}
log("Conditions passing: "+passes+" failing: "+failures);
}
}
Personally, I'd like add(Condition) just to work :)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]