NIHVIVO-2811 getting closer - need a way of "copying" a directory that may not exist.
This commit is contained in:
parent
def608dcda
commit
11239bf040
9 changed files with 565 additions and 226 deletions
46
utilities/anttasks/build.xml
Normal file
46
utilities/anttasks/build.xml
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- ======================================================================
|
||||
|
||||
Create:
|
||||
|
||||
1) DirDifferenceResourceCollection -
|
||||
A new resource collection that will allow us to efficiently merge
|
||||
a primary directory with an overriding directory.
|
||||
A file in the primary directory is included in the resource collection
|
||||
if there is no matching file in the blocking directory
|
||||
|
||||
====================================================================== -->
|
||||
<project name="antTypesAndTasks" default="all">
|
||||
|
||||
<property name="source.dir" location="./src" />
|
||||
<property name="antclasses.dir" location="./classes" />
|
||||
<property name="lib.dir" location="./lib" />
|
||||
|
||||
<path id="compile.classpath">
|
||||
<pathelement location="${lib.dir}/ant.jar" />
|
||||
</path>
|
||||
|
||||
<!-- =================================
|
||||
target: all
|
||||
================================= -->
|
||||
<target name="all" description="compile the custom types and tasks">
|
||||
<javac srcdir="${source.dir}"
|
||||
destdir="${antclasses.dir}"
|
||||
debug="true"
|
||||
encoding="UTF8"
|
||||
includeantruntime="false"
|
||||
source="1.6">
|
||||
<classpath refid="compile.classpath" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
target: clean
|
||||
================================= -->
|
||||
<target name="clean" description="start from scratch">
|
||||
<delete dir="${antclasses.dir}" />
|
||||
<mkdir dir="${antclasses.dir}" />
|
||||
</target>
|
||||
|
||||
|
||||
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
utilities/anttasks/lib/ant.jar
Normal file
BIN
utilities/anttasks/lib/ant.jar
Normal file
Binary file not shown.
|
@ -0,0 +1,126 @@
|
|||
/* $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.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;
|
||||
|
||||
/**
|
||||
* Include all files that are in the primary directory, but do not have matching
|
||||
* files in the blocking directory.
|
||||
*/
|
||||
public abstract class AbstractDirResourceCollection extends DataType implements
|
||||
ResourceCollection {
|
||||
protected List<FileResource> files = null;
|
||||
protected File primaryDir;
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
protected abstract void fillFilesList();
|
||||
|
||||
/**
|
||||
* The directory path must be provided, and unless the optional flag is set,
|
||||
* must point to an existing, readable directory.
|
||||
*/
|
||||
protected 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.");
|
||||
}
|
||||
}
|
||||
|
||||
protected 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.
|
||||
*/
|
||||
protected 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,196 @@
|
|||
/* $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.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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
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;
|
||||
}
|
||||
|
||||
public void setBlockingOptional(boolean blockingOptional) {
|
||||
this.blockingOptional = blockingOptional;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
private void fillFilesList() {
|
||||
if (files != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
confirmValidDirectory(primaryDir, "Primary", false);
|
||||
confirmValidDirectory(blockingDir, "Blocking", blockingOptional);
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Include any file from the primary directory that does not match a file in
|
||||
* the blocking directory.
|
||||
*
|
||||
* Include all files from any subdirectory that has no matching subdirectory
|
||||
* in the blocking directory.
|
||||
*
|
||||
* Include all unblocked files from any subdirectory that has a matching
|
||||
* subdirectory in the blocking directory.
|
||||
*
|
||||
* NOTE: if a file is matched by a subdirectory, the file is blocked. If a
|
||||
* subdirectory is matched by a file, an exception is thrown.
|
||||
*/
|
||||
private void includeUnblockedFiles(File primary, File blocking) {
|
||||
for (File file : primary.listFiles(new NonDirectoryFilter())) {
|
||||
if (!isBlocked(file, blocking)) {
|
||||
files.add(buildResource(file));
|
||||
}
|
||||
}
|
||||
for (File primarySubDir : primary.listFiles(new DirectoryFilter())) {
|
||||
File blockingSubDir = findMatchingDir(primarySubDir, blocking);
|
||||
if (blockingSubDir == null) {
|
||||
includeAllFiles(primarySubDir);
|
||||
} else {
|
||||
includeUnblockedFiles(primarySubDir, blockingSubDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBlocked(File file, File blocking) {
|
||||
return new File(blocking, file.getName()).exists();
|
||||
}
|
||||
|
||||
private File findMatchingDir(File primary, File blockingParent) {
|
||||
File dir = new File(blockingParent, primary.getName());
|
||||
if (!dir.exists()) {
|
||||
return null;
|
||||
}
|
||||
if (!dir.isDirectory()) {
|
||||
throw new BuildException("Directory '" + primary
|
||||
+ "' is blocked by a non-directory '" + dir.getPath() + "'");
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,29 +13,30 @@
|
|||
<!-- - - - - - - - - - - - - - - - - -
|
||||
properties
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<property name="corebase.dir" location="." />
|
||||
|
||||
<!--
|
||||
If calling from a Product build script, these properties already point to
|
||||
the product-related locations, so setting them here has no effect.
|
||||
-->
|
||||
<property name="appbase.dir" location="${corebase.dir}" />
|
||||
<property name="build.dir" location=".build" />
|
||||
<property name="webapp.dir" location="." />
|
||||
<property name="deploy.properties.file" location="config/deploy.properties" />
|
||||
|
||||
<property name="war.dir" location="${build.dir}/war" />
|
||||
<property name="war-webinf.dir" location="${war.dir}/WEB-INF" />
|
||||
<property name="war-classes.dir" location="${war-webinf.dir}/classes" />
|
||||
<property name="war-resources.dir" location="${war-webinf.dir}/resources" />
|
||||
<property name="war-lib.dir" location="${war-webinf.dir}/lib" />
|
||||
|
||||
<property name="test-classes.dir" location="${build.dir}/testclasses" />
|
||||
|
||||
<property name="servletjars.dir" location="${build.dir}/servletjars" />
|
||||
|
||||
<property name="javac.deprecation" value="true" />
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
paths: for compiling and running
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<path id="compile.classpath">
|
||||
<fileset dir="${war-lib.dir}">
|
||||
<include name="**/*.jar" />
|
||||
</fileset>
|
||||
<fileset dir="${servletjars.dir}">
|
||||
<fileset dir="${appbase.dir}/lib">
|
||||
<include name="**/*.jar" />
|
||||
</fileset>
|
||||
</path>
|
||||
|
@ -46,9 +47,7 @@
|
|||
</path>
|
||||
|
||||
<path id="test.run.classpath">
|
||||
<!-- This holds data files and a special log4j.properties -->
|
||||
<pathelement location="${webapp.dir}/test" />
|
||||
|
||||
<pathelement location="${appbase.dir}/test" />
|
||||
<pathelement location="${test-classes.dir}" />
|
||||
<path refid="test.compile.classpath" />
|
||||
</path>
|
||||
|
@ -77,12 +76,6 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
target: properties
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<target name="properties">
|
||||
<!--
|
||||
If calling from a Product build script, then this property
|
||||
already points to the deploy.properties file of the Product.
|
||||
-->
|
||||
<property name="deploy.properties.file" location="config/deploy.properties" />
|
||||
|
||||
<fail message="You must create a "${deploy.properties.file}" file.">
|
||||
<condition>
|
||||
<not>
|
||||
|
@ -118,7 +111,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
</condition>
|
||||
</fail>
|
||||
|
||||
<property name="solr.home" location="${vitro.home.directory}/solr" />
|
||||
<property name="solr.home.dir" location="${vitro.home.directory}/solr" />
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
|
@ -126,7 +119,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
================================= -->
|
||||
<target name="clean" depends="properties" description="--> Delete all artifacts.">
|
||||
<delete dir="${build.dir}" />
|
||||
<delete dir="${solr.home}" excludes="data/**/*" includeemptydirs="true" />
|
||||
<delete dir="${solr.home.dir}" excludes="data/**/*" includeemptydirs="true" />
|
||||
</target>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
|
@ -140,7 +133,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
|
||||
<!-- copy all sorts of web stuff (with or without themes) into the war directory. -->
|
||||
<copy todir="${war.dir}">
|
||||
<fileset dir="${webapp.dir}/web">
|
||||
<fileset dir="${appbase.dir}/web">
|
||||
<!--
|
||||
If a product doesn't want the core themes, it can
|
||||
set this property and they will be skipped.
|
||||
|
@ -150,7 +143,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
</copy>
|
||||
|
||||
<copy todir="${war-webinf.dir}">
|
||||
<fileset dir="${webapp.dir}">
|
||||
<fileset dir="${appbase.dir}">
|
||||
<!-- copy the JARs into the war directory -->
|
||||
<include name="lib/*" />
|
||||
<!-- these are already in Tomcat: we mustn't conflict. -->
|
||||
|
@ -160,10 +153,10 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
</copy>
|
||||
|
||||
<!-- use the production Log4J properties, unless a debug version exists. -->
|
||||
<available file="${webapp.dir}/config/debug.log4j.properties"
|
||||
<available file="${appbase.dir}/config/debug.log4j.properties"
|
||||
property="debug.log4j.exists" />
|
||||
<copy tofile="${war-classes.dir}/log4j.properties" filtering="true" overwrite="true">
|
||||
<fileset dir="${webapp.dir}/config">
|
||||
<fileset dir="${appbase.dir}/config">
|
||||
<include name="default.log4j.properties" unless="debug.log4j.exists" />
|
||||
<include name="debug.log4j.properties" if="debug.log4j.exists" />
|
||||
</fileset>
|
||||
|
@ -177,19 +170,11 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
<fileset file="${deploy.properties.file}" />
|
||||
|
||||
<!-- copy any xml files from source tree to the war directory -->
|
||||
<fileset dir="${webapp.dir}/src" includes="**/*.xml" />
|
||||
</copy>
|
||||
|
||||
<!-- copy the servlet JARs into their own directory, to compile against. -->
|
||||
<copy todir="${servletjars.dir}">
|
||||
<fileset dir="${webapp.dir}/lib">
|
||||
<include name="jsp-api.jar" />
|
||||
<include name="servlet-api.jar" />
|
||||
</fileset>
|
||||
<fileset dir="${appbase.dir}/src" includes="**/*.xml" />
|
||||
</copy>
|
||||
|
||||
<!-- copy the context file into the war directory -->
|
||||
<copy file="${webapp.dir}/context.xml" tofile="${war.dir}/META-INF/context.xml" />
|
||||
<copy file="${appbase.dir}/context.xml" tofile="${war.dir}/META-INF/context.xml" />
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
|
@ -197,14 +182,14 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
================================= -->
|
||||
<target name="compile" depends="prepare" description="--> Compile Java sources">
|
||||
<!-- deletes all files that depend on changed .java files -->
|
||||
<depend srcdir="${webapp.dir}/src"
|
||||
<depend srcdir="${appbase.dir}/src"
|
||||
destdir="${war-classes.dir}"
|
||||
closure="false"
|
||||
cache="${build.dir}/.depcache">
|
||||
<classpath refid="compile.classpath" />
|
||||
</depend>
|
||||
|
||||
<javac srcdir="${webapp.dir}/src"
|
||||
<javac srcdir="${appbase.dir}/src"
|
||||
destdir="${war-classes.dir}"
|
||||
debug="true"
|
||||
deprecation="${javac.deprecation}"
|
||||
|
@ -220,7 +205,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
target: test
|
||||
================================= -->
|
||||
<target name="test" depends="compile" unless="skiptests" description="--> Run JUnit tests">
|
||||
<javac srcdir="${webapp.dir}/test"
|
||||
<javac srcdir="${appbase.dir}/test"
|
||||
destdir="${test-classes.dir}"
|
||||
debug="true"
|
||||
deprecation="${javac.deprecation}"
|
||||
|
@ -235,7 +220,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
fork="yes"
|
||||
failonerror="true">
|
||||
<classpath refid="test.run.classpath" />
|
||||
<arg file="${webapp.dir}/test" />
|
||||
<arg file="${appbase.dir}/test" />
|
||||
<arg value="${testlevel}" />
|
||||
</java>
|
||||
</target>
|
||||
|
@ -258,7 +243,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
<echo file="${revisionInfo.build.file}">${revisionInfo.timestamp}
|
||||
</echo>
|
||||
|
||||
<javac srcdir="${webapp.dir}/../utilities/buildutils/revisioninfo"
|
||||
<javac srcdir="${appbase.dir}/../utilities/buildutils/revisioninfo"
|
||||
destdir="${test-classes.dir}"
|
||||
debug="true"
|
||||
deprecation="${javac.deprecation}"
|
||||
|
@ -282,19 +267,19 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
target: prepareSolr
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<target name="prepareSolr" depends="properties">
|
||||
<property name="solr.distrib.dir" location="${webapp.dir}/../solr" />
|
||||
<property name="solr.distrib.dir" location="${appbase.dir}/../solr" />
|
||||
<property name="solr.example.dir" location="${solr.distrib.dir}/exampleSolr" />
|
||||
<property name="solr.context.config.example"
|
||||
location="${solr.distrib.dir}/exampleSolrContext.xml" />
|
||||
<property name="solr.war" location="${solr.distrib.dir}/apache-solr-3.1.0.war" />
|
||||
|
||||
<property name="solr.docbase" location="${solr.home}/solr.war" />
|
||||
<property name="solr.docbase" location="${solr.home.dir}/solr.war" />
|
||||
<property name="solr.context.name" value="${webapp.name}solr" />
|
||||
<property name="solr.context.config" location="${solr.home}/${solr.context.name}.xml" />
|
||||
<property name="solr.context.config" location="${solr.home.dir}/${solr.context.name}.xml" />
|
||||
|
||||
<!-- Create and copy the example directory to the solr.home directory. -->
|
||||
<mkdir dir="${solr.home}" />
|
||||
<copy todir="${solr.home}">
|
||||
<!-- Create and copy the example directory to the solr.home.dir directory. -->
|
||||
<mkdir dir="${solr.home.dir}" />
|
||||
<copy todir="${solr.home.dir}">
|
||||
<fileset dir="${solr.example.dir}" includes="**/*" />
|
||||
</copy>
|
||||
|
||||
|
@ -303,7 +288,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
<fileset file="${solr.war}" />
|
||||
</copy>
|
||||
<war destfile="${solr.docbase}" update="true">
|
||||
<classes dir="${webapp.dir}/config/solr/" />
|
||||
<classes dir="${appbase.dir}/config/solr/" />
|
||||
</war>
|
||||
|
||||
<!-- if no mask is define, go with an unsecured installation. -->
|
||||
|
@ -360,12 +345,12 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
|
|||
================================= -->
|
||||
<target name="licenser" description="--> Check source files for licensing tags">
|
||||
<property name="licenser.properties.file"
|
||||
location="${webapp.dir}/config/licenser/licenser.properties" />
|
||||
location="${appbase.dir}/config/licenser/licenser.properties" />
|
||||
<property name="licenser.label" value="Vitro core" />
|
||||
|
||||
<echo message="Checking license tags on ${licenser.label}" />
|
||||
|
||||
<exec executable="ruby" dir="${webapp.dir}/../utilities/licenser" failonerror="true">
|
||||
<exec executable="ruby" dir="${appbase.dir}/../utilities/licenser" failonerror="true">
|
||||
<arg value="licenser.rb" />
|
||||
<arg value="${licenser.properties.file}" />
|
||||
<redirector outputproperty="licenser.test.output" alwayslog="true" />
|
||||
|
|
|
@ -29,56 +29,60 @@
|
|||
Everything else hangs from the build directory.
|
||||
-->
|
||||
<property name="build.dir" location="./.build" />
|
||||
<property name="war.dir" location="${build.dir}/war" />
|
||||
<property name="war-webinf.dir" location="${war.dir}/WEB-INF" />
|
||||
<property name="war-classes.dir" location="${war-webinf.dir}/classes" />
|
||||
<property name="war-resources.dir" location="${war-webinf.dir}/resources" />
|
||||
<property name="war-lib.dir" location="${war-webinf.dir}/lib" />
|
||||
<property name="test-classes.dir" location="${build.dir}/testclasses" />
|
||||
<property name="servletjars.dir" location="${build.dir}/servletjars" />
|
||||
|
||||
<property name="javac.deprecation" value="true" />
|
||||
<property name="appbase.dir" location="${build.dir}/appBase" />
|
||||
|
||||
|
||||
<!-- Is there a "src" directory in the product? -->
|
||||
<property name="product.source.dir" location="./src" />
|
||||
<available property="product.sources.exist" file="${product.source.dir}" />
|
||||
|
||||
<!-- Is there a "test" directory in the product? -->
|
||||
<property name="product.test.dir" location="./test" />
|
||||
<available property="product.tests.exist" file="${product.test.dir}" />
|
||||
|
||||
<!-- Is there a "themes" directory in the product? -->
|
||||
<property name="product.themes.dir" location="./themes" />
|
||||
<available property="product.themes.exist" file="${product.themes.dir}" />
|
||||
|
||||
<!-- Is there a modifications directory in the product? -->
|
||||
<property name="product.modifications.dir" location="./modifications" />
|
||||
<available property="product.modifications.exist" file="${product.modifications.dir}" />
|
||||
<dirname property="vivoProduct.basedir" file="${ant.file.vivoProduct}" />
|
||||
<path id="anttasks.classpath">
|
||||
<pathelement location="${vivoProduct.basedir}/../utilities/anttasks/classes" />
|
||||
</path>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
paths: for compiling and running
|
||||
custom Ant types
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<path id="compile.classpath">
|
||||
<fileset dir="${war-lib.dir}">
|
||||
<include name="**/*.jar" />
|
||||
</fileset>
|
||||
<fileset dir="${servletjars.dir}">
|
||||
<include name="**/*.jar" />
|
||||
</fileset>
|
||||
</path>
|
||||
<typedef name="dirDifference"
|
||||
classname="edu.cornell.mannlib.vitro.utilities.anttasks.DirDifferenceResourceCollection"
|
||||
classpathref="anttasks.classpath" />
|
||||
|
||||
<path id="test.compile.classpath">
|
||||
<pathelement location="${product.test.dir}"/>
|
||||
<pathelement location="${war-classes.dir}" />
|
||||
<path refid="compile.classpath" />
|
||||
</path>
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
target: product-prepare
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<target name="product-prepare" depends="product-prepare-lib">
|
||||
<mkdir dir="${appbase.dir}" />
|
||||
<mkdir dir="${appbase.dir}/web" />
|
||||
<mkdir dir="${appbase.dir}/src" />
|
||||
|
||||
<path id="test.run.classpath">
|
||||
<pathelement location="${test-classes.dir}" />
|
||||
<path refid="test.compile.classpath" />
|
||||
</path>
|
||||
<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>
|
||||
|
||||
<copy todir="${appbase.dir}/config">
|
||||
<fileset dir="${inner.basedir}/config" />
|
||||
</copy>
|
||||
|
||||
<copy todir="${appbase.dir}/src">
|
||||
<dirDifference primary="${inner.basedir}/src"
|
||||
blocking="./src"
|
||||
blockingOptional="true" />
|
||||
</copy>
|
||||
<copy todir="${appbase.dir}/src">
|
||||
<fileset dir="./src" />
|
||||
</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
|
||||
|
@ -99,6 +103,121 @@
|
|||
<innercall target="clean" />
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
target: deploy
|
||||
================================= -->
|
||||
<target name="deploy"
|
||||
depends="product-prepare"
|
||||
description="--> Build the app and install in Tomcat">
|
||||
<innercall target="deploy" />
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
target: compile
|
||||
================================= -->
|
||||
<target name="compile" depends="product-prepare" description="--> Compile Java sources.">
|
||||
<innercall target="compile" />
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
target: test
|
||||
================================= -->
|
||||
<target name="test" depends="product-prepare" description="--> Run JUnit tests">
|
||||
<innercall target="test" />
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
target: revisionInfo
|
||||
================================= -->
|
||||
<target name="revisionInfo"
|
||||
depends="product-prepare"
|
||||
description="--> Store revision info in build">
|
||||
<innercall target="revisionInfo" />
|
||||
<antcall target="productRevisionInfo" />
|
||||
</target>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
target: productRevisionInfo
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<target name="productRevisionInfo" unless="skipinfo">
|
||||
<property name="revisionInfo.product.dir" location="${ant.file}/.." />
|
||||
<property name="revisionInfo.build.file" location="${war-resources.dir}/revisionInfo.txt" />
|
||||
|
||||
<java classname="edu.cornell.mannlib.vitro.utilities.revisioninfo.RevisionInfoBuilder"
|
||||
fork="no"
|
||||
failonerror="true">
|
||||
<classpath refid="test.run.classpath" />
|
||||
<arg value="${ant.project.name}" />
|
||||
<arg file="${revisionInfo.product.dir}" />
|
||||
<arg file="${revisionInfo.build.file}" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
target: war
|
||||
================================= -->
|
||||
<target name="war"
|
||||
depends="product-prepare"
|
||||
description="--> Build the app and create a WAR file">
|
||||
<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>
|
||||
|
||||
<!--
|
||||
===========================================================================
|
||||
===========================================================================
|
||||
===========================================================================
|
||||
NOT YET USING ANYTHING BELOW HERE
|
||||
===========================================================================
|
||||
===========================================================================
|
||||
===========================================================================
|
||||
-->
|
||||
|
||||
<!-- Is there a "src" directory in the product? -->
|
||||
<property name="product.source.dir" location="./src" />
|
||||
<available property="product.sources.exist" file="${product.source.dir}" />
|
||||
|
||||
<!-- Is there a "test" directory in the product? -->
|
||||
<property name="product.test.dir" location="./test" />
|
||||
<available property="product.tests.exist" file="${product.test.dir}" />
|
||||
|
||||
<!-- Is there a "themes" directory in the product? -->
|
||||
<property name="product.themes.dir" location="./themes" />
|
||||
<available property="product.themes.exist" file="${product.themes.dir}" />
|
||||
|
||||
<!-- Is there a modifications directory in the product? -->
|
||||
<property name="product.modifications.dir" location="./modifications" />
|
||||
<available property="product.modifications.exist" file="${product.modifications.dir}" />
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
target: productPrepare
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
|
@ -126,146 +245,12 @@
|
|||
</target>
|
||||
|
||||
|
||||
<!-- =================================
|
||||
target: compile
|
||||
================================= -->
|
||||
<target name="compile" description="--> Compile Java sources.">
|
||||
<innercall target="compile" />
|
||||
<antcall target="productCompile" />
|
||||
</target>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
target: productCompile
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<target name="productCompile" depends="productPrepare" if="product.sources.exist">
|
||||
<property name="product.classes.dir" value="${build.dir}/${ant.project.name}/classes" />
|
||||
<mkdir dir="${product.classes.dir}" />
|
||||
<javac srcdir="${product.source.dir}"
|
||||
destdir="${product.classes.dir}"
|
||||
debug="true"
|
||||
deprecation="${javac.deprecation}"
|
||||
encoding="UTF8"
|
||||
includeantruntime="false"
|
||||
optimize="true"
|
||||
source="1.6">
|
||||
<classpath>
|
||||
<path refid="compile.classpath" />
|
||||
<pathelement location="${build.dir}/war/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
<copy todir="${build.dir}/war/WEB-INF/classes" overwrite="true">
|
||||
<fileset dir="${product.classes.dir}" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
target: test
|
||||
================================= -->
|
||||
<target name="test" description="--> Run JUnit tests">
|
||||
<innercall target="test" />
|
||||
<antcall target="productTest" />
|
||||
</target>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
target: productTest
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<target name="productTest" depends="productCompile" if="product.tests.exist" unless="skiptests">
|
||||
<javac srcdir="${product.test.dir}"
|
||||
destdir="${test-classes.dir}"
|
||||
debug="true"
|
||||
deprecation="true"
|
||||
encoding="UTF8"
|
||||
includeantruntime="false"
|
||||
optimize="false"
|
||||
source="1.6">
|
||||
<classpath refid="test.compile.classpath" />
|
||||
</javac>
|
||||
|
||||
<java classname="edu.cornell.mannlib.vitro.testing.VitroTestRunner"
|
||||
fork="yes"
|
||||
failonerror="true">
|
||||
<classpath refid="test.run.classpath" />
|
||||
<arg file="${product.test.dir}" />
|
||||
<arg value="${testlevel}" />
|
||||
</java>
|
||||
</target>
|
||||
<!-- =================================
|
||||
target: revisionInfo
|
||||
================================= -->
|
||||
<target name="revisionInfo" description="--> Store revision info in build">
|
||||
<innercall target="revisionInfo" />
|
||||
<antcall target="productRevisionInfo" />
|
||||
</target>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
target: productRevisionInfo
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<target name="productRevisionInfo" depends="productTest" unless="skipinfo">
|
||||
<property name="revisionInfo.product.dir" location="${ant.file}/.." />
|
||||
<property name="revisionInfo.build.file" location="${war-resources.dir}/revisionInfo.txt" />
|
||||
|
||||
<java classname="edu.cornell.mannlib.vitro.utilities.revisioninfo.RevisionInfoBuilder"
|
||||
fork="no"
|
||||
failonerror="true">
|
||||
<classpath refid="test.run.classpath" />
|
||||
<arg value="${ant.project.name}" />
|
||||
<arg file="${revisionInfo.product.dir}" />
|
||||
<arg file="${revisionInfo.build.file}" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
target: deploySolr
|
||||
|
||||
This must be visible so a second-level product like CornellVivo can call it.
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<target name="deploySolr" >
|
||||
<innercall target="deploySolr" />
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
target: deploy
|
||||
================================= -->
|
||||
<target name="deploy" description="--> Build the app and install in Tomcat">
|
||||
<!-- the inner "deploy" would just do a sync that will be done by productDeploy -->
|
||||
<innercall target="revisionInfo" />
|
||||
<antcall target="deploySolr" />
|
||||
<antcall target="productDeploy" />
|
||||
</target>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
target: productDeploy
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<target name="productDeploy" depends="productRevisionInfo">
|
||||
<property name="webapp.deploy.home" value="${tomcat.home}/webapps/${webapp.name}" />
|
||||
|
||||
<mkdir dir="${webapp.deploy.home}" />
|
||||
|
||||
<sync todir="${webapp.deploy.home}" includeemptydirs="true">
|
||||
<fileset dir="${build.dir}/war" />
|
||||
</sync>
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
target: war
|
||||
================================= -->
|
||||
<target name="war" description="--> Build the app and create a WAR file">
|
||||
<innercall target="revisionInfo" />
|
||||
<antcall target="productWar" />
|
||||
</target>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - -
|
||||
target: productWar
|
||||
- - - - - - - - - - - - - - - - - -->
|
||||
<target name="productWar" depends="productRevisionInfo">
|
||||
<jar basedir="${build.dir}/war" destfile="${build.dir}/${webapp.name}.war"/>
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
target: jar
|
||||
================================= -->
|
||||
<target name="jar" depends="revisionInfo" description="--> Build the app and create a JAR file">
|
||||
<jar basedir="${build.dir}/war/WEB-INF/classes" destfile="${build.dir}/${webapp.name}.jar" />
|
||||
<jar basedir="${build.dir}/war/WEB-INF/classes"
|
||||
destfile="${build.dir}/${webapp.name}.jar" />
|
||||
</target>
|
||||
|
||||
<!-- =================================
|
||||
|
@ -310,6 +295,7 @@
|
|||
<!-- pass the properties that are needed. -->
|
||||
<propertyset>
|
||||
<propertyref name="build.dir" />
|
||||
<propertyref name="appbase.dir" />
|
||||
<propertyref name="skip.core.themes" />
|
||||
<propertyref name="deploy.properties.file" />
|
||||
</propertyset>
|
||||
|
|
Loading…
Add table
Reference in a new issue