NIHVIVO-2811 Restructure the build utilities into a single directory, and compile them all at the beginning.

This commit is contained in:
j2blake 2011-09-12 19:44:32 +00:00
parent 60e92e9bf0
commit 0e4441935e
14 changed files with 113 additions and 147 deletions

View file

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!-- ======================================================================
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.

View file

@ -43,6 +43,11 @@ public abstract class AbstractWrappedFileSet implements ResourceCollection {
return fileSet.createExclude(); return fileSet.createExclude();
} }
public PatternSet createPatternSet() {
return fileSet.createPatternSet();
}
@Override @Override
public Object clone() { public Object clone() {
throw new BuildException(this.getClass().getSimpleName() throw new BuildException(this.getClass().getSimpleName()

View file

@ -1,26 +1,25 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */ /* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.testing; package edu.cornell.mannlib.vitro.utilities.testing;
import static edu.cornell.mannlib.vitro.testing.VitroTestRunner.ReportLevel.BRIEF; import static edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner.ReportLevel.BRIEF;
import static edu.cornell.mannlib.vitro.testing.VitroTestRunner.ReportLevel.FULL; import static edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner.ReportLevel.FULL;
import static edu.cornell.mannlib.vitro.testing.VitroTestRunner.ReportLevel.MORE; import static edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner.ReportLevel.MORE;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.ArrayList; import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.ArrayList;
import java.util.Date; import java.util.Arrays;
import java.util.List; import java.util.Date;
import java.util.List;
import org.junit.runner.Description;
import org.junit.runner.Result; import org.junit.runner.Description;
import org.junit.runner.notification.Failure; import org.junit.runner.Result;
import org.junit.runner.notification.RunListener; import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
import com.ibm.icu.text.SimpleDateFormat;
import edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner.ReportLevel;
import edu.cornell.mannlib.vitro.testing.VitroTestRunner.ReportLevel;
/** /**
* Listen to events as they come from the JUnit test runner. The events from the * Listen to events as they come from the JUnit test runner. The events from the

View file

@ -1,14 +1,14 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */ /* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.testing; package edu.cornell.mannlib.vitro.utilities.testing;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import org.junit.runner.JUnitCore; import org.junit.runner.JUnitCore;
/** /**
* A Java application that will run the Vitro unit tests. It searches for unit * A Java application that will run the Vitro unit tests. It searches for unit

View file

@ -15,21 +15,24 @@
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<dirname property="corebase.dir" file="${ant.file.vitroCore}" /> <dirname property="corebase.dir" file="${ant.file.vitroCore}" />
<!-- <!-- A product script will override appbase.dir, but not corebase.dir -->
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="appbase.dir" location="${corebase.dir}" />
<property name="build.dir" location=".build" /> <property name="build.dir" location=".build" />
<property name="deploy.properties.file" location="config/deploy.properties" /> <property name="deploy.properties.file" location="config/deploy.properties" />
<property name="war.dir" location="${build.dir}/war" /> <property name="utilities.base.dir" location="${corebase.dir}/../utilities/buildutils" />
<property name="war-webinf.dir" location="${war.dir}/WEB-INF" /> <property name="utilities.source.dir" location="${utilities.base.dir}/src" />
<property name="war-classes.dir" location="${war-webinf.dir}/classes" /> <property name="utilities.lib.dir" location="${utilities.base.dir}/lib" />
<property name="war-resources.dir" location="${war-webinf.dir}/resources" />
<property name="revisionInfo.build.file" location="${war-resources.dir}/revisionInfo.txt" />
<property name="test-classes.dir" location="${build.dir}/testclasses" /> <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="revisionInfo.build.file" location="${war.resources.dir}/revisionInfo.txt" />
<property name="test.classes.dir" location="${build.dir}/testClasses" />
<property name="utility.classes.dir" location="${build.dir}/utilityClasses" />
<property name="javac.deprecation" value="true" /> <property name="javac.deprecation" value="true" />
@ -37,23 +40,30 @@
paths: for compiling and running paths: for compiling and running
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<path id="compile.classpath"> <path id="compile.classpath">
<fileset dir="${appbase.dir}/lib"> <fileset dir="${appbase.dir}/lib" includes="*.jar" />
<include name="**/*.jar" /> </path>
</fileset>
<path id="utility.compile.classpath">
<fileset dir="${utilities.lib.dir}" includes="*.jar" />
</path>
<path id="utility.run.classpath">
<pathelement location="${utility.classes.dir}" />
<path refid="utility.compile.classpath" />
</path> </path>
<path id="test.compile.classpath"> <path id="test.compile.classpath">
<pathelement location="${war-classes.dir}" /> <pathelement location="${war.classes.dir}" />
<path refid="compile.classpath" /> <path refid="compile.classpath" />
</path> </path>
<path id="test.run.classpath"> <path id="test.run.classpath">
<pathelement location="${appbase.dir}/test" /> <pathelement location="${appbase.dir}/test" />
<pathelement location="${test-classes.dir}" /> <pathelement location="${test.classes.dir}" />
<path refid="test.compile.classpath" /> <path refid="test.compile.classpath" />
<path refid="utility.run.classpath" />
</path> </path>
<!-- ================================= <!-- =================================
target: describe target: describe
================================= --> ================================= -->
@ -123,25 +133,43 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
<delete dir="${solr.home.dir}" excludes="data/**/*" includeemptydirs="true" /> <delete dir="${solr.home.dir}" excludes="data/**/*" includeemptydirs="true" />
</target> </target>
<!-- - - - - - - - - - - - - - - - - -
target: compileUtilities
- - - - - - - - - - - - - - - - - -->
<target name="compileUtilities">
<mkdir dir="${utility.classes.dir}" />
<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" />
</javac>
<typedef name="dirDifference"
classname="edu.cornell.mannlib.vitro.utilities.anttasks.DirDifferenceFileSet"
classpathref="utility.run.classpath" />
</target>
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
target: prepare target: prepare
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<target name="prepare" depends="properties"> <target name="prepare" depends="properties, compileUtilities">
<mkdir dir="${build.dir}" /> <mkdir dir="${build.dir}" />
<mkdir dir="${war-classes.dir}" /> <mkdir dir="${war.classes.dir}" />
<mkdir dir="${war-resources.dir}" /> <mkdir dir="${war.resources.dir}" />
<mkdir dir="${test-classes.dir}" /> <mkdir dir="${test.classes.dir}" />
<!-- copy all sorts of web stuff into the war directory. --> <!-- copy all sorts of web stuff into the war directory. -->
<copy todir="${war.dir}"> <copy todir="${war.dir}">
<fileset dir="${appbase.dir}/web"> <fileset dir="${appbase.dir}/web" />
</fileset> <fileset dir="${appbase.dir}" includes="themes/**/*" />
<fileset dir="${appbase.dir}">
<include name="themes/**/*" />
</fileset>
</copy> </copy>
<copy todir="${war-webinf.dir}"> <copy todir="${war.webinf.dir}">
<fileset dir="${appbase.dir}"> <fileset dir="${appbase.dir}">
<!-- copy the JARs into the war directory --> <!-- copy the JARs into the war directory -->
<include name="lib/*" /> <include name="lib/*" />
@ -154,7 +182,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
<!-- use the production Log4J properties, unless a debug version exists. --> <!-- use the production Log4J properties, unless a debug version exists. -->
<available file="${appbase.dir}/config/debug.log4j.properties" <available file="${appbase.dir}/config/debug.log4j.properties"
property="debug.log4j.exists" /> property="debug.log4j.exists" />
<copy tofile="${war-classes.dir}/log4j.properties" filtering="true" overwrite="true"> <copy tofile="${war.classes.dir}/log4j.properties" filtering="true" overwrite="true">
<fileset dir="${appbase.dir}/config"> <fileset dir="${appbase.dir}/config">
<include name="default.log4j.properties" unless="debug.log4j.exists" /> <include name="default.log4j.properties" unless="debug.log4j.exists" />
<include name="debug.log4j.properties" if="debug.log4j.exists" /> <include name="debug.log4j.properties" if="debug.log4j.exists" />
@ -164,7 +192,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
</filterchain> </filterchain>
</copy> </copy>
<copy todir="${war-classes.dir}"> <copy todir="${war.classes.dir}">
<!-- copy the deploy.properties into the war directory --> <!-- copy the deploy.properties into the war directory -->
<fileset file="${deploy.properties.file}" /> <fileset file="${deploy.properties.file}" />
@ -183,14 +211,14 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
<target name="compile" depends="prepare" description="--> Compile Java sources"> <target name="compile" depends="prepare" description="--> Compile Java sources">
<!-- deletes all files that depend on changed .java files --> <!-- deletes all files that depend on changed .java files -->
<depend srcdir="${appbase.dir}/src" <depend srcdir="${appbase.dir}/src"
destdir="${war-classes.dir}" destdir="${war.classes.dir}"
closure="false" closure="false"
cache="${build.dir}/.depcache"> cache="${build.dir}/.depcache">
<classpath refid="compile.classpath" /> <classpath refid="compile.classpath" />
</depend> </depend>
<javac srcdir="${appbase.dir}/src" <javac srcdir="${appbase.dir}/src"
destdir="${war-classes.dir}" destdir="${war.classes.dir}"
debug="true" debug="true"
deprecation="${javac.deprecation}" deprecation="${javac.deprecation}"
encoding="UTF8" encoding="UTF8"
@ -206,7 +234,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
================================= --> ================================= -->
<target name="test" depends="compile" unless="skiptests" description="--> Run JUnit tests"> <target name="test" depends="compile" unless="skiptests" description="--> Run JUnit tests">
<javac srcdir="${appbase.dir}/test" <javac srcdir="${appbase.dir}/test"
destdir="${test-classes.dir}" destdir="${test.classes.dir}"
debug="true" debug="true"
deprecation="${javac.deprecation}" deprecation="${javac.deprecation}"
encoding="UTF8" encoding="UTF8"
@ -216,7 +244,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
<classpath refid="test.compile.classpath" /> <classpath refid="test.compile.classpath" />
</javac> </javac>
<java classname="edu.cornell.mannlib.vitro.testing.VitroTestRunner" <java classname="edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner"
fork="yes" fork="yes"
failonerror="true"> failonerror="true">
<classpath refid="test.run.classpath" /> <classpath refid="test.run.classpath" />
@ -229,8 +257,7 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
target: jar target: jar
================================= --> ================================= -->
<target name="jar" depends="test" description="--> Compile the Java, and build a JAR file"> <target name="jar" depends="test" description="--> Compile the Java, and build a JAR file">
<jar basedir="${war-classes.dir}" <jar basedir="${war.classes.dir}" destfile="${build.dir}/${ant.project.name}.jar" />
destfile="${build.dir}/${ant.project.name}.jar" />
</target> </target>
<!-- ================================= <!-- =================================
@ -364,20 +391,10 @@ deploy - Deploy the application directly into the Tomcat webapps directory.
<attribute name="productName" /> <attribute name="productName" />
<attribute name="productCheckoutDir" /> <attribute name="productCheckoutDir" />
<sequential> <sequential>
<javac srcdir="${corebase.dir}/../utilities/buildutils/revisioninfo"
destdir="${test-classes.dir}"
debug="true"
deprecation="${javac.deprecation}"
encoding="UTF8"
includeantruntime="false"
optimize="false"
source="1.6">
</javac>
<java classname="edu.cornell.mannlib.vitro.utilities.revisioninfo.RevisionInfoBuilder" <java classname="edu.cornell.mannlib.vitro.utilities.revisioninfo.RevisionInfoBuilder"
fork="no" fork="no"
failonerror="true"> failonerror="true">
<classpath refid="test.run.classpath" /> <classpath refid="utility.run.classpath" />
<arg value="@{productName}" /> <arg value="@{productName}" />
<arg file="@{productCheckoutDir}" /> <arg file="@{productCheckoutDir}" />
<arg file="${revisionInfo.build.file}" /> <arg file="${revisionInfo.build.file}" />

View file

@ -33,17 +33,10 @@
<pathelement location="${vivoProduct.basedir}/../utilities/anttasks/classes" /> <pathelement location="${vivoProduct.basedir}/../utilities/anttasks/classes" />
</path> </path>
<!-- - - - - - - - - - - - - - - - - -
custom Ant types
- - - - - - - - - - - - - - - - - -->
<typedef name="dirDifference"
classname="edu.cornell.mannlib.vitro.utilities.anttasks.DirDifferenceFileSet"
classpathref="anttasks.classpath" />
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
target: prepare target: prepare
- - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - -->
<target name="prepare" depends="product-prepare,vitroCore.prepare" /> <target name="prepare" depends="compileUtilities,product-prepare,vitroCore.prepare" />
<!-- - - - - - - - - - - - - - - - - - <!-- - - - - - - - - - - - - - - - - -
target: product-prepare target: product-prepare
@ -61,25 +54,26 @@
<fileset dir="${product.modifications.dir}" /> <fileset dir="${product.modifications.dir}" />
</copy> </copy>
<patternset id="appbase.patterns">
<include name="src/**/*" />
<include name="lib/**/*" />
<include name="test/**/*" />
<include name="themes/**/*" />
<include name="config/*.properties" />
<include name="config/solr/*" />
<include name="context.xml" />
</patternset>
<copy todir="${appbase.dir}" includeemptydirs="true"> <copy todir="${appbase.dir}" includeemptydirs="true">
<dirDifference dir="${corebase.dir}"> <dirDifference dir="${corebase.dir}">
<include name="src/**/*" /> <patternset refid="appbase.patterns" />
<include name="lib/**/*" /> <exclude name="themes/**/*" if="skip.core.themes" />
<include name="test/**/*" />
<include name="themes/**/*" unless="skip.core.themes" />
<include name="config/*.properties" />
<include name="config/solr/*" />
<include name="context.xml" />
<blockingPath> <blockingPath>
<pathelement location="." /> <pathelement location="." />
</blockingPath> </blockingPath>
</dirDifference> </dirDifference>
<fileset dir="."> <fileset dir=".">
<include name="src/**/*" /> <patternset refid="appbase.patterns" />
<include name="lib/**/*" />
<include name="test/**/*" />
<include name="themes/**/*" />
<include name="context.xml" />
</fileset> </fileset>
</copy> </copy>
</target> </target>
@ -100,16 +94,16 @@
In regular use, checks that all appropriate source files have license tags. In regular use, checks that all appropriate source files have license tags.
At release time, applies license text to source files. At release time, applies license text to source files.
The files are handled as properties so they can be overridden from the command line, if desired.
NOTE: don't override licenser.properties.file from the command line.
Instead, override licenser.core.properties.file and licenser.product.properties.file
================================= --> ================================= -->
<target name="licenser" description="--> Check source files for licensing tags"> <target name="licenser" description="--> Check source files for licensing tags">
<property name="licenser.product.properties.file" <property name="licenser.product.properties.file"
location="./config/licenser/licenser.properties" /> location="./config/licenser/licenser.properties" />
<property name="licenser.core.properties.file" <property name="licenser.core.properties.file"
location="${corebase.dir}/config/licenser/licenser.properties" /> location="${corebase.dir}/config/licenser/licenser.properties" />
<runLicenserScript productname="${ant.project.name}" propertiesfile="${licenser.product.properties.file}" /> <runLicenserScript productname="${ant.project.name}"
<runLicenserScript productname="Vitro core" propertiesfile="${licenser.core.properties.file}" /> propertiesfile="${licenser.product.properties.file}" />
<runLicenserScript productname="Vitro core"
propertiesfile="${licenser.core.properties.file}" />
</target> </target>
</project> </project>