<?xml version="1.0"?>
<!--
    The contents of this file are subject to the Mozilla Public License Version 1.1
    (the "License"); you may not use this file except in compliance with the License.
    You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.

    Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
    WARRANTY OF ANY KIND, either express or implied. See the License for the specific
    language governing rights and limitations under the License.

    The Original Code is the Venice Web Community System.

    The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
    for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
    Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.

    Contributor(s): 
-->
<project name="Venice" default="compile" basedir=".">
  <!-- Adapted from default Ant buildfile - EJB 12/29/Y2K -->

  <!-- Global property names -->
  <property name="app.name" value="venice"/>
  <property name="deploy.home" value="/home/erbo/venice"/>
  <property name="dist.home" value="${deploy.home}"/>
  <property name="dist.src" value="${app.name}.jar"/>
  <property name="dist.war" value="${app.name}.war"/>
  <property name="javadoc.home" value="${deploy.home}/javadoc"/>

  <!-- Build the base directories that fastupdate requires. -->
  <target name="mkbasedirs">
    <mkdir dir="${deploy.home}"/>
    <mkdir dir="${deploy.home}/WEB-INF"/>
    <mkdir dir="${deploy.home}/WEB-INF/scripts"/>
    <mkdir dir="${deploy.home}/WEB-INF/rpcscripts"/>
  </target>

  <!-- Copy everything to the application directory that can be updated without a restart. -->
  <target name="fastupdate" depends="mkbasedirs">
    <copy todir="${deploy.home}"> <!-- this copies all the JSP files and stuff -->
      <fileset dir="web"/>
    </copy>
    <copy todir="${deploy.home}/WEB-INF/scripts">  <!-- this copies all the scripts -->
      <fileset dir="scripts"/>
    </copy>
    <copy todir="${deploy.home}/WEB-INF/rpcscripts">  <!-- this copies all the RPC scripts -->
      <fileset dir="rpcscripts"/>
    </copy>
  </target>

  <!-- Prepare directory for build (copy everything that requires a restart to take effect) -->
  <target name="prepare" depends="mkbasedirs">
    <copy todir="${deploy.home}/WEB-INF">
      <fileset dir="etc">
	<include name="*.xml"/>
	<include name="*.css"/>
        <include name="*.dict"/>
      </fileset>
    </copy>
    <mkdir  dir="${deploy.home}/WEB-INF/classes"/>
    <mkdir  dir="${deploy.home}/WEB-INF/lib"/>
    <copy todir="${deploy.home}/WEB-INF/lib">
      <fileset dir="lib">
        <include name="*.jar"/>
      </fileset>
    </copy>
    <mkdir  dir="${deploy.home}/WEB-INF/tlds"/>
    <copy todir="${deploy.home}/WEB-INF/tlds">
      <fileset dir="tlds">
        <include name="*.tld"/>
      </fileset>
    </copy>
    <mkdir  dir="${deploy.home}/WEB-INF/temp"/>
    <mkdir  dir="${javadoc.home}"/>
  </target>

  <!-- Wipe out the deployment directory -->
  <target name="clean">
    <delete dir="${deploy.home}"/>
  </target>

  <!-- Compile all the Java source -->
  <target name="compile" depends="prepare,fastupdate">
    <javac srcdir="src" destdir="${deploy.home}/WEB-INF/classes" debug="on" optimize="off" deprecation="on">
      <classpath>
	<fileset dir="${deploy.home}/WEB-INF/lib">
	  <include name="**/*.jar"/>
        </fileset>
	<pathelement location="${deploy.home}/WEB-INF/classes"/>
      </classpath>
    </javac>
    <copy todir="${deploy.home}/WEB-INF/classes">
      <fileset dir="src" includes="**/*.properties"/>
    </copy>
  </target>

  <!-- Create Javadocs -->
  <target name="javadoc" depends="mkbasedirs,prepare">
    <javadoc sourcepath="src" packagenames="*" destdir="${javadoc.home}"/>
  </target>

  <!-- Build it all, man -->
  <target name="all" depends="clean,mkbasedirs,prepare,fastupdate,compile,javadoc"/>

  <!-- Build the distribution .WAR file and JAR up the source code -->
  <target name="dist" depends="mkbasedirs,prepare,fastupdate,compile">
    <jar jarfile="${dist.home}/${dist.src}" basedir="."/>
    <jar jarfile="${dist.home}/${dist.war}" basedir="${deploy.home}"/>
  </target>

</project>




