Browse Source

Fix for id/refid data type bug. Delays adding the

id to the list of references till runtime when the
data type is inside a target.  Without this change,
if multiple data types have the same id, only the
one that is last refered to in the file *and* is
configured at runtime (i.e. its target is executed)
will work properly.  Otherwise, you will end up
using an unconfigured data type.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269374 13f79535-47bb-0310-9956-ffa450edef68
master
glennm 24 years ago
parent
commit
9932ed799b
4 changed files with 43 additions and 1 deletions
  1. +1
    -1
      src/main/org/apache/tools/ant/ProjectHelper.java
  2. +7
    -0
      src/main/org/apache/tools/ant/RuntimeConfigurable.java
  3. +3
    -0
      src/main/org/apache/tools/ant/types/FileSet.java
  4. +32
    -0
      src/main/org/apache/tools/ant/types/PatternSet.java

+ 1
- 1
src/main/org/apache/tools/ant/ProjectHelper.java View File

@@ -611,13 +611,13 @@ public class ProjectHelper {
throw new BuildException("Unknown data type "+propType);
}
configureId(element, attrs);
if (target != null) {
wrapper = new RuntimeConfigurable(element);
wrapper.setAttributes(attrs);
target.addDataType(wrapper);
} else {
configure(element, attrs, project);
configureId(element, attrs);
}
} catch (BuildException exc) {
throw new SAXParseException(exc.getMessage(), locator, exc);


+ 7
- 0
src/main/org/apache/tools/ant/RuntimeConfigurable.java View File

@@ -130,8 +130,11 @@ public class RuntimeConfigurable {
* Configure the wrapped element and all children.
*/
public void maybeConfigure(Project p) throws BuildException {
String id = null;
if (attributes != null) {
ProjectHelper.configure(wrappedObject, attributes, p);
id = attributes.getValue("id");
attributes = null;
}
if (characters.length() != 0) {
@@ -143,6 +146,10 @@ public class RuntimeConfigurable {
RuntimeConfigurable child = (RuntimeConfigurable) enum.nextElement();
child.maybeConfigure(p);
}

if (id != null) {
p.addReference(id, wrappedObject);
}
}

}

+ 3
- 0
src/main/org/apache/tools/ant/types/FileSet.java View File

@@ -260,6 +260,9 @@ public class FileSet extends DataType {
Object o = additionalPatterns.elementAt(i);
defaultPatterns.append((PatternSet) o, p);
}

p.log( "FileSet: Setup file scanner in dir " + dir +
" with " + defaultPatterns, p.MSG_DEBUG );
ds.setIncludes(defaultPatterns.getIncludePatterns(p));
ds.setExcludes(defaultPatterns.getExcludePatterns(p));


+ 32
- 0
src/main/org/apache/tools/ant/types/PatternSet.java View File

@@ -121,6 +121,32 @@ public class PatternSet extends DataType {
}
return true;
}

public String toString()
{
StringBuffer buf = new StringBuffer();
buf.append( name );
if ((ifCond != null) || (unlessCond != null))
{
buf.append(":");
String connector = "";
if (ifCond != null)
{
buf.append("if->");
buf.append(ifCond);
connector = ";";
}
if (unlessCond != null)
{
buf.append(connector);
buf.append("unless->");
buf.append(unlessCond);
}
}

return buf.toString();
}
}

public PatternSet() {
@@ -377,4 +403,10 @@ public class PatternSet extends DataType {
}
}

public String toString()
{
return "patternSet{ includes: " + includeList +
" excludes: " + excludeList + " }";
}

}

Loading…
Cancel
Save