Browse Source

Fix up the determination of fileset names since most fileset subclasses

won't override the getDataTypeName and thus be reported as fileset


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272337 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 23 years ago
parent
commit
d2d5078dc7
4 changed files with 36 additions and 10 deletions
  1. +8
    -0
      src/main/org/apache/tools/ant/taskdefs/MatchingTask.java
  2. +28
    -2
      src/main/org/apache/tools/ant/types/AbstractFileSet.java
  3. +0
    -4
      src/main/org/apache/tools/ant/types/DirSet.java
  4. +0
    -4
      src/main/org/apache/tools/ant/types/FileSet.java

+ 8
- 0
src/main/org/apache/tools/ant/taskdefs/MatchingTask.java View File

@@ -79,6 +79,14 @@ public abstract class MatchingTask extends Task {
protected boolean useDefaultExcludes = true;
protected FileSet fileset = new FileSet();

/**
* @see ProjectComponent#setProject
*/
public void setProject(Project project) {
super.setProject(project);
fileset.setProject(project);
}

/**
* add a name entry on the include list
*/


+ 28
- 2
src/main/org/apache/tools/ant/types/AbstractFileSet.java View File

@@ -62,6 +62,8 @@ import org.apache.tools.ant.Project;
import java.io.File;
import java.util.Stack;
import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration;

/**
* Class that holds an implicit patternset and supports nested
@@ -85,6 +87,7 @@ public abstract class AbstractFileSet extends DataType implements Cloneable {
private boolean useDefaultExcludes = true;
private boolean isCaseSensitive = true;

public AbstractFileSet() {
super();
}
@@ -95,7 +98,7 @@ public abstract class AbstractFileSet extends DataType implements Cloneable {
this.additionalPatterns = fileset.additionalPatterns;
this.useDefaultExcludes = fileset.useDefaultExcludes;
this.isCaseSensitive = fileset.isCaseSensitive;
setProject(getProject());
setProject(fileset.getProject());
}

/**
@@ -270,10 +273,33 @@ public abstract class AbstractFileSet extends DataType implements Cloneable {
this.isCaseSensitive = isCaseSensitive;
}

/**
* sets the name used for this datatype instance.
*/
protected abstract String getDataTypeName();
protected String getDataTypeName() {
// look up the types in project and see if they match this class
Project project = getProject();
if (project != null) {
Hashtable typedefs = project.getDataTypeDefinitions();
for (Enumeration e = typedefs.keys(); e.hasMoreElements();) {
String typeName = (String)e.nextElement();
Class typeClass = (Class)typedefs.get(typeName);
if (typeClass == getClass()) {
return typeName;
}
}
}
String classname = getClass().getName();
int dotIndex = classname.lastIndexOf(".");
if (dotIndex == -1) {
return classname;
}
return classname.substring(dotIndex + 1);
}

/**
* Returns the directory scanner needed to access the files to process.


+ 0
- 4
src/main/org/apache/tools/ant/types/DirSet.java View File

@@ -70,10 +70,6 @@ public class DirSet extends AbstractFileSet {
super(dirset);
}

protected String getDataTypeName() {
return "dirset";
}

/**
* Return a DirSet that has the same basedir and same patternsets
* as this one.


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

@@ -75,10 +75,6 @@ public class FileSet extends AbstractFileSet {
super(fileset);
}

protected String getDataTypeName() {
return "fileset";
}

/**
* Return a FileSet that has the same basedir and same patternsets
* as this one.


Loading…
Cancel
Save