vitro/webapp/build.xml

324 lines
14 KiB
XML

<?xml version="1.0"?>
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<!-- <!DOCTYPE project PUBLIC "-//ANT//DTD project//EN" "ant16.dtd" > this doesn't seem to work well. -->
<project name="vivoWebApp" default="test" basedir="../">
<!-- Load user property definition overrides -->
<property file="./config/globalbuild.properties"/>
<!-- defined in globalbuild.properties -->
<!-- <property name="webapp.dir" value="./webapp"/> -->
<!-- <property name="webapp.build" value="${webapp.dir}/.build"/> -->
<!-- Property Definitions -->
<property name="app.name" value="vitro-webapp"/>
<property name="app.version" value="3.0"/>
<!-- default lucene index dir:: -->
<property name="luceneIndexDir" value="/usr/local/lucene/vitroAntdefault"/>
<!-- defined in globalbuild.properties -->
<property name="source.dir" value="${source.home}"/>
<!-- The clones/build.xml file modifies this default upload directory, now used for images -->
<property name="uploadDir" value="${source.dir}/webapp/web" />
<property name="compile.debug" value="true"/>
<property name="compile.deprecation" value="true" />
<property name="compile.optimize" value="true" />
<property name="dist.home" value="${webapp.dir}/dist"/>
<!-- directory for local modifications -->
<property name="modDir" value="modifications"/>
<property name="axis.port" value="8080"/>
<property name="axis.server" value="localhost"/>
<!-- ==================== Compilation Classpath =========================== -->
<path id="webapp-compile.classpath">
<!-- Include all JAR files that will be included in /WEB-INF/lib -->
<fileset dir="webapp/lib">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- ==================== Runtime Classpath =========================== -->
<path id="webapp-run.classpath">
<!-- some other jars we need -->
<!-- build dir -->
<pathelement path="${webapp.build}"/>
</path>
<!-- =================== Axis Classpath ============================== -->
<!-- need to include the classes directory so that axis can
find the necessary compiled classes -->
<path id="axis.classpath">
<pathelement path="${webapp.build}/WEB-INF/classes"/>
<fileset dir="webapp/lib">
<include name="**/*.jar" />
</fileset>
</path>
<!-- ================== set up the ant axis tasks ================ -->
<taskdef resource="axis-tasks.properties" classpathref="axis.classpath" />
<!-- ==================== All Target ====================================== -->
<!-- The "all" target is a shortcut for running the "clean" target followed
by the "compile" target, to force a complete recompile. -->
<target name="all" depends="clean,compile" description="Clean build and dist, then compile"/>
<!-- ==================== Clean Target ==================================== -->
<!-- The "clean" target deletes any previous "build" and "dist" directory,
so that you can be ensured the application can be built from scratch.
do not delete the ${deploy.home}/images directory !!! that's where images
are uploaded to-->
<target name="clean" description="Delete old build and dist directories">
<delete failonerror="false" dir="${webapp.build}"/>
</target>
<!-- ==================== Compile Target ================================== -->
<!--
The "compile" target transforms source files (from your "src" directory)
into object files in the appropriate location in the build directory.
This example assumes that you will be including your classes in an
unpacked directory hierarchy under "/WEB-INF/classes".
-->
<target name="compile" depends="prepare" description="Compile Java sources">
<!-- deletes all files that depend on changes .java files -->
<depend srcdir="${webapp.dir}/src"
destdir="${webapp.build}/WEB-INF/classes"
closure="false"
cache=".depcache">
<classpath refid="webapp-compile.classpath"/>
</depend>
<echo>Compile webapp</echo>
<javac srcdir="${webapp.dir}/src"
destdir="${webapp.build}/WEB-INF/classes"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
source="1.5">
<classpath refid="webapp-compile.classpath"/>
<!-- <compilerarg value="-Xlint:unchecked"/> -->
</javac>
<echo>Compile unit tests</echo>
<javac srcdir="${webapp.dir}/test"
destdir="${webapp.build}/WEB-INF/classes"
debug="yes"
source="1.5">
<classpath refid="webapp-compile.classpath"/>
</javac>
</target>
<!-- ==================== Test Target ================================== -->
<!--
The "test" target runs JUnit tests against the compiled classes.
-->
<target name="test" depends="prepare,compile" description="Run JUnit tests" unless="skiptests">
<java classname="edu.cornell.mannlib.vitro.testing.VitroTestRunner" fork="yes" failonerror="true">
<classpath>
<!-- The classes and their supporting JARs -->
<pathelement location="${webapp.build}/WEB-INF/classes" />
<path refid="webapp-compile.classpath" />
<!-- Test data files are stored with the test source -->
<pathelement location="${webapp.dir}/test" />
</classpath>
<arg file="${webapp.dir}/test" />
<arg value="${testlevel}" />
</java>
</target>
<!-- ============================== Copy Etc ============================== -->
<!-- There are configuration files under dream/etc that need to go in different -->
<!-- places in the build. This target copies them to the correct places. -->
<target name="copyEtc"
description="copies the files from the dream/etc dir to correct places in build">
<echo> ${tomcat.home}</echo>
<copy todir="${webapp.build}/WEB-INF">
<fileset file="${webapp.dir}/config/web.xml"/>
<fileset file="${webapp.dir}/config/dwr.xml"/>
</copy>
<!-- copy the default log4j config and then copy the override if it exists -->
<copy file="${webapp.dir}/config/default.log4j.properties"
tofile="${webapp.build}/WEB-INF/classes/log4j.properties"
filtering="true">
<filterchain><expandproperties/></filterchain>
</copy>
<copy file="${webapp.dir}/config/debugging.log4j.properties"
tofile="${webapp.build}/WEB-INF/classes/log4j.properties"
filtering="true"
failonerror="false">
<filterchain><expandproperties/></filterchain>
</copy>
<!-- copy properties files -->
<copy todir="${webapp.build}/WEB-INF/classes">
<fileset dir="${webapp.dir}/config" includes="deploy.properties" />
</copy>
<copy todir="${webapp.build}/WEB-INF/tlds">
<fileset dir="${webapp.dir}/config/tlds" includes="**/*" excludes="*.LCK"/></copy>
<!-- copy the webservices files -->
<copy todir="${webapp.build}/WEB-INF/lib">
<fileset dir="${ws.lib}"
includes="**/*"
excludes="*.LCK"/>
</copy>
<copy todir="${webapp.build}">
<fileset dir="${ws.dir}/additions"
includes="**/*"
excludes=".svn"/>
</copy>
<!-- copy the ontology files -->
<copy todir="${webapp.build}/WEB-INF/ontologies">
<fileset dir="${webapp.dir}/ontologies"/>
</copy>
<!-- copy the model files -->
<copy todir="${webapp.build}/WEB-INF/submodels" failonerror="false">
<fileset dir="${webapp.dir}/model/submodels"/>
</copy>
<!-- copy the init-data files -->
<copy todir="${webapp.build}/WEB-INF/init-data" failonerror="false">
<fileset dir="${webapp.dir}/model/init-data"/>
</copy>
<!-- xml files from src tree -->
<copy todir="${webapp.build}/WEB-INF/classes">
<fileset dir="${webapp.dir}/src" includes="**/*.xml" excludes="*.svn"/>
</copy>
<copy todir="${webapp.build}/WEB-INF/lib">
<fileset dir="${webapp.lib}">
<!-- these are already in Tomcat: we shouldn't conflict. -->
<exclude name="jsp-api.jar"/>
<exclude name="servlet-api.jar"/>
</fileset>
</copy>
<copy file="${webapp.dir}/context.xml"
tofile="${webapp.build}/META-INF/context.xml" />
</target>
<!-- ==================== Local Modifications ============================ -->
<!-- The localMods target will copy local modifications into the build directory
so that a user can who is not using the clone system can have a way to
apply simple chages to the deployed web application. In many cases
there will be no modifications directory so this will do nothing. -->
<target name="localMods" depends="compile,test,copyEtc"
description="Adds local modifications to build">
<copy todir="${webapp.build}" overwrite="true" preservelastmodified="true" failonerror="false">
<fileset dir="${modDir}" />
</copy>
</target>
<!-- ==================== Deploy Target =================================== -->
<!--
The "deploy" target copies the contents of the build directory into a
location required by our servlet container, and picks up any external
dependencies along the way. After restarting the servlet container, you
can now test your web application. -->
<target name="deploy" depends="compile,test,copyEtc, localMods"
description="Deploy application to servlet container">
<!-- Copy the contents of the build directory -->
<mkdir dir="${webapp.deploy.home}"/>
<copy todir="${webapp.deploy.home}">
<fileset dir="${webapp.build}"/>
</copy>
</target>
<!-- ==================== Jar Target ==================== -->
<target name="jar" depends="compile,test" description="Makes a jar file">
<jar jarfile="${webapp.dir.jar}" basedir="${webapp.build}/WEB-INF/classes"/>
</target>
<!-- ==================== Javadoc Target ================================== -->
<!--
The "javadoc" target creates Javadoc API documentation for the Java
classes included in your application. Normally, this is only required
when preparing a distribution release, but is available as a separate
target in case the developer wants to create Javadocs independently.
-->
<target name="javadoc" depends="compile" description="Create Javadoc API documentation">
<mkdir dir="${dist.home}/docs"/>
<javadoc sourcepath="src" classpathref="compile.classpath" destdir="${dist.home}/docs"
packagenames="*"/>
</target>
<!-- ==================== Prepare Target ================================== -->
<!--
The "prepare" target is used to create the "build" destination directory,
and copy the static contents of your web application to it.
Normally, this task is executed indirectly when needed. -->
<target name="prepare">
<!-- Create build directory and copy static content -->
<mkdir dir="${webapp.build}"/>
<mkdir dir="${webapp.build}/WEB-INF/classes"/>
<mkdir dir="${webapp.build}/WEB-INF/classes/properties"/>
<mkdir dir="${webapp.build}/WEB-INF/tlds"/>
<!--mkdir dir="${webapp.build}/jsp"/-->
<copy todir="${webapp.build}">
<fileset dir="${webapp.dir}/web"/>
</copy>
</target>
<!-- ==================== setupWs task ==================== -->
<target name="setupWs"
description="invoke axis admin to deploy and expose VitroWs">
<!-- Notice that this can be run from the command line too:
$ java org.apache.axis.client.AdminClient \
-lhttp://localhost:8080/vivo/services/AdminService deploy.wsdd -->
<axis-admin
port="${axis.port}"
hostname="${axis.server}"
failonerror="true"
servletpath="${webapp.name}/services/AdminService"
debug="true"
xmlfile="${webapp.dir}/config/VitroWs3.wsdd" />
</target>
<!-- ==================== axis prepare Target ======================== -->
<!--
The "axis" target is used to fill the "build" directory with files needed
for axis web services.
Normally, this task is executed indirectly when needed. -->
<target name="axisPrepare">
<copy todir="${webapp.build}/WEB-INF/classes">
<fileset dir="${webapp.dir}/config/axisproperties"
includes="**/*"
excludes=".svn"/>
</copy>
<copy file="${webapp.dir}/config/VitroWs3.wsdd"
todir="${webapp.build}/WEB-INF" />
</target>
<!-- =================== Create modifications directory ============== -->
<target name="prepareModDir"
description="create a directory structure to hold
local modifications"
depends="compile,test,copyEtc">
<mkdir dir="${modDir}"/>
<copy todir="${modDir}" >
<fileset dir="${webapp.build}">
<type type="dir"/>
<exclude name="WEB-INF/classes/"/>
<exclude name="jenaIngest"/>
<exclude name="src"/>
</fileset>
</copy>
</target>
</project>