You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by co...@locus.apache.org on 2000/08/03 04:36:25 UTC
cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Property.java
conor 00/08/02 19:36:25
Modified: src/main/org/apache/tools/ant/taskdefs Property.java
Log:
Rewrote the property resolution code so that it handles empty property
lists. I also cleaned it up a little so it doesn't continually restart
resolving all properties from the start of the list and it handles
circular dependencies.
Problem reported by: Arun Katkere <ka...@praja.com>
Revision Changes Path
1.12 +30 -27 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java
Index: Property.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Property.java 2000/07/28 11:00:30 1.11
+++ Property.java 2000/08/03 02:36:25 1.12
@@ -184,43 +184,46 @@
}
private void resolveAllProperties(Hashtable props) {
- Hashtable toResolve = new Hashtable();
- Enumeration e = props.keys();
- boolean more = true;
-
- while (more) {
- while (e.hasMoreElements()) {
- Vector propsInValue = new Vector();
- String name = (String) e.nextElement();
- String value = (String) props.get(name);
+ Hashtable unresolvableProperties = new Hashtable();
+ for (Enumeration e = props.keys(); e.hasMoreElements(); ) {
+ String name = (String) e.nextElement();
+ String value = (String) props.get(name);
+ boolean resolved = false;
+ while (!resolved) {
+ Vector propsInValue = new Vector();
+
+ // assume it will be resolved
+ resolved = true;
+ boolean unresolvable = false;
if (extractProperties(value, propsInValue)) {
for (int i=0; i < propsInValue.size(); i++) {
String elem = (String) propsInValue.elementAt(i);
+ if (elem.equals(name) || unresolvableProperties.containsKey(elem)) {
+ // we won't try further resolving elements with circular
+ // property dependencies or dependencies on unresolvable elements
+ unresolvable = true;
+ break;
+ }
+
if (project.getProperties().containsKey(elem) ||
props.containsKey(elem)) {
- toResolve.put(name, value);
- break;
+ resolved = false;
}
}
}
-
- if (toResolve.size() > 0) {
- Enumeration tre = toResolve.keys();
- while (tre.hasMoreElements()) {
- String name2 = (String) tre.nextElement();
- String value2 = (String) toResolve.get(name2);
- String v = ProjectHelper.replaceProperties(value2,
- project.getProperties());
- v = ProjectHelper.replaceProperties(v, props);
- props.put(name, v);
- }
-
- toResolve.clear();
- e = props.keys();
- } else {
- more = false;
+
+ if (unresolvable) {
+ unresolvableProperties.put(name, value);
+ resolved = true;
}
+
+ if (!resolved) {
+ value = ProjectHelper.replaceProperties(value,
+ project.getProperties());
+ value = ProjectHelper.replaceProperties(value, props);
+ props.put(name, value);
+ }
}
}
}