NIHVIVO-2811 getting closer - working except for themes.
This commit is contained in:
parent
11239bf040
commit
a29d85db04
6 changed files with 77 additions and 156 deletions
Binary file not shown.
|
@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.utilities.anttasks;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -3,14 +3,9 @@
|
|||
package edu.cornell.mannlib.vitro.utilities.anttasks;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.types.DataType;
|
||||
import org.apache.tools.ant.types.Resource;
|
||||
import org.apache.tools.ant.types.ResourceCollection;
|
||||
import org.apache.tools.ant.types.resources.FileResource;
|
||||
|
||||
|
@ -18,40 +13,11 @@ import org.apache.tools.ant.types.resources.FileResource;
|
|||
* Include all files that are in the primary directory, but do not have matching
|
||||
* files in the blocking directory.
|
||||
*/
|
||||
public class DirDifferenceResourceCollection extends DataType implements
|
||||
ResourceCollection {
|
||||
private List<FileResource> files = null;
|
||||
private File primaryDir;
|
||||
public class DirDifferenceResourceCollection extends
|
||||
AbstractDirResourceCollection implements ResourceCollection {
|
||||
private File blockingDir;
|
||||
private boolean blockingOptional;
|
||||
|
||||
@Override
|
||||
public boolean isFilesystemOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insure that the list has been filled and return an iterator to the list.
|
||||
*/
|
||||
@Override
|
||||
public Iterator<? extends Resource> iterator() {
|
||||
fillFilesList();
|
||||
return files.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insure that the list has been filled and return the size of the list.
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
fillFilesList();
|
||||
return files.size();
|
||||
}
|
||||
|
||||
public void setPrimary(File primaryDir) {
|
||||
this.primaryDir = primaryDir;
|
||||
}
|
||||
|
||||
public void setBlocking(File blockingDir) {
|
||||
this.blockingDir = blockingDir;
|
||||
}
|
||||
|
@ -65,7 +31,8 @@ public class DirDifferenceResourceCollection extends DataType implements
|
|||
* primary directory that are not blocked by files with the same path under
|
||||
* the blocking directory.
|
||||
*/
|
||||
private void fillFilesList() {
|
||||
@Override
|
||||
protected void fillFilesList() {
|
||||
if (files != null) {
|
||||
return;
|
||||
}
|
||||
|
@ -75,33 +42,6 @@ public class DirDifferenceResourceCollection extends DataType implements
|
|||
|
||||
files = new ArrayList<FileResource>();
|
||||
includeUnblockedFiles(primaryDir, blockingDir);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The primary and blocking directory paths must be provided, and must point
|
||||
* to existing, readable directories.
|
||||
*/
|
||||
private void confirmValidDirectory(File dir, String label, boolean optional) {
|
||||
if (dir == null) {
|
||||
throw new BuildException(label + " directory not specified.");
|
||||
}
|
||||
if (!dir.exists()) {
|
||||
if (optional) {
|
||||
return;
|
||||
} else {
|
||||
throw new BuildException(label + " directory '" + dir.getPath()
|
||||
+ "' does not exist.");
|
||||
}
|
||||
}
|
||||
if (!dir.isDirectory()) {
|
||||
throw new BuildException(label + " directory '" + dir.getPath()
|
||||
+ "' is not a directory.");
|
||||
}
|
||||
if (!dir.canRead()) {
|
||||
throw new BuildException(label + " directory '" + dir.getPath()
|
||||
+ "' is not readable.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,48 +89,4 @@ public class DirDifferenceResourceCollection extends DataType implements
|
|||
return dir;
|
||||
}
|
||||
|
||||
private void includeAllFiles(File primary) {
|
||||
for (File file : primary.listFiles(new NonDirectoryFilter())) {
|
||||
files.add(buildResource(file));
|
||||
}
|
||||
for (File primarySubDir : primary.listFiles(new DirectoryFilter())) {
|
||||
includeAllFiles(primarySubDir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* All file resources are based on the original primary directory.
|
||||
*/
|
||||
private FileResource buildResource(File file) {
|
||||
String primaryBasePath = primaryDir.getAbsolutePath();
|
||||
String filePath = file.getAbsolutePath();
|
||||
if (!filePath.startsWith(primaryBasePath)) {
|
||||
throw new IllegalStateException("File is not a descendant "
|
||||
+ "of the primary directory: file='" + file
|
||||
+ "', primary='" + primaryDir + "'");
|
||||
}
|
||||
|
||||
String pathPart = filePath.substring(primaryBasePath.length());
|
||||
if (pathPart.startsWith(File.separator)) {
|
||||
pathPart = pathPart.substring(1);
|
||||
}
|
||||
|
||||
// System.out.println("Resource: b='" + primaryDir + "', name='" +
|
||||
// pathPart + "'");
|
||||
return new FileResource(primaryDir, pathPart);
|
||||
}
|
||||
|
||||
public class DirectoryFilter implements FileFilter {
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
return file.isDirectory();
|
||||
}
|
||||
}
|
||||
|
||||
public class NonDirectoryFilter implements FileFilter {
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
return !file.isDirectory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.utilities.anttasks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.tools.ant.types.ResourceCollection;
|
||||
import org.apache.tools.ant.types.resources.FileResource;
|
||||
|
||||
/**
|
||||
* If the primary directory exists, include all files that are descendent from
|
||||
* it. Otherwise, don't complain but act as a collection of zero files.
|
||||
*/
|
||||
public class OptionalDirResourceCollection extends
|
||||
AbstractDirResourceCollection implements ResourceCollection {
|
||||
|
||||
/**
|
||||
* If the list hasn't already been filled, fill it with all files in the
|
||||
* primary directory that are not blocked by files with the same path under
|
||||
* the blocking directory.
|
||||
*/
|
||||
@Override
|
||||
protected void fillFilesList() {
|
||||
if (files != null) {
|
||||
return;
|
||||
}
|
||||
files = new ArrayList<FileResource>();
|
||||
|
||||
confirmValidDirectory(primaryDir, "The", true);
|
||||
|
||||
if (primaryDir.exists()) {
|
||||
includeAllFiles(primaryDir);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
<!-- - - - - - - - - - - - - - - - - -
|
||||
properties
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<property name="corebase.dir" location="." />
|
||||
<dirname property="corebase.dir" file="${ant.file.vitroCore}" />
|
||||
|
||||
<!--
|
||||
If calling from a Product build script, these properties already point to
|
||||
|
@ -232,7 +232,8 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
depends="test"
|
||||
unless="skipinfo"
|
||||
description="--> Store revision info in build">
|
||||
<property name="revisionInfo.product.dir" location="${ant.file.vitroCore}/.." />
|
||||
|
||||
<property name="revisionInfo.product.dir" location="${corebase.dir}/.." />
|
||||
<property name="revisionInfo.build.file" location="${war-resources.dir}/revisionInfo.txt" />
|
||||
|
||||
<delete file="${revisionInfo.build.file}" />
|
||||
|
@ -243,7 +244,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
<echo file="${revisionInfo.build.file}">${revisionInfo.timestamp}
|
||||
</echo>
|
||||
|
||||
<javac srcdir="${appbase.dir}/../utilities/buildutils/revisioninfo"
|
||||
<javac srcdir="${corebase.dir}/../utilities/buildutils/revisioninfo"
|
||||
destdir="${test-classes.dir}"
|
||||
debug="true"
|
||||
deprecation="${javac.deprecation}"
|
||||
|
@ -267,7 +268,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
target: prepareSolr
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<target name="prepareSolr" depends="properties">
|
||||
<property name="solr.distrib.dir" location="${appbase.dir}/../solr" />
|
||||
<property name="solr.distrib.dir" location="${corebase.dir}/../solr" />
|
||||
<property name="solr.example.dir" location="${solr.distrib.dir}/exampleSolr" />
|
||||
<property name="solr.context.config.example"
|
||||
location="${solr.distrib.dir}/exampleSolrContext.xml" />
|
||||
|
|
|
@ -42,14 +42,18 @@
|
|||
<typedef name="dirDifference"
|
||||
classname="edu.cornell.mannlib.vitro.utilities.anttasks.DirDifferenceResourceCollection"
|
||||
classpathref="anttasks.classpath" />
|
||||
<typedef name="optionalDir"
|
||||
classname="edu.cornell.mannlib.vitro.utilities.anttasks.OptionalDirResourceCollection"
|
||||
classpathref="anttasks.classpath" />
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
target: product-prepare
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<target name="product-prepare" depends="product-prepare-lib">
|
||||
<target name="product-prepare">
|
||||
<mkdir dir="${appbase.dir}" />
|
||||
<mkdir dir="${appbase.dir}/web" />
|
||||
<mkdir dir="${appbase.dir}/src" />
|
||||
<mkdir dir="${appbase.dir}/test" />
|
||||
|
||||
<copy todir="${appbase.dir}/web">
|
||||
<dirDifference primary="${inner.basedir}/web" blocking="${product.modifications.dir}" />
|
||||
|
@ -68,22 +72,38 @@
|
|||
blockingOptional="true" />
|
||||
</copy>
|
||||
<copy todir="${appbase.dir}/src">
|
||||
<fileset dir="./src" />
|
||||
<optionalDir primary="./src" />
|
||||
</copy>
|
||||
|
||||
<copy todir="${appbase.dir}/lib">
|
||||
<dirDifference primary="${inner.basedir}/lib"
|
||||
blocking="./lib"
|
||||
blockingOptional="true" />
|
||||
</copy>
|
||||
<copy todir="${appbase.dir}/lib">
|
||||
<optionalDir primary="./lib" />
|
||||
</copy>
|
||||
|
||||
<copy todir="${appbase.dir}/test">
|
||||
<dirDifference primary="${inner.basedir}/test"
|
||||
blocking="./test"
|
||||
blockingOptional="true" />
|
||||
</copy>
|
||||
<copy todir="${appbase.dir}/test">
|
||||
<optionalDir primary="./test" />
|
||||
</copy>
|
||||
|
||||
<copy todir="${appbase.dir}/test">
|
||||
<dirDifference primary="${inner.basedir}/test"
|
||||
blocking="./test"
|
||||
blockingOptional="true" />
|
||||
</copy>
|
||||
<copy todir="${appbase.dir}/test">
|
||||
<optionalDir primary="./test" />
|
||||
</copy>
|
||||
|
||||
<copy tofile="${appbase.dir}/context.xml" file="${inner.basedir}/context.xml" />
|
||||
</target>
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
target: product-prepare-lib
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<target name="product-prepare-lib">
|
||||
<mkdir dir="${appbase.dir}/lib" />
|
||||
|
||||
<available property="product.lib.exist" file="./lib" />
|
||||
<mergedirs suffix="lib" flag="${product.lib.exist}" />
|
||||
<copydir suffix="lib" flag="${product.lib.exist}" />
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
target: describe
|
||||
================================= -->
|
||||
|
@ -162,36 +182,6 @@
|
|||
<innercall target="war" />
|
||||
</target>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
MACROS
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
|
||||
<!--
|
||||
Call a target in the inner script.
|
||||
-->
|
||||
<macrodef name="mergedirs">
|
||||
<attribute name="suffix" />
|
||||
<attribute name="flag" />
|
||||
<sequential>
|
||||
<copy todir="${appbase.dir}/web">
|
||||
<dirDifference primary="${inner.basedir}/web" blocking="${product.modifications.dir}" />
|
||||
</copy>
|
||||
<copy todir="${appbase.dir}/web">
|
||||
<fileset dir="${product.modifications.dir}" />
|
||||
</copy>
|
||||
<ant dir="${inner.basedir}" inheritall="false">
|
||||
<!-- pass the properties that are needed. -->
|
||||
<propertyset>
|
||||
<propertyref name="build.dir" />
|
||||
<propertyref name="skip.core.themes" />
|
||||
<propertyref name="deploy.properties.file" />
|
||||
</propertyset>
|
||||
<additionalProperties />
|
||||
<target name="@{target}" />
|
||||
</ant>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<!--
|
||||
===========================================================================
|
||||
===========================================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue