NIHVIVO-3597 Use a <FileSet> with a <present> selector instead of the home-brewed DirDifferenceFileSet
This commit is contained in:
parent
f7d585b0c3
commit
cd64830dd5
3 changed files with 0 additions and 145 deletions
|
@ -1,84 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.utilities.anttasks;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.tools.ant.BuildException;
|
|
||||||
import org.apache.tools.ant.Project;
|
|
||||||
import org.apache.tools.ant.types.FileSet;
|
|
||||||
import org.apache.tools.ant.types.PatternSet;
|
|
||||||
import org.apache.tools.ant.types.Resource;
|
|
||||||
import org.apache.tools.ant.types.ResourceCollection;
|
|
||||||
import org.apache.tools.ant.types.resources.FileResource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A base class for our custom-made FileSet extensions.
|
|
||||||
*/
|
|
||||||
public abstract class AbstractWrappedFileSet implements ResourceCollection {
|
|
||||||
private Project p;
|
|
||||||
|
|
||||||
/** The list of FileResources that we will yield to the task. */
|
|
||||||
protected List<FileResource> files;
|
|
||||||
|
|
||||||
/** The internal FileSet */
|
|
||||||
private FileSet fileSet = new FileSet();
|
|
||||||
|
|
||||||
public void setProject(Project p) {
|
|
||||||
this.p = p;
|
|
||||||
fileSet.setProject(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDir(File dir) {
|
|
||||||
fileSet.setDir(dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PatternSet.NameEntry createInclude() {
|
|
||||||
return fileSet.createInclude();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PatternSet.NameEntry createExclude() {
|
|
||||||
return fileSet.createExclude();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PatternSet createPatternSet() {
|
|
||||||
return fileSet.createPatternSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object clone() {
|
|
||||||
throw new BuildException(this.getClass().getSimpleName()
|
|
||||||
+ " does not support cloning.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFilesystemOnly() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterator<? extends Resource> iterator() {
|
|
||||||
fillFileList();
|
|
||||||
return files.iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int size() {
|
|
||||||
fillFileList();
|
|
||||||
return files.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void fillFileList();
|
|
||||||
|
|
||||||
protected Project getProject() {
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected FileSet getInternalFileSet() {
|
|
||||||
return fileSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.utilities.anttasks;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.apache.tools.ant.types.FileSet;
|
|
||||||
import org.apache.tools.ant.types.Path;
|
|
||||||
import org.apache.tools.ant.types.resources.FileResource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO
|
|
||||||
*/
|
|
||||||
public class DirDifferenceFileSet extends AbstractWrappedFileSet {
|
|
||||||
private Path blockingPath;
|
|
||||||
|
|
||||||
public Path createBlockingPath() {
|
|
||||||
if (blockingPath == null) {
|
|
||||||
blockingPath = new Path(getProject());
|
|
||||||
}
|
|
||||||
return blockingPath.createPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void fillFileList() {
|
|
||||||
if (files != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileSet fs = getInternalFileSet();
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Iterator<FileResource> iter = fs.iterator();
|
|
||||||
|
|
||||||
files = new ArrayList<FileResource>();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
FileResource fr = iter.next();
|
|
||||||
if (!isBlocked(fr)) {
|
|
||||||
files.add(fr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check to see whether this same file exists in any of the blocking
|
|
||||||
* directories.
|
|
||||||
*/
|
|
||||||
private boolean isBlocked(FileResource fr) {
|
|
||||||
for (String blockingDir : blockingPath.list()) {
|
|
||||||
File f = new File(blockingDir + File.separator + fr.getName());
|
|
||||||
if (f.exists()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -135,8 +135,6 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
||||||
<javac srcdir="${utilities.source.dir}" destdir="${utility.classes.dir}" debug="true" deprecation="${javac.deprecation}" encoding="UTF8" includeantruntime="false" optimize="false" source="1.6">
|
<javac srcdir="${utilities.source.dir}" destdir="${utility.classes.dir}" debug="true" deprecation="${javac.deprecation}" encoding="UTF8" includeantruntime="false" optimize="false" source="1.6">
|
||||||
<classpath refid="utility.compile.classpath" />
|
<classpath refid="utility.compile.classpath" />
|
||||||
</javac>
|
</javac>
|
||||||
|
|
||||||
<typedef name="dirDifference" classname="edu.cornell.mannlib.vitro.utilities.anttasks.DirDifferenceFileSet" classpathref="utility.run.classpath" />
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- - - - - - - - - - - - - - - - - -
|
<!-- - - - - - - - - - - - - - - - - -
|
||||||
|
|
Loading…
Add table
Reference in a new issue