
Create an Ant target that checks web.xml against the assembled webapp, looking for conditions that violate the Servlet spec or the JSP spec, but that Tomcat does not complain about. This will not be a main-stream target, but must be specifically invoked by developers or by Jenkins in order to be effective.
485 lines
19 KiB
XML
485 lines
19 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
|
|
|
<!-- ======================================================================
|
|
Build script for the Vitro core webapp.
|
|
|
|
This can be used on its own, or invoked from a Product build script.
|
|
====================================================================== -->
|
|
|
|
<project name="vitroCore" default="describe">
|
|
|
|
<!-- A product script will override appbase.dir, but not corebase.dir -->
|
|
<dirname property="corebase.dir" file="${ant.file.vitroCore}" />
|
|
<property name="appbase.dir" location="${corebase.dir}" />
|
|
|
|
<property name="build.properties.file" location="config/build.properties" />
|
|
|
|
<property name="build.dir" location=".build" />
|
|
|
|
<property name="buildtools.dir" location="${corebase.dir}/../utilities/buildutils" />
|
|
<property name="buildtools.source.dir" location="${buildtools.dir}/src" />
|
|
<property name="buildtools.lib.dir" location="${buildtools.dir}/lib" />
|
|
<property name="buildtools.compiled.dir" location="${build.dir}/buildTools" />
|
|
|
|
<property name="main.build.dir" location="${build.dir}/main"/>
|
|
<property name="main.webapp.dir" location="${main.build.dir}/webapp" />
|
|
<property name="main.webinf.dir" location="${main.webapp.dir}/WEB-INF" />
|
|
<property name="main.compiled.dir" location="${main.webinf.dir}/classes" />
|
|
<property name="main.resources.dir" location="${main.webinf.dir}/resources" />
|
|
<property name="main.revisioninfo.file" location="${main.resources.dir}/revisionInfo.txt" />
|
|
|
|
<property name="unittests.compiled.dir" location="${main.build.dir}/testClasses" />
|
|
|
|
<property name="solr.template.dir" location="${corebase.dir}/../solr" />
|
|
<property name="solr.template.context.file" location="${solr.template.dir}/template.context.xml" />
|
|
|
|
<property name="solr.build.dir" location="${build.dir}/solr" />
|
|
<property name="solr.webapp.dir" location="${solr.build.dir}/webapp" />
|
|
<property name="solr.homeimage.dir" location="${solr.build.dir}/homeimage" />
|
|
|
|
<property name="distribution.dir" location="${build.dir}/distribution" />
|
|
<property name="distribution.tar.gz.file" location="${build.dir}/distribution.tar.gz" />
|
|
|
|
<property name="option.javac.deprecation" value="true" />
|
|
|
|
<!-- - - - - - - - - - - - - - - - - -
|
|
target: buildProperties
|
|
- - - - - - - - - - - - - - - - - -->
|
|
<target name="buildProperties">
|
|
<fail message="You must create a "${build.properties.file}" file.">
|
|
<condition>
|
|
<not>
|
|
<available file="${build.properties.file}" />
|
|
</not>
|
|
</condition>
|
|
</fail>
|
|
|
|
<property file="${build.properties.file}" />
|
|
|
|
<fail unless="webapp.name" message="${build.properties.file} must contain a value for webapp.name" />
|
|
<property name="solr.app.name" value="${webapp.name}solr" />
|
|
</target>
|
|
|
|
<!-- - - - - - - - - - - - - - - - - -
|
|
target: deployProperties
|
|
- - - - - - - - - - - - - - - - - -->
|
|
<target name="deployProperties" depends="buildProperties">
|
|
<fail unless="vitro.home" message="${build.properties.file} must contain a value for vitro.home" />
|
|
<fail unless="tomcat.home" message="${build.properties.file} must contain a value for tomcat.home" />
|
|
|
|
<property name="solr.home.dir" location="${vitro.home}/solr" />
|
|
|
|
<property name="tomcat.context.filename" value="META-INF/context.xml" />
|
|
<property name="main.tomcat.webapp.dir" value="${tomcat.home}/webapps/${webapp.name}" />
|
|
<property name="main.tomcat.context.file" value="${main.tomcat.webapp.dir}/${tomcat.context.filename}" />
|
|
<property name="solr.tomcat.webapp.dir" value="${tomcat.home}/webapps/${solr.app.name}" />
|
|
<property name="solr.tomcat.context.file" value="${solr.tomcat.webapp.dir}/${tomcat.context.filename}" />
|
|
</target>
|
|
|
|
<!-- - - - - - - - - - - - - - - - - -
|
|
target: compileBuildtools
|
|
- - - - - - - - - - - - - - - - - -->
|
|
<target name="compileBuildtools">
|
|
<path id="utility.compile.classpath">
|
|
<fileset dir="${buildtools.lib.dir}" includes="*.jar" />
|
|
<fileset dir="${appbase.dir}/lib">
|
|
<include name="commons-io-2.0.1.jar" />
|
|
<include name="commons-lang-2.6.jar" />
|
|
<include name="servlet-api.jar" />
|
|
</fileset>
|
|
</path>
|
|
|
|
<mkdir dir="${buildtools.compiled.dir}" />
|
|
<javac srcdir="${buildtools.source.dir}"
|
|
destdir="${buildtools.compiled.dir}"
|
|
debug="true"
|
|
deprecation="${option.javac.deprecation}"
|
|
encoding="UTF8"
|
|
includeantruntime="false"
|
|
optimize="false"
|
|
source="1.6">
|
|
<classpath refid="utility.compile.classpath" />
|
|
</javac>
|
|
|
|
<path id="utility.run.classpath">
|
|
<pathelement location="${buildtools.compiled.dir}" />
|
|
<path refid="utility.compile.classpath" />
|
|
</path>
|
|
</target>
|
|
|
|
<!-- - - - - - - - - - - - - - - - - -
|
|
target: prepare
|
|
- - - - - - - - - - - - - - - - - -->
|
|
<target name="prepare">
|
|
<mkdir dir="${build.dir}" />
|
|
</target>
|
|
|
|
<!-- - - - - - - - - - - - - - - - - -
|
|
target: prepareWebappDir
|
|
- - - - - - - - - - - - - - - - - -->
|
|
<target name="prepareWebappDir" depends="prepare">
|
|
<!-- copy all sorts of web stuff into the webapp directory. -->
|
|
<copy todir="${main.webapp.dir}">
|
|
<fileset dir="${appbase.dir}/web" />
|
|
<fileset dir="${appbase.dir}" includes="themes/**/*" />
|
|
</copy>
|
|
|
|
<copy todir="${main.webinf.dir}">
|
|
<fileset dir="${appbase.dir}">
|
|
<!-- copy the JARs into the war directory -->
|
|
<include name="lib/*" />
|
|
<!-- these will be in the servlet container: we mustn't conflict. -->
|
|
<exclude name="lib/jsp-api.jar" />
|
|
<exclude name="lib/servlet-api.jar" />
|
|
</fileset>
|
|
</copy>
|
|
|
|
<!-- use the production Log4J properties, unless a debug version exists. -->
|
|
<condition property="log4j.properties.file" value="debug.log4j.properties" else="default.log4j.properties">
|
|
<available file="${appbase.dir}/config/debug.log4j.properties" />
|
|
</condition>
|
|
<copy file="${appbase.dir}/config/${log4j.properties.file}"
|
|
tofile="${main.build.dir}/log4j.properties"
|
|
filtering="true"
|
|
overwrite="true">
|
|
<filterchain>
|
|
<expandproperties />
|
|
</filterchain>
|
|
</copy>
|
|
<copy todir="${main.compiled.dir}">
|
|
<fileset dir="${main.build.dir}">
|
|
<filename name="log4j.properties"/>
|
|
<different targetdir="${main.compiled.dir}" ignorefiletimes="true"/>
|
|
</fileset>
|
|
</copy>
|
|
|
|
<!-- Copy the build.properties file to the resources directory. -->
|
|
<copy todir="${main.resources.dir}" file="${build.properties.file}" />
|
|
|
|
<!-- If there is a runtime.properties file in the same directory as build.properties, copy that too. -->
|
|
<dirname file="${build.properties.file}" property="runtime.properties.dir"/>
|
|
<copy todir="${main.resources.dir}" >
|
|
<fileset dir="${runtime.properties.dir}" >
|
|
<filename name="runtime.properties" />
|
|
</fileset>
|
|
</copy>
|
|
|
|
<!-- copy any xml files from source tree to the war directory -->
|
|
<copy todir="${main.compiled.dir}">
|
|
<fileset dir="${appbase.dir}/src" includes="**/*.xml" />
|
|
</copy>
|
|
</target>
|
|
|
|
<!-- =================================
|
|
target: clean
|
|
================================= -->
|
|
<target name="clean" description="--> Delete all artifacts.">
|
|
<delete dir="${build.dir}" />
|
|
</target>
|
|
|
|
<!-- =================================
|
|
target: compile
|
|
================================= -->
|
|
<target name="compile" depends="prepareWebappDir" description="--> Compile Java sources">
|
|
<path id="main.compile.classpath">
|
|
<fileset dir="${appbase.dir}/lib" includes="*.jar" />
|
|
</path>
|
|
|
|
<!-- deletes all files that depend on changed .java files -->
|
|
<depend srcdir="${appbase.dir}/src"
|
|
destdir="${main.compiled.dir}"
|
|
closure="false"
|
|
cache="${main.build.dir}/compileDependencyCache">
|
|
<classpath refid="main.compile.classpath" />
|
|
</depend>
|
|
|
|
<javac srcdir="${appbase.dir}/src"
|
|
destdir="${main.compiled.dir}"
|
|
debug="true"
|
|
deprecation="${option.javac.deprecation}"
|
|
encoding="UTF8"
|
|
includeantruntime="false"
|
|
optimize="true"
|
|
source="1.6">
|
|
<classpath refid="main.compile.classpath" />
|
|
</javac>
|
|
</target>
|
|
|
|
<!-- =================================
|
|
target: test
|
|
================================= -->
|
|
<target name="test" depends="compile, compileBuildtools" unless="skiptests" description="--> Run JUnit tests">
|
|
<path id="test.compile.classpath">
|
|
<pathelement location="${main.compiled.dir}" />
|
|
<path refid="main.compile.classpath" />
|
|
</path>
|
|
|
|
<mkdir dir="${unittests.compiled.dir}" />
|
|
<javac srcdir="${appbase.dir}/test"
|
|
destdir="${unittests.compiled.dir}"
|
|
debug="true"
|
|
deprecation="${option.javac.deprecation}"
|
|
encoding="UTF8"
|
|
includeantruntime="false"
|
|
optimize="false"
|
|
source="1.6">
|
|
<classpath refid="test.compile.classpath" />
|
|
</javac>
|
|
|
|
<path id="test.run.classpath">
|
|
<pathelement location="${appbase.dir}/test" />
|
|
<pathelement location="${unittests.compiled.dir}" />
|
|
<path refid="test.compile.classpath" />
|
|
<path refid="utility.run.classpath" />
|
|
</path>
|
|
|
|
<java classname="edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner" fork="yes" failonerror="true">
|
|
<classpath refid="test.run.classpath" />
|
|
<arg file="${appbase.dir}/test" />
|
|
<arg value="${testlevel}" />
|
|
</java>
|
|
</target>
|
|
|
|
<!-- =================================
|
|
target: revisionInfo
|
|
================================= -->
|
|
<target name="revisionInfo" depends="test" unless="skipinfo" description="--> Store revision info in build">
|
|
<mkdir dir="${main.resources.dir}" />
|
|
<tstamp>
|
|
<format property="revisionInfo.timestamp" pattern="yyyy-MM-dd HH:mm:ss" />
|
|
</tstamp>
|
|
<echo file="${main.revisioninfo.file}">${revisionInfo.timestamp}
|
|
</echo>
|
|
|
|
<addRevisionInfoLine productName="vitroCore" productCheckoutDir="${corebase.dir}/.." />
|
|
</target>
|
|
|
|
<!-- - - - - - - - - - - - - - - - - -
|
|
target: deployWebapp
|
|
- - - - - - - - - - - - - - - - - -->
|
|
<target name="deployWebapp" depends="deployProperties, revisionInfo">
|
|
<mkdir dir="${main.tomcat.webapp.dir}" />
|
|
|
|
<sync todir="${main.tomcat.webapp.dir}" includeemptydirs="true">
|
|
<fileset dir="${main.webapp.dir}" />
|
|
<preserveintarget>
|
|
<include name="${tomcat.context.filename}"/>
|
|
</preserveintarget>
|
|
</sync>
|
|
|
|
<!-- Create the context XML with expanded properties. Store it in a temp file for now. -->
|
|
<copy tofile="${main.build.dir}/context.xml" filtering="true" overwrite="true">
|
|
<fileset file="${appbase.dir}/context.xml" />
|
|
<filterchain>
|
|
<expandproperties />
|
|
</filterchain>
|
|
</copy>
|
|
|
|
<!-- Copy the new context XML only if it differs from the existing one. -->
|
|
<copy todir="${main.tomcat.webapp.dir}/META-INF">
|
|
<fileset dir="${main.build.dir}">
|
|
<filename name="context.xml"/>
|
|
<different targetdir="${main.tomcat.webapp.dir}/META-INF" ignorefiletimes="true"/>
|
|
</fileset>
|
|
</copy>
|
|
</target>
|
|
|
|
<!-- - - - - - - - - - - - - - - - - -
|
|
target: prepareSolr
|
|
- - - - - - - - - - - - - - - - - -->
|
|
<target name="prepareSolr" depends="prepare, buildProperties">
|
|
<!-- create an image of the Solr home directory -->
|
|
<copy todir="${solr.homeimage.dir}">
|
|
<fileset dir="${solr.template.dir}/homeDirectoryTemplate" />
|
|
</copy>
|
|
|
|
<!-- create an unpacked image of the Solr WAR, with our config options -->
|
|
<unwar src="${solr.template.dir}/apache-solr-3.6.2.war" dest="${solr.webapp.dir}" />
|
|
<copy todir="${solr.webapp.dir}/WEB-INF/classes">
|
|
<fileset dir="${appbase.dir}/config/solr/" />
|
|
</copy>
|
|
</target>
|
|
|
|
<!-- - - - - - - - - - - - - - - - - -
|
|
target: deploySolr
|
|
- - - - - - - - - - - - - - - - - -->
|
|
<target name="deploySolr" depends="deployProperties, prepareSolr">
|
|
<!-- Deploy to the Solr home directory. -->
|
|
<mkdir dir="${solr.home.dir}" />
|
|
<sync todir="${solr.home.dir}" includeemptydirs="true">
|
|
<fileset dir="${solr.homeimage.dir}" />
|
|
<preserveintarget>
|
|
<include name="data/**/*"/>
|
|
</preserveintarget>
|
|
</sync>
|
|
|
|
<!-- Deploy to Tomcat. -->
|
|
<mkdir dir="${solr.tomcat.webapp.dir}" />
|
|
<sync todir="${solr.tomcat.webapp.dir}" includeemptydirs="true">
|
|
<fileset dir="${solr.webapp.dir}" />
|
|
<preserveintarget>
|
|
<include name="${tomcat.context.filename}"/>
|
|
</preserveintarget>
|
|
</sync>
|
|
|
|
<!-- Create the context XML with expanded properties. Store it in a temp file for now. -->
|
|
<copy tofile="${solr.build.dir}/context.xml" filtering="true" overwrite="true">
|
|
<fileset file="${solr.template.context.file}" />
|
|
<filterchain>
|
|
<expandproperties />
|
|
</filterchain>
|
|
</copy>
|
|
|
|
<!-- Copy the new context XML only if it differs from the existing one. -->
|
|
<copy todir="${solr.tomcat.webapp.dir}/META-INF">
|
|
<fileset dir="${solr.build.dir}">
|
|
<filename name="context.xml"/>
|
|
<different targetdir="${solr.tomcat.webapp.dir}/META-INF" ignorefiletimes="true"/>
|
|
</fileset>
|
|
</copy>
|
|
</target>
|
|
|
|
<!-- =================================
|
|
target: deploy
|
|
================================= -->
|
|
<target name="deploy"
|
|
depends="deployWebapp, deploySolr"
|
|
description="--> Build the app and install in Tomcat">
|
|
</target>
|
|
|
|
<!-- =================================
|
|
target: all
|
|
================================= -->
|
|
<target name="all" depends="clean, deploy" description="--> Run 'clean', then 'deploy'" />
|
|
|
|
|
|
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
OUTSIDE THE MAIN BUILD SEQUENCE
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
|
|
<!-- =================================
|
|
target: distribute
|
|
================================= -->
|
|
<target name="distribute"
|
|
depends="revisionInfo, prepareSolr"
|
|
description="--> Build the app and create a distribution bundle">
|
|
<mkdir dir="${distribution.dir}" />
|
|
|
|
<jar basedir="${main.webapp.dir}" destfile="${distribution.dir}/${webapp.name}.war" />
|
|
<jar basedir="${solr.webapp.dir}" destfile="${distribution.dir}/${solr.app.name}.war" />
|
|
<tar basedir="${solr.homeimage.dir}" destfile="${distribution.dir}/solrhome.tar" />
|
|
|
|
<tar basedir="${distribution.dir}" destfile="${distribution.tar.gz.file}" compression="gzip" />
|
|
</target>
|
|
|
|
<!-- =================================
|
|
target: describe
|
|
================================= -->
|
|
<target name="describe"
|
|
description="--> Describe the targets (this is the default).">
|
|
<echo>
|
|
all - Runs "clean", then "deploy".
|
|
clean - Delete all artifacts so the next build will be from scratch.
|
|
compile - Compile the Java source files.
|
|
orng - Configure and deploy the ORNG Shindig application.
|
|
test - Compile and run the JUnit tests.
|
|
distribute - Create WAR files to be deployed in a servlet container.
|
|
deploy - Deploy the application directly into the Tomcat webapps directory.
|
|
</echo>
|
|
</target>
|
|
|
|
<!-- =================================
|
|
target: jar
|
|
================================= -->
|
|
<target name="jar" depends="test" description="--> Compile the Java, and build a JAR file">
|
|
<jar basedir="${main.compiled.dir}" destfile="${build.dir}/${ant.project.name}.jar" />
|
|
</target>
|
|
|
|
<!-- =================================
|
|
target: licenser
|
|
|
|
In regular use, checks that all appropriate source files have license tags.
|
|
At release time, applies license text to source files.
|
|
================================= -->
|
|
<target name="licenser" description="--> Check source files for licensing tags">
|
|
<property name="licenser.properties.file" location="${corebase.dir}/config/licenser/licenser.properties" />
|
|
<runLicenserScript productname="Vitro core" propertiesfile="${licenser.properties.file}" />
|
|
</target>
|
|
|
|
<!-- =================================
|
|
target: jarlist
|
|
================================= -->
|
|
<target name="jarlist" depends="compileBuildtools, jar" description="Figure out what JARs are not needed">
|
|
<java classname="edu.cornell.mannlib.vitro.utilities.jarlist.JarLister" fork="no" failonerror="true">
|
|
<classpath refid="utility.run.classpath" />
|
|
<arg value="${build.dir}/${ant.project.name}.jar" />
|
|
<arg value="${appbase.dir}/lib" />
|
|
<arg value="${appbase.dir}/config/jarlist/known_dependencies.txt" />
|
|
</java>
|
|
</target>
|
|
|
|
<!-- =================================
|
|
target: orng
|
|
================================= -->
|
|
<target name="orng" description="Configure and deploy the ORNG Shindig application">
|
|
<ant dir="${corebase.dir}/../opensocial" antfile="build_orng.xml" target="all" />
|
|
</target>
|
|
|
|
<!-- =================================
|
|
target: checkContainerNeutrality
|
|
================================= -->
|
|
<target name="checkContainerNeutrality" depends="compile, compileBuildtools" description="Look for things that Tomcat tolerates but shouldn't">
|
|
<junit haltonfailure="true">
|
|
<test name="edu.cornell.mannlib.vitro.utilities.containerneutral.CheckContainerNeutrality" />
|
|
<sysproperty key="CheckContainerNeutrality.webapp.dir" value="${main.webapp.dir}"/>
|
|
<classpath>
|
|
<path refid="utility.run.classpath" />
|
|
<path refid="main.compile.classpath" />
|
|
<pathelement location="${main.compiled.dir}" />
|
|
</classpath>
|
|
<formatter type="plain" usefile="false"/>
|
|
</junit>
|
|
</target>
|
|
|
|
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
MACROS
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
|
|
<!--
|
|
Run the licenser script.
|
|
-->
|
|
<macrodef name="runLicenserScript">
|
|
<attribute name="productName" />
|
|
<attribute name="propertiesFile" />
|
|
<sequential>
|
|
<echo message="Checking license tags on @{productName}" />
|
|
|
|
<exec executable="ruby" dir="${corebase.dir}/../utilities/licenser" failonerror="true">
|
|
<arg value="licenser.rb" />
|
|
<arg value="@{propertiesFile}" />
|
|
<redirector outputproperty="licenser.test.output" alwayslog="true" />
|
|
</exec>
|
|
</sequential>
|
|
</macrodef>
|
|
|
|
<!--
|
|
Add a line to the revisionInfo file.
|
|
-->
|
|
<macrodef name="addRevisionInfoLine">
|
|
<attribute name="productName" />
|
|
<attribute name="productCheckoutDir" />
|
|
<sequential>
|
|
<java classname="edu.cornell.mannlib.vitro.utilities.revisioninfo.RevisionInfoBuilder"
|
|
fork="no"
|
|
failonerror="true">
|
|
<classpath refid="utility.run.classpath" />
|
|
<arg value="@{productName}" />
|
|
<arg file="@{productCheckoutDir}" />
|
|
<arg file="${main.revisioninfo.file}" />
|
|
</java>
|
|
</sequential>
|
|
</macrodef>
|
|
|
|
</project>
|