vitro/webapp/build.xml

334 lines
12 KiB
XML
Raw Normal View History

<?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">
<!-- - - - - - - - - - - - - - - - - -
properties
- - - - - - - - - - - - - - - - - -->
<property name="build.dir" location=".build" />
<property name="webapp.dir" location="." />
<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" />
<!-- - - - - - - - - - - - - - - - - -
paths: for compiling and running
- - - - - - - - - - - - - - - - - -->
<path id="compile.classpath">
<fileset dir="${war-lib.dir}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${servletjars.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="test.compile.classpath">
<pathelement location="${war-classes.dir}" />
<path refid="compile.classpath" />
</path>
<path id="test.run.classpath">
<!-- This holds data files and a special log4j.properties -->
<pathelement location="${webapp.dir}/test" />
<pathelement location="${test-classes.dir}" />
<path refid="test.compile.classpath" />
</path>
<!-- =================================
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.
test - Compile and run the JUnit tests.
deploy - Deploy the application directly into the Tomcat webapps directory.
</echo>
</target>
<!-- =================================
target: all
================================= -->
<target name="all" depends="clean, deploy" description="--> Run 'clean', then 'deploy'" />
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> Delete all artifacts.">
<delete dir="${build.dir}" />
</target>
<!-- - - - - - - - - - - - - - - - - -
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 &quot;${deploy.properties.file}&quot; file.">
<condition>
<not>
<available file="${deploy.properties.file}" />
</not>
</condition>
</fail>
<property file="${deploy.properties.file}" />
<fail unless="tomcat.home"
message="${deploy.properties.file} must contain a value for tomcat.home" />
<fail unless="webapp.name"
message="${deploy.properties.file} must contain a value for webapp.name" />
<fail unless="upload.directory"
message="${deploy.properties.file} must contain a value for upload.directory" />
<fail unless="LuceneSetup.indexDir"
message="${deploy.properties.file} must contain a value for LuceneSetup.indexDir" />
<fail unless="Vitro.defaultNamespace"
message="${deploy.properties.file} must contain a value for Vitro.defaultNamespace" />
<fail unless="Vitro.smtpHost"
message="${deploy.properties.file} must contain a value for Vitro.smtpHost (may be empty)" />
<fail unless="VitroConnection.DataSource.url"
message="${deploy.properties.file} must contain a value for VitroConnection.DataSource.url" />
<fail unless="VitroConnection.DataSource.username"
message="${deploy.properties.file} must contain a value for VitroConnection.DataSource.username" />
<fail unless="VitroConnection.DataSource.password"
message="${deploy.properties.file} must contain a value for VitroConnection.DataSource.password" />
<fail unless="initialAdminUser"
message="${deploy.properties.file} must contain a value for initialAdminUser" />
</target>
<!-- - - - - - - - - - - - - - - - - -
target: prepare
- - - - - - - - - - - - - - - - - -->
<target name="prepare" depends="properties">
<mkdir dir="${build.dir}" />
<mkdir dir="${war-classes.dir}" />
<mkdir dir="${war-resources.dir}" />
<mkdir dir="${test-classes.dir}" />
<!-- copy the themes into the war directory. -->
<copy todir="${war.dir}">
<fileset dir="${webapp.dir}/web">
<!--
If a product doesn't want the core themes, it can
set this property and they will be skipped.
-->
<exclude name="themes/**/*" if="skip.core.themes" />
</fileset>
</copy>
<!-- copy the config files into the war directory. -->
<copy todir="${war-webinf.dir}">
<fileset file="${webapp.dir}/config/web.xml" />
<fileset file="${webapp.dir}/config/dwr.xml" />
</copy>
<!-- copy the ontologies and the submodels into the war directory. -->
<copy todir="${war-webinf.dir}">
<fileset dir="${webapp.dir}" includes="ontologies" />
<fileset dir="${webapp.dir}" includes="ontologies/**/*" />
<fileset dir="${webapp.dir}" includes="submodels" />
<fileset dir="${webapp.dir}" includes="submodels/**/*" />
</copy>
<!-- use the production Log4J properties, unless a debug version exists. -->
<available file="${webapp.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">
<include name="default.log4j.properties" unless="debug.log4j.exists" />
<include name="debug.log4j.properties" if="debug.log4j.exists" />
</fileset>
<filterchain>
<expandproperties />
</filterchain>
</copy>
<!-- copy the deploy.properties into the war directory -->
<copy todir="${war-classes.dir}">
<fileset file="${deploy.properties.file}" />
</copy>
<!-- copy the custom tag libraries into the war directory -->
<copy todir="${war-webinf.dir}/tlds">
<fileset dir="${webapp.dir}/config/tlds" includes="**/*" excludes="*.LCK" />
</copy>
<!-- TODO Get rid of these webservices files -->
<copy todir="${war-webinf.dir}/lib">
<fileset dir="${webapp.dir}/../services/lib" includes="**/*" excludes="*.LCK" />
</copy>
<copy todir="${build.dir}/war">
<fileset dir="${webapp.dir}/../services/additions" includes="**/*" />
</copy>
<!-- TODO Get rid of these webservices files -->
<!-- copy any xml files from source tree to the war directory -->
<copy todir="${build.dir}/war/WEB-INF/classes">
<fileset dir="${webapp.dir}/src" includes="**/*.xml" />
</copy>
<!-- copy the JARs into the war directory -->
<copy todir="${war-lib.dir}">
<fileset dir="${webapp.dir}/lib">
<!-- these are already in Tomcat: we mustn't conflict. -->
<exclude name="jsp-api.jar" />
<exclude name="servlet-api.jar" />
</fileset>
</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>
</copy>
<!-- copy the context file into the war directory -->
<copy file="${webapp.dir}/context.xml" tofile="${war.dir}/META-INF/context.xml" />
</target>
<!-- =================================
target: compile
================================= -->
<target name="compile" depends="prepare" description="--> Compile Java sources">
<!-- deletes all files that depend on changed .java files -->
<depend srcdir="${webapp.dir}/src"
destdir="${war-classes.dir}"
closure="false"
cache="${build.dir}/.depcache">
<classpath refid="compile.classpath" />
</depend>
<javac srcdir="${webapp.dir}/src"
destdir="${war-classes.dir}"
debug="true"
deprecation="true"
encoding="UTF8"
optimize="true"
source="1.6">
<classpath refid="compile.classpath" />
</javac>
</target>
<!-- =================================
target: test
================================= -->
<target name="test" depends="compile" unless="skiptests" description="--> Run JUnit tests">
<javac srcdir="${webapp.dir}/test"
destdir="${test-classes.dir}"
debug="true"
deprecation="true"
encoding="UTF8"
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="${webapp.dir}/test" />
<arg value="${testlevel}" />
</java>
</target>
<!-- =================================
target: revisionInfo
================================= -->
<target name="revisionInfo" depends="test" unless="skipinfo" description="--> Store revision info in build">
<property name="revisionInfo.product.dir" location="${ant.file.vitroCore}/.." />
<property name="revisionInfo.build.file" location="${war-resources.dir}/revisionInfo.txt" />
<delete file="${revisionInfo.build.file}" />
<tstamp>
<format property="revisionInfo.timestamp" pattern="yyyy-MM-dd HH:mm:ss" />
</tstamp>
<echo file="${revisionInfo.build.file}">${revisionInfo.timestamp}
</echo>
<javac srcdir="${webapp.dir}/../utilities/buildutils/revisioninfo"
destdir="${test-classes.dir}"
debug="true"
deprecation="true"
encoding="UTF8"
optimize="false"
source="1.6">
</javac>
<java classname="edu.cornell.mannlib.vitro.utilities.revisioninfo.RevisionInfoBuilder"
fork="no"
failonerror="true"
logerror="true"
outputproperty="revisionInfo.outputLine">
<classpath refid="test.run.classpath" />
<arg value="${ant.project.name}" />
<arg file="${revisionInfo.product.dir}" />
</java>
<echo file="${revisionInfo.build.file}" append="true">${revisionInfo.outputLine}
</echo>
</target>
<!-- =================================
target: deploy
================================= -->
<target name="deploy"
depends="revisionInfo"
description="--> Build the app and install in Tomcat">
<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: 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="${webapp.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">
<arg value="licenser.rb" />
<arg value="${licenser.properties.file}" />
<redirector outputproperty="licenser.test.output" alwayslog="true" />
</exec>
</target>
</project>