|
@@ -31,6 +31,7 @@ import java.util.Vector; |
|
|
|
|
|
|
|
|
import org.apache.tools.ant.BuildException; |
|
|
import org.apache.tools.ant.BuildException; |
|
|
import org.apache.tools.ant.Project; |
|
|
import org.apache.tools.ant.Project; |
|
|
|
|
|
import org.apache.tools.ant.types.resources.MappedResource; |
|
|
import org.apache.tools.ant.types.resources.PropertyResource; |
|
|
import org.apache.tools.ant.types.resources.PropertyResource; |
|
|
import org.apache.tools.ant.util.FileNameMapper; |
|
|
import org.apache.tools.ant.util.FileNameMapper; |
|
|
import org.apache.tools.ant.util.regexp.RegexpMatcher; |
|
|
import org.apache.tools.ant.util.regexp.RegexpMatcher; |
|
@@ -292,17 +293,48 @@ public class PropertySet extends DataType implements ResourceCollection { |
|
|
return getRef().getProperties(); |
|
|
return getRef().getProperties(); |
|
|
} |
|
|
} |
|
|
dieOnCircularReference(); |
|
|
dieOnCircularReference(); |
|
|
Set names = null; |
|
|
|
|
|
Project prj = getProject(); |
|
|
|
|
|
Hashtable props = |
|
|
|
|
|
prj == null ? getAllSystemProperties() : prj.getProperties(); |
|
|
|
|
|
|
|
|
Hashtable props = getEffectiveProperties(); |
|
|
|
|
|
Set names = getPropertyNames(props); |
|
|
|
|
|
|
|
|
|
|
|
FileNameMapper m = null; |
|
|
|
|
|
Mapper myMapper = getMapper(); |
|
|
|
|
|
if (myMapper != null) { |
|
|
|
|
|
m = myMapper.getImplementation(); |
|
|
|
|
|
} |
|
|
|
|
|
Properties properties = new Properties(); |
|
|
|
|
|
//iterate through the names, get the matching values |
|
|
|
|
|
for (Iterator iter = names.iterator(); iter.hasNext();) { |
|
|
|
|
|
String name = (String) iter.next(); |
|
|
|
|
|
String value = (String) props.get(name); |
|
|
|
|
|
if (value != null) { |
|
|
|
|
|
// may be null if a system property has been added |
|
|
|
|
|
// after the project instance has been initialized |
|
|
|
|
|
if (m != null) { |
|
|
|
|
|
//map the names |
|
|
|
|
|
String[] newname = m.mapFileName(name); |
|
|
|
|
|
if (newname != null) { |
|
|
|
|
|
name = newname[0]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
properties.setProperty(name, value); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return properties; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Hashtable getEffectiveProperties() { |
|
|
|
|
|
Project prj = getProject(); |
|
|
|
|
|
Hashtable result = prj == null ? getAllSystemProperties() : prj.getProperties(); |
|
|
//quick & dirty, to make nested mapped p-sets work: |
|
|
//quick & dirty, to make nested mapped p-sets work: |
|
|
for (Enumeration e = setRefs.elements(); e.hasMoreElements();) { |
|
|
for (Enumeration e = setRefs.elements(); e.hasMoreElements();) { |
|
|
PropertySet set = (PropertySet) e.nextElement(); |
|
|
PropertySet set = (PropertySet) e.nextElement(); |
|
|
props.putAll(set.getProperties()); |
|
|
|
|
|
|
|
|
result.putAll(set.getProperties()); |
|
|
} |
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Set getPropertyNames(Hashtable props) { |
|
|
|
|
|
Set names; |
|
|
if (getDynamic() || cachedNames == null) { |
|
|
if (getDynamic() || cachedNames == null) { |
|
|
names = new HashSet(); |
|
|
names = new HashSet(); |
|
|
addPropertyNames(names, props); |
|
|
addPropertyNames(names, props); |
|
@@ -323,30 +355,7 @@ public class PropertySet extends DataType implements ResourceCollection { |
|
|
} else { |
|
|
} else { |
|
|
names = cachedNames; |
|
|
names = cachedNames; |
|
|
} |
|
|
} |
|
|
FileNameMapper m = null; |
|
|
|
|
|
Mapper myMapper = getMapper(); |
|
|
|
|
|
if (myMapper != null) { |
|
|
|
|
|
m = myMapper.getImplementation(); |
|
|
|
|
|
} |
|
|
|
|
|
Properties properties = new Properties(); |
|
|
|
|
|
//iterate through the names, get the matching values |
|
|
|
|
|
for (Iterator iter = names.iterator(); iter.hasNext();) { |
|
|
|
|
|
String name = (String) iter.next(); |
|
|
|
|
|
String value = (String) props.get(name); |
|
|
|
|
|
if (value != null) { |
|
|
|
|
|
// may be null if a system property has been added |
|
|
|
|
|
// after the project instance has been initialized |
|
|
|
|
|
if (m != null) { |
|
|
|
|
|
//map the names |
|
|
|
|
|
String[] newname = m.mapFileName(name); |
|
|
|
|
|
if (newname != null) { |
|
|
|
|
|
name = newname[0]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
properties.setProperty(name, value); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return properties; |
|
|
|
|
|
|
|
|
return names; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -498,13 +507,20 @@ public class PropertySet extends DataType implements ResourceCollection { |
|
|
return getRef().iterator(); |
|
|
return getRef().iterator(); |
|
|
} |
|
|
} |
|
|
dieOnCircularReference(); |
|
|
dieOnCircularReference(); |
|
|
final Enumeration e = getProperties().propertyNames(); |
|
|
|
|
|
|
|
|
Hashtable props = getEffectiveProperties(); |
|
|
|
|
|
Set names = getPropertyNames(props); |
|
|
|
|
|
|
|
|
|
|
|
Mapper myMapper = getMapper(); |
|
|
|
|
|
final FileNameMapper m = myMapper == null ? null : myMapper.getImplementation(); |
|
|
|
|
|
final Iterator iter = names.iterator(); |
|
|
|
|
|
|
|
|
return new Iterator() { |
|
|
return new Iterator() { |
|
|
public boolean hasNext() { |
|
|
public boolean hasNext() { |
|
|
return e.hasMoreElements(); |
|
|
|
|
|
|
|
|
return iter.hasNext(); |
|
|
} |
|
|
} |
|
|
public Object next() { |
|
|
public Object next() { |
|
|
return new PropertyResource(getProject(), (String) e.nextElement()); |
|
|
|
|
|
|
|
|
PropertyResource p = new PropertyResource(getProject(), (String) iter.next()); |
|
|
|
|
|
return m == null ? (Resource) p : new MappedResource(p, m); |
|
|
} |
|
|
} |
|
|
public void remove() { |
|
|
public void remove() { |
|
|
throw new UnsupportedOperationException(); |
|
|
throw new UnsupportedOperationException(); |
|
|