diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java
index 7f669f382..60847f9cc 100644
--- a/src/main/org/apache/tools/ant/Project.java
+++ b/src/main/org/apache/tools/ant/Project.java
@@ -1184,6 +1184,13 @@ public class Project {
return references;
}
+ /**
+ * @return The object with the "id" key.
+ */
+ public Object getReference(String key) {
+ return references.get(key);
+ }
+
/**
* send build started event to the listeners
*/
diff --git a/src/main/org/apache/tools/ant/types/FileList.java b/src/main/org/apache/tools/ant/types/FileList.java
index c07277ee4..d3e5cfe66 100644
--- a/src/main/org/apache/tools/ant/types/FileList.java
+++ b/src/main/org/apache/tools/ant/types/FileList.java
@@ -86,6 +86,7 @@ public class FileList extends DataType {
protected FileList(FileList filelist) {
this.dir = filelist.dir;
this.filenames = filelist.filenames;
+ setProject(filelist.getProject());
}
/**
diff --git a/src/main/org/apache/tools/ant/types/FileSet.java b/src/main/org/apache/tools/ant/types/FileSet.java
index 9bca0f2b0..dc44d820b 100644
--- a/src/main/org/apache/tools/ant/types/FileSet.java
+++ b/src/main/org/apache/tools/ant/types/FileSet.java
@@ -74,7 +74,7 @@ import java.util.Vector;
* @author Stefan Bodewig
* @author Magesh Umasankar
*/
-public class FileSet extends DataType {
+public class FileSet extends DataType implements Cloneable {
private PatternSet defaultPatterns = new PatternSet();
private Vector additionalPatterns = new Vector();
@@ -93,6 +93,7 @@ public class FileSet extends DataType {
this.additionalPatterns = fileset.additionalPatterns;
this.useDefaultExcludes = fileset.useDefaultExcludes;
this.isCaseSensitive = fileset.isCaseSensitive;
+ setProject(getProject());
}
@@ -323,4 +324,16 @@ public class FileSet extends DataType {
}
}
+ /**
+ * Return a FileSet that has the same basedir and same patternsets
+ * as this one.
+ */
+ public Object clone() {
+ if (isReference()) {
+ return new FileSet(getRef(getProject()));
+ } else {
+ return new FileSet(this);
+ }
+ }
+
}
diff --git a/src/main/org/apache/tools/ant/types/FilterSet.java b/src/main/org/apache/tools/ant/types/FilterSet.java
index f69bf8bd8..2f12ac332 100644
--- a/src/main/org/apache/tools/ant/types/FilterSet.java
+++ b/src/main/org/apache/tools/ant/types/FilterSet.java
@@ -77,7 +77,7 @@ import org.apache.tools.ant.Project;
* @author Michael McCallum
* @created 14 March 2001
*/
-public class FilterSet extends DataType {
+public class FilterSet extends DataType implements Cloneable {
/**
* Individual filter component of filterset
@@ -439,6 +439,15 @@ public class FilterSet extends DataType {
public boolean hasFilters() {
return getFilters().size() > 0;
}
+
+ public Object clone() throws BuildException {
+ if (isReference()) {
+ return new FilterSet(getRef());
+ } else {
+ return new FilterSet(this);
+ }
+ }
+
}
diff --git a/src/main/org/apache/tools/ant/types/Mapper.java b/src/main/org/apache/tools/ant/types/Mapper.java
index 788ae9364..fd451475f 100644
--- a/src/main/org/apache/tools/ant/types/Mapper.java
+++ b/src/main/org/apache/tools/ant/types/Mapper.java
@@ -67,14 +67,12 @@ import java.util.Stack;
*
* @author Stefan Bodewig
*/
-public class Mapper extends DataType {
-
- protected Project p;
+public class Mapper extends DataType implements Cloneable {
protected MapperType type = null;
public Mapper(Project p) {
- this.p = p;
+ setProject(p);
}
/**
@@ -123,7 +121,7 @@ public class Mapper extends DataType {
throw noChildrenAllowed();
}
if (this.classpath == null) {
- this.classpath = new Path(p);
+ this.classpath = new Path(getProject());
}
return this.classpath.createPath();
}
@@ -201,7 +199,8 @@ public class Mapper extends DataType {
if (classpath == null) {
c = Class.forName(classname);
} else {
- AntClassLoader al = new AntClassLoader(p, classpath);
+ AntClassLoader al = new AntClassLoader(getProject(),
+ classpath);
c = al.loadClass(classname);
AntClassLoader.initializeClass(c);
}
@@ -229,10 +228,10 @@ public class Mapper extends DataType {
if (!checked) {
Stack stk = new Stack();
stk.push(this);
- dieOnCircularReference(stk, p);
+ dieOnCircularReference(stk, getProject());
}
- Object o = ref.getReferencedObject(p);
+ Object o = ref.getReferencedObject(getProject());
if (!(o instanceof Mapper)) {
String msg = ref.getRefId()+" doesn\'t denote a mapper";
throw new BuildException(msg);
@@ -269,4 +268,5 @@ public class Mapper extends DataType {
return implementations.getProperty(getValue());
}
}
+
}
diff --git a/src/main/org/apache/tools/ant/types/Path.java b/src/main/org/apache/tools/ant/types/Path.java
index b726ca5dd..79e10a56a 100644
--- a/src/main/org/apache/tools/ant/types/Path.java
+++ b/src/main/org/apache/tools/ant/types/Path.java
@@ -99,7 +99,6 @@ import java.util.Vector;
public class Path extends DataType implements Cloneable {
private Vector elements;
- private Project project;
public static Path systemClasspath =
new Path(null, System.getProperty("java.class.path"));
@@ -116,7 +115,7 @@ public class Path extends DataType implements Cloneable {
}
public void setPath(String path) {
- parts = Path.translatePath(project, path);
+ parts = Path.translatePath(getProject(), path);
}
public String[] getParts() {
@@ -134,15 +133,10 @@ public class Path extends DataType implements Cloneable {
}
public Path(Project project) {
- this.project = project;
+ setProject(project);
elements = new Vector();
}
- public void setProject(Project p) {
- this.project = p;
- }
- public Project getProject() {return project;}
-
/**
* Adds a element definition to the path.
* @param location the location of the element to add (must not be
@@ -211,7 +205,7 @@ public class Path extends DataType implements Cloneable {
if (isReference()) {
throw noChildrenAllowed();
}
- Path p = new Path(project);
+ Path p = new Path(getProject());
elements.addElement(p);
checked = false;
return p;
@@ -240,8 +234,8 @@ public class Path extends DataType implements Cloneable {
String[] list = source.list();
for (int i=0; i