NIHVIVO-2811 Improve DirDifferenceFileSet to take <include> elements. This simplifies the build script.

This commit is contained in:
j2blake 2011-09-11 15:05:13 +00:00
parent 38a5269521
commit 0ef4a791c8
3 changed files with 39 additions and 48 deletions

View file

@ -3,13 +3,13 @@
package edu.cornell.mannlib.vitro.utilities.anttasks;
import java.io.File;
import java.util.ArrayList;
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;
@ -18,19 +18,25 @@ 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;
private Project p;
private File dir;
private FileSet fileSet;
/** The internal FileSet */
private FileSet fileSet = new FileSet();
public void setProject(Project p) {
this.p = p;
fileSet.setProject(p);
}
public void setDir(File dir) {
this.dir = dir;
fileSet.setDir(dir);
}
public PatternSet.NameEntry createInclude() {
return fileSet.createInclude();
}
@Override
@ -58,14 +64,11 @@ public abstract class AbstractWrappedFileSet implements ResourceCollection {
protected abstract void fillFileList();
protected FileSet getInternalFileSet() {
if (fileSet != null) {
return fileSet;
protected Project getProject() {
return p;
}
fileSet = new FileSet();
fileSet.setProject(p);
fileSet.setDir(dir);
protected FileSet getInternalFileSet() {
return fileSet;
}

View file

@ -16,9 +16,11 @@ import org.apache.tools.ant.types.resources.FileResource;
public class DirDifferenceFileSet extends AbstractWrappedFileSet {
private Path blockingPath;
@SuppressWarnings("hiding")
public void addConfiguredPath(Path blockingPath) {
this.blockingPath = blockingPath;
public Path createBlockingPath() {
if (blockingPath == null) {
blockingPath = new Path(getProject());
}
return blockingPath.createPath();
}
@Override

View file

@ -54,9 +54,9 @@
<copy todir="${appbase.dir}/web" includeemptydirs="true">
<dirDifference dir="${inner.basedir}/web">
<path>
<blockingPath>
<pathelement location="${product.modifications.dir}" />
</path>
</blockingPath>
</dirDifference>
</copy>
<copy todir="${appbase.dir}/web" includeemptydirs="true">
@ -67,37 +67,23 @@
<fileset dir="${inner.basedir}/config" />
</copy>
<copy todir="${appbase.dir}/src" includeemptydirs="true">
<dirDifference dir="${inner.basedir}/src">
<path>
<pathelement location="./src" />
</path>
<!-- -->
<copy todir="${appbase.dir}" includeemptydirs="true">
<dirDifference dir="${inner.basedir}">
<include name="src/**/*" />
<include name="lib/**/*" />
<include name="test/**/*" />
<blockingPath>
<pathelement location="." />
</blockingPath>
</dirDifference>
</copy>
<copy todir="${appbase.dir}/src" includeemptydirs="true">
<fileset dir="./src" erroronmissingdir="false" />
</copy>
<copy todir="${appbase.dir}/lib" includeemptydirs="true">
<dirDifference dir="${inner.basedir}/lib">
<path>
<pathelement location="./lib" />
</path>
</dirDifference>
</copy>
<copy todir="${appbase.dir}/lib" includeemptydirs="true">
<fileset dir="./lib" erroronmissingdir="false" />
</copy>
<copy todir="${appbase.dir}/test" includeemptydirs="true">
<dirDifference dir="${inner.basedir}/test">
<path>
<pathelement location="./test" />
</path>
</dirDifference>
</copy>
<copy todir="${appbase.dir}/test" includeemptydirs="true">
<fileset dir="./test" />
<copy todir="${appbase.dir}" includeemptydirs="true">
<fileset dir="." erroronmissingdir="false">
<include name="src/**/*" />
<include name="lib/**/*" />
<include name="test/**/*" />
</fileset>
</copy>
<copy todir="${appbase.dir}/themes" includeemptydirs="true">