Changed build process to avoid use of symlinks, which have caused so many

problems for people installing DSpace with Tomcat.  Instead, two .war files
are created which can simply be dropped in the appropriate place for Tomcat
or other servlet container.  A simple LoadDSpaceConfig servlet then loads in
the dspace.cfg (from a config parameter in the web.xml contained within each
.war) and initialises log4j with the appropriate properties file.

A few other cleanups:

- Removed redundant ${basedir} references
- update and fresh_install targets now give useful hints as to what to do next
- fresh_install target builds search + browse indices and config files for
  3rd party tools (i.e. bin/index-all and bin/install-configs)


git-svn-id: http://scm.dspace.org/svn/repo/trunk@726 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Robert Tansley
2004-02-04 19:21:53 +00:00
parent 8226aa9ab3
commit ec9e23e1f5
5 changed files with 281 additions and 126 deletions

View File

@@ -41,27 +41,24 @@
- Date: $Date$
-->
<project name="DSpace" default="compile" basedir=".">
<project name="DSpace" default="compile">
<!-- ============================================================= -->
<!-- Description -->
<!-- ============================================================= -->
<description>
===================== DSpace platform build file =====================
====================== DSpace platform build file ======================
Common usage:
Fresh install, including database setup and registry loading:
% ant ; ant fresh_install
% ant fresh_install
Upgrade existing installation, leaving code, data and configuration
% ant ; ant -Dconfig=/installdir/config/dspace.cfg update
Update existing installation, leaving data and configuration intact:
% ant -Dconfig=/installdir/config/dspace.cfg update
The following target require that the system is installed:
load_registries
======================================================================
========================================================================
</description>
<!-- ============================================================= -->
@@ -76,7 +73,7 @@ Common usage:
<!-- ============================================================= -->
<!-- Default configuration to use. This may be overridden. -->
<property name="config" value="${basedir}/config/dspace.cfg" />
<property name="config" value="config/dspace.cfg" />
<!-- Give user a chance to override without editing this file
(and without typing -D each time s/he compiles it) -->
@@ -93,35 +90,92 @@ Common usage:
<!-- We will include the environment CLASSPATH -->
<path id="build.class.path">
<pathelement path="${env.CLASSPATH}"/>
<pathelement path="${basedir}/build/classes"/>
<fileset dir="${basedir}/lib">
<pathelement path="build/classes"/>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- ============================================================= -->
<!-- Compile the source code -->
<!-- Compile the source code and build WARs -->
<!-- ============================================================= -->
<target name="compile"
description="Compile the source code">
<mkdir dir="${basedir}/build/classes"/>
<javac srcdir="${basedir}/src"
destdir="${basedir}/build/classes"
description="Compile the source code and build .war files">
<mkdir dir="build/classes"/>
<javac srcdir="src"
destdir="build/classes"
debug="on">
<include name="**/*.java"/>
<classpath refid="build.class.path"/>
</javac>
<!-- Build DSpace UI .war -->
<copy file="etc/dspace-web.xml"
tofile="build/dspace-web.xml"
preservelastmodified="true"/>
<replace file="build/dspace-web.xml"
token="@@dspace.dir@@"
value="${dspace.dir}" />
<war destfile="build/dspace.war"
webxml="build/dspace-web.xml">
<fileset dir="jsp" />
<lib dir="lib">
<exclude name="servlet.jar" />
</lib>
<classes dir="build/classes" />
</war>
<!-- Build DSpace OAI-PMH .war -->
<copy file="etc/oai-web.xml"
tofile="build/oai-web.xml"
preservelastmodified="true"/>
<replace file="build/oai-web.xml"
token="@@dspace.dir@@"
value="${dspace.dir}" />
<war destfile="build/dspace-oai.war"
webxml="build/oai-web.xml">
<lib dir="lib">
<exclude name="servlet.jar" />
</lib>
<classes dir="build/classes" />
</war>
</target>
<!-- ============================================================= -->
<!-- Update the code, without clobbering existing data -->
<!-- Update an installation (except database) -->
<!-- ============================================================= -->
<target name="update"
description="Update installed code (install without clobbering data)">
depends="install_code"
description="Update installed code (without clobbering data/config)">
<echo>
====================================================================
Updated Web application (.war) files are in the 'build' directory.
* Stop your Web servlet container (Tomcat, Jetty, Resin etc.)
* If you're using Tomcat, you need delete the directories
corresponding to the old .war files. For example, if dspace.war
is installed in CATALINA_HOME/webapps/dspace.war, you should
delete the CATALINA_HOME/webapps/dspace directory. Otherwise,
Tomcat will continue to use the old code in that directory.
* Copy the new dspace.war and dspace-oai.war from the 'build'
directory over the old ones
* Start up your Web servlet container again.
====================================================================
</echo>
</target>
<!-- ============================================================= -->
<!-- Install or update DSpace code (except database) -->
<!-- ============================================================= -->
<target name="install_code"
depends="compile">
<mkdir dir="${dspace.dir}/config" />
<mkdir dir="${assetstore.dir}" />
<mkdir dir="${handle.dir}" />
@@ -131,42 +185,6 @@ Common usage:
<mkdir dir="${upload.temp.dir}" />
<mkdir dir="${dspace.dir}/bin"/>
<mkdir dir="${dspace.dir}/lib"/>
<mkdir dir="${dspace.dir}/jsp/local"/>
<mkdir dir="${dspace.dir}/jsp/WEB-INF"/>
<mkdir dir="${dspace.dir}/oai/WEB-INF"/>
<!-- Delete symlinks, otherwise ln -s commands below would create
extra symlinks, e.g. "WEB-INF/lib/lib". Plus, we need to use
shell "rm" command, since ANT's delete task doesn't
understand symlinks. -->
<exec executable="rm">
<arg value="-f" />
<arg value="${dspace.dir}/jsp/WEB-INF/classes" />
<arg value="${dspace.dir}/jsp/WEB-INF/lib" />
<arg value="${dspace.dir}/oai/WEB-INF/classes" />
<arg value="${dspace.dir}/oai/WEB-INF/lib" />
</exec>
<!-- Symlink the Web UI and OAI webapps "classes" and "lib" directory
- to dspace.dir/config and dspace.dir/lib respectively -->
<exec executable="ln">
<arg value="-s" />
<arg value="${dspace.dir}/config" />
<arg value="${dspace.dir}/jsp/WEB-INF/classes" />
</exec>
<exec executable="ln">
<arg value="-s" />
<arg value="${dspace.dir}/lib" />
<arg value="${dspace.dir}/jsp/WEB-INF/lib" />
</exec>
<exec executable="ln">
<arg value="-s" />
<arg value="${dspace.dir}/config" />
<arg value="${dspace.dir}/oai/WEB-INF/classes" />
</exec>
<exec executable="ln">
<arg value="-s" />
<arg value="${dspace.dir}/lib" />
<arg value="${dspace.dir}/oai/WEB-INF/lib" />
</exec>
<copy todir="${dspace.dir}/bin" preservelastmodified="true">
<fileset dir="bin"/>
</copy>
@@ -176,31 +194,26 @@ Common usage:
<arg value="${dspace.dir}/bin" />
</exec>
<copy todir="${dspace.dir}/lib" preservelastmodified="true">
<fileset dir="lib" excludesfile="lib/servlet.jar" />
</copy>
<copy todir="${dspace.dir}/jsp" preservelastmodified="true">
<fileset dir="jsp"/>
<fileset dir="lib" />
</copy>
<jar jarfile="${dspace.dir}/lib/dspace.jar"
basedir="${basedir}/build/classes" />
basedir="build/classes" />
</target>
<!-- ============================================================= -->
<!-- Do a fresh install of the code and configuration files -->
<!-- Fresh install of config files -->
<!-- ============================================================= -->
<!-- Installs code, then config, and symlinks WEB-INF/classes to config.
The "log4j.build.properties" file is copied to ${dspace.dir}/config
so there's a simple log4j.properties file present for the initial
run of "install-configs". -->
<target name="install_code"
depends="update"
description="Do a fresh install of the system, not touching database">
<!-- Writes the configuration files to ${dspace.dir}/config. It does *not*
run the install-configs script. The "log4j.build.properties" file is
copied to ${dspace.dir}/config so there's a simple log4j.properties
file present for the initial run of "install-configs". -->
<target name="init_configs">
<copy todir="${dspace.dir}/config" preservelastmodified="true">
<fileset dir="${basedir}/config"/>
<fileset dir="config"/>
</copy>
<copy file="${basedir}/etc/log4j.build.properties"
<copy file="etc/log4j.build.properties"
tofile="${dspace.dir}/config/log4j.properties"
preservelastmodified="true"/>
</target>
@@ -214,14 +227,15 @@ Common usage:
- file in etc/ and the DSpace configuration file using system
- properties -->
<target name="setup_database"
depends="compile"
description="Create database tables">
<java classname="org.dspace.storage.rdbms.InitializeDatabase"
classpathref="build.class.path"
fork="yes"
failonerror="yes">
<sysproperty key="log4j.configuration" value="file:${basedir}/etc/log4j.build.properties"/>
<sysproperty key="log4j.configuration" value="file:etc/log4j.build.properties"/>
<sysproperty key="dspace.configuration" value="${config}"/>
<arg value="${basedir}/etc/database_schema.sql"/>
<arg value="etc/database_schema.sql"/>
</java>
</target>
@@ -234,14 +248,15 @@ Common usage:
- file in etc/ and the DSpace configuration file using system
- properties -->
<target name="clean_database"
depends="compile"
description="Removes DSpace database tables, destroying data">
<java classname="org.dspace.storage.rdbms.InitializeDatabase"
classpathref="build.class.path"
fork="yes"
failonerror="yes">
<sysproperty key="log4j.configuration" value="file:${basedir}/etc/log4j.build.properties"/>
<sysproperty key="log4j.configuration" value="file:etc/log4j.build.properties"/>
<sysproperty key="dspace.configuration" value="${config}"/>
<arg value="${basedir}/etc/clean-database.sql"/>
<arg value="etc/clean-database.sql"/>
</java>
</target>
@@ -252,12 +267,13 @@ Common usage:
<!-- Loads bitstream format and Dublin Core type registries -->
<target name="load_registries"
depends="compile"
description="Load initial contents of registries">
<java classname="org.dspace.administer.RegistryLoader"
classpathref="build.class.path"
fork="yes"
failonerror="yes">
<sysproperty key="log4j.configuration" value="file:${basedir}/etc/log4j.build.properties"/>
<sysproperty key="log4j.configuration" value="file:etc/log4j.build.properties"/>
<sysproperty key="dspace.configuration" value="${config}"/>
<arg value="-bitstream"/>
<arg value="${dspace.dir}/config/registries/bitstream-formats.xml"/>
@@ -266,7 +282,7 @@ Common usage:
classpathref="build.class.path"
fork="yes"
failonerror="yes">
<sysproperty key="log4j.configuration" value="file:${basedir}/etc/log4j.build.properties"/>
<sysproperty key="log4j.configuration" value="file:etc/log4j.build.properties"/>
<sysproperty key="dspace.configuration" value="${config}"/>
<arg value="-dc"/>
<arg value="${dspace.dir}/config/registries/dublin-core-types.xml"/>
@@ -279,8 +295,55 @@ Common usage:
<!-- ============================================================= -->
<target name="fresh_install"
depends="install_code,setup_database,load_registries"
depends="install_code,init_configs,setup_database,load_registries"
description="Do a fresh install of the system, overwriting any data">
<java classname="org.dspace.core.ConfigurationManager"
classpathref="build.class.path"
fork="yes"
failonerror="yes">
<sysproperty key="log4j.configuration" value="file:etc/log4j.build.properties"/>
<sysproperty key="dspace.configuration" value="${config}"/>
<arg value="-installTemplates"/>
</java>
<java classname="org.dspace.browse.InitializeBrowse"
classpathref="build.class.path"
fork="yes"
failonerror="yes">
<sysproperty key="log4j.configuration" value="file:etc/log4j.build.properties"/>
<sysproperty key="dspace.configuration" value="${config}"/>
</java>
<java classname="org.dspace.search.DSIndexer"
classpathref="build.class.path"
fork="yes"
failonerror="yes">
<sysproperty key="log4j.configuration" value="file:etc/log4j.build.properties"/>
<sysproperty key="dspace.configuration" value="${config}"/>
</java>
<echo>
====================================================================
The DSpace code has been installed, and the database initialized.
To complete installation, you should do the following:
* Install the DSpace UI (dspace.war) and OAI-PMH (dspace-oai.war)
Web applications from the 'build' directory in the appropriate
place for your servlet container. e.g. '/opt/tomcat/webapps'
* Make an initial administrator account (an e-person) in DSpace:
${dspace.dir}/bin/create-administrator
* Start up your servlet container (Tomcat etc.)
You should then be able to access your DSpace's 'home page':
${dspace.url}
You should also be able to access the administrator UI:
${dspace.url}/dspace-admin
====================================================================
</echo>
</target>
@@ -290,7 +353,7 @@ Common usage:
<target name="clean"
description="Remove compiled files - does not affect installation">
<delete dir="${basedir}/build" />
<delete dir="build" />
</target>
@@ -300,16 +363,16 @@ Common usage:
<target name="public_api"
description="Create the DSpace public API documentation with javadoc">
<mkdir dir="${basedir}/build/public-api" />
<javadoc sourcepath="${basedir}/src"
destdir="${basedir}/build/public-api"
<mkdir dir="build/public-api" />
<javadoc sourcepath="src"
destdir="build/public-api"
author="true"
version="true"
access="public"
doctitle="DSpace Public API"
windowtitle="DSpace Public API"
bottom="Copyright &#169; 2002 MIT and Hewlett-Packard. All Rights Reserved."
overview="${basedir}/src/overview.html"
overview="src/overview.html"
classpathref="build.class.path">
<package name="org.dspace.administer"/>
<package name="org.dspace.authorize"/>
@@ -333,16 +396,16 @@ Common usage:
<target name="javadoc"
description="Create the DSpace public API documentation with javadoc">
<mkdir dir="${basedir}/build/javadoc" />
<javadoc destdir="${basedir}/build/javadoc"
<mkdir dir="build/javadoc" />
<javadoc destdir="build/javadoc"
author="true"
version="true"
doctitle="DSpace Source Javadoc"
windowtitle="DSpace Source Javadoc"
bottom="Copyright &#169; 2002 MIT and Hewlett-Packard. All Rights Reserved."
overview="${basedir}/src/overview.html"
overview="src/overview.html"
classpathref="build.class.path">
<packageset dir="${basedir}/src">
<packageset dir="src">
<include name="**" />
</packageset>
</javadoc>

View File

@@ -44,6 +44,8 @@
<!--
- The is the servlet deployment descriptor for Tomcat 4.0 for the DSpace
- Web user interface
-
- '@@dspace.dir@@' will be replaced with the directory where DSpace is installed
-->
<web-app>
@@ -51,6 +53,17 @@
<display-name>DSpace Web UI</display-name>
<!-- Configuration Information -->
<context-param>
<param-name>dspace-config</param-name>
<param-value>@@dspace.dir@@/config/dspace.cfg</param-value>
<description>
The location of the main DSpace configuration file
</description>
</context-param>
<!-- Filters -->
<filter>
@@ -91,15 +104,17 @@
<url-pattern>/subscribe</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>registered-only</filter-name>
<url-pattern>/tools</url-pattern>
</filter-mapping>
<!-- Servlets -->
<!-- DSpace configuration initialisation. This needs to be loaded before
other servlets. -->
<servlet>
<servlet-name>load-dspace-config</servlet-name>
<servlet-class>org.dspace.app.webui.servlet.LoadDSpaceConfig</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>authorize</servlet-name>
<servlet-class>org.dspace.app.webui.servlet.admin.AuthorizeAdminServlet</servlet-class>
@@ -265,11 +280,6 @@
<servlet-class>org.dspace.app.webui.servlet.admin.WorkflowAbortServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>itemmap</servlet-name>
<servlet-class>org.dspace.app.webui.servlet.tools.ItemMapServlet</servlet-class>
</servlet>
<!-- Servlet Mappings -->
@@ -418,11 +428,6 @@
<url-pattern>/dspace-admin/workflow</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>itemmap</servlet-name>
<url-pattern>/tools/itemmap</url-pattern>
</servlet-mapping>
<!-- Icon MIME type -->

View File

@@ -1,12 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<!--
- REMEMBER: ONLY UPDATE THE VERSION IN dspace/config/templates
- AND THEN RUN dspace/bin/install-configs!
- DO NOT EDIT THE 'LIVE' VERSION!
-->
<!--
- web.xml
-
@@ -52,19 +46,21 @@
- Web application.
- OAICat Configuration file - see OAICat documentation for details
-
- Text surrounded by two '@' symbols is replaced with the corresponding
- property from dspace.cfg. For example:
-
- @@dspace.url@@
-
- would be replaced with the dspace.url property in dspace.cfg.
- When /dspace/bin/install-configs is run, this file will be installed in the
- location specified by the property: config.template.oai-web.xml
- '@@dspace.dir@@' will be replaced with the directory where DSpace is installed
-->
<web-app>
<display-name>DSpace OAI-PMH 2.0</display-name>
<!-- DSpace configuration information -->
<context-param>
<param-name>dspace-config</param-name>
<param-value>@@dspace.dir@@/config/dspace.cfg</param-value>
<description>
The location of the main DSpace configuration file
</description>
</context-param>
<context-param>
<param-name>properties</param-name>
<param-value>@@dspace.dir@@/config/oaicat.properties</param-value>
@@ -74,6 +70,14 @@
</description>
</context-param>
<!-- DSpace configuration initialisation. This needs to be loaded before
other servlets. -->
<servlet>
<servlet-name>load-dspace-config</servlet-name>
<servlet-class>org.dspace.app.webui.servlet.LoadDSpaceConfig</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>oai-handler</servlet-name>
<servlet-class>ORG.oclc.oai.server.OAIHandler</servlet-class>

View File

@@ -0,0 +1,74 @@
/*
* DSpaceServlet.java
*
* Version: $Revision$
*
* Date: $Date$
*
* Copyright (c) 2002, Hewlett-Packard Company and Massachusetts
* Institute of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of the Hewlett-Packard Company nor the name of the
* Massachusetts Institute of Technology nor the names of their
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
package org.dspace.app.webui.servlet;
import java.io.File;
import javax.servlet.http.HttpServlet;
import org.apache.log4j.PropertyConfigurator;
import org.dspace.core.ConfigurationManager;
/**
* Simple servlet to load in DSpace and log4j configurations. Should always
* be started up before other servlets (use <loadOnStartup>)
*
* @author Robert Tansley
* @version $Revision$
*/
public class LoadDSpaceConfig extends HttpServlet
{
public void init()
{
// Get config parameter
String config = getServletContext().getInitParameter("dspace-config");
// Load in DSpace config
ConfigurationManager.loadConfig(config);
// Load in log4j config
String log4jConf = ConfigurationManager.getProperty("dspace.dir") +
File.separator + "config" + File.separator + "log4j.properties";
PropertyConfigurator.configure(log4jConf);
}
}

View File

@@ -100,7 +100,7 @@ public class ConfigurationManager
{
if (properties == null)
{
loadProperties();
loadConfig(null);
}
return properties.getProperty(property);
@@ -121,7 +121,7 @@ public class ConfigurationManager
{
if (properties == null)
{
loadProperties();
loadConfig(null);
}
String stringValue = properties.getProperty(property);
@@ -160,7 +160,7 @@ public class ConfigurationManager
{
if (properties == null)
{
loadProperties();
loadConfig(null);
}
String stringValue = properties.getProperty(property);
@@ -250,7 +250,7 @@ public class ConfigurationManager
{
if (properties == null)
{
loadProperties();
loadConfig(null);
}
return license;
@@ -258,9 +258,14 @@ public class ConfigurationManager
/**
* Load the properties if they aren't already loaded
* Load the DSpace configuration properties. Only does anything if properties
* are not already loaded. Properties are loaded in from the specified file,
* or default locations.
*
* @param configFile The <code>dspace.cfg</code> configuration file to use,
* or <code>null</code> to try default locations
*/
private static void loadProperties()
public static void loadConfig(String configFile)
{
InputStream is;
@@ -269,12 +274,16 @@ public class ConfigurationManager
return;
}
try
{
// Has the default configuration location been overridden?
String configProperty = System.getProperty("dspace.configuration");
if (configProperty != null)
try
{
if (configFile != null)
{
is = new FileInputStream(configFile);
}
// Has the default configuration location been overridden?
else if (configProperty != null)
{
// Load the overriding configuration
is = new FileInputStream(configProperty);