NIHVIVO-2811 Improve DirDifferenceFileSet to take <include> elements. This simplifies the build script.
This commit is contained in:
parent
38a5269521
commit
0ef4a791c8
3 changed files with 39 additions and 48 deletions
|
@ -3,13 +3,13 @@
|
||||||
package edu.cornell.mannlib.vitro.utilities.anttasks;
|
package edu.cornell.mannlib.vitro.utilities.anttasks;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.tools.ant.BuildException;
|
import org.apache.tools.ant.BuildException;
|
||||||
import org.apache.tools.ant.Project;
|
import org.apache.tools.ant.Project;
|
||||||
import org.apache.tools.ant.types.FileSet;
|
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.Resource;
|
||||||
import org.apache.tools.ant.types.ResourceCollection;
|
import org.apache.tools.ant.types.ResourceCollection;
|
||||||
import org.apache.tools.ant.types.resources.FileResource;
|
import org.apache.tools.ant.types.resources.FileResource;
|
||||||
|
@ -18,20 +18,26 @@ import org.apache.tools.ant.types.resources.FileResource;
|
||||||
* A base class for our custom-made FileSet extensions.
|
* A base class for our custom-made FileSet extensions.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractWrappedFileSet implements ResourceCollection {
|
public abstract class AbstractWrappedFileSet implements ResourceCollection {
|
||||||
|
private Project p;
|
||||||
|
|
||||||
|
/** The list of FileResources that we will yield to the task. */
|
||||||
protected List<FileResource> files;
|
protected List<FileResource> files;
|
||||||
|
|
||||||
private Project p;
|
/** The internal FileSet */
|
||||||
private File dir;
|
private FileSet fileSet = new FileSet();
|
||||||
|
|
||||||
private FileSet fileSet;
|
|
||||||
|
|
||||||
public void setProject(Project p) {
|
public void setProject(Project p) {
|
||||||
this.p = p;
|
this.p = p;
|
||||||
|
fileSet.setProject(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDir(File dir) {
|
public void setDir(File dir) {
|
||||||
this.dir = dir;
|
fileSet.setDir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PatternSet.NameEntry createInclude() {
|
||||||
|
return fileSet.createInclude();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
|
@ -58,14 +64,11 @@ public abstract class AbstractWrappedFileSet implements ResourceCollection {
|
||||||
|
|
||||||
protected abstract void fillFileList();
|
protected abstract void fillFileList();
|
||||||
|
|
||||||
|
protected Project getProject() {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
protected FileSet getInternalFileSet() {
|
protected FileSet getInternalFileSet() {
|
||||||
if (fileSet != null) {
|
|
||||||
return fileSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
fileSet = new FileSet();
|
|
||||||
fileSet.setProject(p);
|
|
||||||
fileSet.setDir(dir);
|
|
||||||
return fileSet;
|
return fileSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,12 @@ import org.apache.tools.ant.types.resources.FileResource;
|
||||||
public class DirDifferenceFileSet extends AbstractWrappedFileSet {
|
public class DirDifferenceFileSet extends AbstractWrappedFileSet {
|
||||||
private Path blockingPath;
|
private Path blockingPath;
|
||||||
|
|
||||||
@SuppressWarnings("hiding")
|
public Path createBlockingPath() {
|
||||||
public void addConfiguredPath(Path blockingPath) {
|
if (blockingPath == null) {
|
||||||
this.blockingPath = blockingPath;
|
blockingPath = new Path(getProject());
|
||||||
}
|
}
|
||||||
|
return blockingPath.createPath();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void fillFileList() {
|
protected void fillFileList() {
|
||||||
|
|
|
@ -54,9 +54,9 @@
|
||||||
|
|
||||||
<copy todir="${appbase.dir}/web" includeemptydirs="true">
|
<copy todir="${appbase.dir}/web" includeemptydirs="true">
|
||||||
<dirDifference dir="${inner.basedir}/web">
|
<dirDifference dir="${inner.basedir}/web">
|
||||||
<path>
|
<blockingPath>
|
||||||
<pathelement location="${product.modifications.dir}" />
|
<pathelement location="${product.modifications.dir}" />
|
||||||
</path>
|
</blockingPath>
|
||||||
</dirDifference>
|
</dirDifference>
|
||||||
</copy>
|
</copy>
|
||||||
<copy todir="${appbase.dir}/web" includeemptydirs="true">
|
<copy todir="${appbase.dir}/web" includeemptydirs="true">
|
||||||
|
@ -67,37 +67,23 @@
|
||||||
<fileset dir="${inner.basedir}/config" />
|
<fileset dir="${inner.basedir}/config" />
|
||||||
</copy>
|
</copy>
|
||||||
|
|
||||||
<copy todir="${appbase.dir}/src" includeemptydirs="true">
|
<!-- -->
|
||||||
<dirDifference dir="${inner.basedir}/src">
|
<copy todir="${appbase.dir}" includeemptydirs="true">
|
||||||
<path>
|
<dirDifference dir="${inner.basedir}">
|
||||||
<pathelement location="./src" />
|
<include name="src/**/*" />
|
||||||
</path>
|
<include name="lib/**/*" />
|
||||||
|
<include name="test/**/*" />
|
||||||
|
<blockingPath>
|
||||||
|
<pathelement location="." />
|
||||||
|
</blockingPath>
|
||||||
</dirDifference>
|
</dirDifference>
|
||||||
</copy>
|
</copy>
|
||||||
<copy todir="${appbase.dir}/src" includeemptydirs="true">
|
<copy todir="${appbase.dir}" includeemptydirs="true">
|
||||||
<fileset dir="./src" erroronmissingdir="false" />
|
<fileset dir="." erroronmissingdir="false">
|
||||||
</copy>
|
<include name="src/**/*" />
|
||||||
|
<include name="lib/**/*" />
|
||||||
<copy todir="${appbase.dir}/lib" includeemptydirs="true">
|
<include name="test/**/*" />
|
||||||
<dirDifference dir="${inner.basedir}/lib">
|
</fileset>
|
||||||
<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>
|
</copy>
|
||||||
|
|
||||||
<copy todir="${appbase.dir}/themes" includeemptydirs="true">
|
<copy todir="${appbase.dir}/themes" includeemptydirs="true">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue