diff --git a/src/main/org/apache/tools/ant/types/AbstractFileSet.java b/src/main/org/apache/tools/ant/types/AbstractFileSet.java index b1c0e2461..738938b5c 100644 --- a/src/main/org/apache/tools/ant/types/AbstractFileSet.java +++ b/src/main/org/apache/tools/ant/types/AbstractFileSet.java @@ -719,16 +719,31 @@ public abstract class AbstractFileSet extends DataType implements Cloneable, } /** + * Creates a deep clone of this instance, except for the nested + * selectors (the list of selectors is a shallow clone of this + * instance's list). + * * @since Ant 1.6 */ public Object clone() { - try { - AbstractFileSet fs = (AbstractFileSet) super.clone(); - fs.setProject(getProject()); - return fs; - } catch (CloneNotSupportedException e) { - throw new BuildException(e); + if (isReference()) { + return (getRef(getProject())).clone(); + } else { + try { + AbstractFileSet fs = (AbstractFileSet) super.clone(); + fs.defaultPatterns = (PatternSet) defaultPatterns.clone(); + fs.additionalPatterns = new Vector(additionalPatterns.size()); + Enumeration e = additionalPatterns.elements(); + while (e.hasMoreElements()) { + fs.additionalPatterns + .addElement(((PatternSet) e.nextElement()).clone()); + } + fs.selectors = (Vector) fs.selectors.clone(); + return fs; + } catch (CloneNotSupportedException e) { + throw new BuildException(e); + } } } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/types/PatternSet.java b/src/main/org/apache/tools/ant/types/PatternSet.java index 4d60d59e4..6c55cda2a 100644 --- a/src/main/org/apache/tools/ant/types/PatternSet.java +++ b/src/main/org/apache/tools/ant/types/PatternSet.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -77,7 +77,7 @@ import org.apache.tools.ant.Project; * @author Jon S. Stevens jon@clearink.com * @author Stefan Bodewig */ -public class PatternSet extends DataType { +public class PatternSet extends DataType implements Cloneable { private Vector includeList = new Vector(); private Vector excludeList = new Vector(); private Vector includesFileList = new Vector(); @@ -477,4 +477,24 @@ public class PatternSet extends DataType { + " excludes: " + excludeList + " }"; } + /** + * @since Ant 1.6 + */ + public Object clone() { + if (isReference()) { + return getRef(getProject()).clone(); + } else { + try { + PatternSet ps = (PatternSet) super.clone(); + ps.includeList = (Vector) includeList.clone(); + ps.excludeList = (Vector) excludeList.clone(); + ps.includesFileList = (Vector) includesFileList.clone(); + ps.excludesFileList = (Vector) excludesFileList.clone(); + return ps; + } catch (CloneNotSupportedException e) { + throw new BuildException(e); + } + } + } + }