From 9932ed799bd36ab3e9176ffe4e27cf32e2f04d12 Mon Sep 17 00:00:00 2001 From: glennm Date: Mon, 23 Jul 2001 03:56:12 +0000 Subject: [PATCH] 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 --- .../org/apache/tools/ant/ProjectHelper.java | 2 +- .../apache/tools/ant/RuntimeConfigurable.java | 7 ++++ .../org/apache/tools/ant/types/FileSet.java | 3 ++ .../apache/tools/ant/types/PatternSet.java | 32 +++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java index 6e87e0b57..c88df83e3 100644 --- a/src/main/org/apache/tools/ant/ProjectHelper.java +++ b/src/main/org/apache/tools/ant/ProjectHelper.java @@ -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); diff --git a/src/main/org/apache/tools/ant/RuntimeConfigurable.java b/src/main/org/apache/tools/ant/RuntimeConfigurable.java index 8a5584d54..cdd8420ee 100644 --- a/src/main/org/apache/tools/ant/RuntimeConfigurable.java +++ b/src/main/org/apache/tools/ant/RuntimeConfigurable.java @@ -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); + } } } diff --git a/src/main/org/apache/tools/ant/types/FileSet.java b/src/main/org/apache/tools/ant/types/FileSet.java index 8545d808b..4d6aee690 100644 --- a/src/main/org/apache/tools/ant/types/FileSet.java +++ b/src/main/org/apache/tools/ant/types/FileSet.java @@ -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)); diff --git a/src/main/org/apache/tools/ant/types/PatternSet.java b/src/main/org/apache/tools/ant/types/PatternSet.java index 73937961f..59e68e9a9 100644 --- a/src/main/org/apache/tools/ant/types/PatternSet.java +++ b/src/main/org/apache/tools/ant/types/PatternSet.java @@ -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 + " }"; + } + }