<!--
========================================================================
 Copyright (c) 2003 Mort Bay Consulting (Australia) Pty. Ltd.
 $Id: build.xml,v 1.10 2004/11/16 00:15:37 janb Exp $
========================================================================
-->

<project name="LoadBalancer" default="jars" basedir=".">

  <property name="package"          value="jdk1.2" />
  <property environment="env"/>
  <property file="../../ant.properties" />
  <property file="../build.package.properties" />

  <property name="tmp.src" value="${this}/src.tmp" /> 

  <!-- ==================================================================== -->
  <!-- Classpath                                                            -->
  <!-- ==================================================================== -->
  <target name="classpath">
    <path id="extpath">
      <fileset dir="${ext}">
        <include name="*.jar"/>
        <include name="*.JAR"/>
        <include name="*.zip"/>
        <include name="*.ZIP"/>
       </fileset>
       <fileset dir="${jetty.ext}">
        <include name="*.jar"/>
        <include name="*.JAR"/>
        <include name="*.zip"/>
        <include name="*.ZIP"/>
       </fileset>
    </path>

    <path id="classpath">
      <pathelement location="${servlet.jar}" />
      <path refid="extpath" />
    </path>

    <property name="expanded.classpath" refid="classpath"/>
    <echo message="classpath=${expanded.classpath}" level="info"/>

    <available property="jmx.available"
               classname="javax.management.MBeanException"
               classpathref="extpath"
    />
    <echo message="JMX available=${jmx.available}" level="info"/>
  </target>


  <!-- ==================================================================== -->
  <!-- Prepare                                                              -->
  <!-- ==================================================================== -->
  <target name="prepare" depends="classpath" description="Make build directories">
    <mkdir dir="${classes}" />
    <mkdir dir="${lib}" />
  </target>


  <!-- ==================================================================== -->
  <!-- Tidy                                                                 -->
  <!-- ==================================================================== -->
  <target name="tidy" description="Remove classes">
    <delete dir="${classes}" quiet="true"/>
    <delete dir="${tmp.src}" quiet="true"/>
  </target>


  <!-- ==================================================================== -->
  <!-- Clean                                                                -->
  <!-- ==================================================================== -->
  <target name="clean" depends="tidy" description="Remove generated files">
    <delete dir="${test}/classes" quiet="false"/>
    <delete file="${lib}/org.mortbay.jetty-jdk1.2.jar"/>
    <delete file="${lib}/org.mortbay.jmx-jdk1.2.jar"/>
  </target>


  <!-- ==================================================================== -->
  <!-- Classes                                                              -->
  <!-- ==================================================================== -->
  <target name="classes" depends="prepare" description="Compile classes">

    <mkdir dir="${tmp.src}" />

    <copy todir="${tmp.src}">
      <fileset dir="${jetty.src}">
        <include name="javax/**" />
        <include name="org/**/*.java" />
        <include name="org/**/*.properties" />
        <include name="org/**/*.config" />
        <include name="org/**/*.dtd" />
        <include name="org/**/*.xml" />
        <exclude name="org/mortbay/http/nio/**" />
        <exclude name="org/mortbay/log/Frame.java" />
        <exclude name="org/mortbay/util/Resource.java" />
        <exclude name="org/mortbay/util/FileResource.java" />
        <exclude name="org/mortbay/http/handler/ErrorPageHandler.java" />
        <exclude name="org/mortbay/http/handler/ProxyHandler.java" />
        <exclude name="org/mortbay/servlet/ProxyServlet.java" />
      </fileset>
    </copy>

    <copy todir="${tmp.src}">
      <fileset dir="${src}">
        <include name="**/*.java" />
        <include name="**/*.properties" />
        <include name="**/*.config" />
        <include name="**/*.dtd" />
        <include name="**/*.xml" />
      </fileset>
    </copy>

    <mkdir dir="${classes}" />
    <copy todir="${classes}">
      <fileset dir="${tmp.src}">
        <include name="**/*.properties" />
        <include name="**/*.config" />
        <include name="**/*.dtd" />
        <include name="**/*.xml" />
      </fileset>
    </copy>

    <javac srcdir="${tmp.src}"
           destdir="${classes}"
           debug="${javac.debug}"
           optimize="${javac.optimize}"
           deprecation="${javac.deprecation}"
           target="1.2"
           >
       <classpath>
         <path refid="extpath"/>
         <pathelement location="${servlet.jar}" />
       </classpath>
       <include name="**/*.java"/>
       <exclude name="**/jmx/**" unless="jmx.available"/>
    </javac>

  </target>


  <!-- ==================================================================== -->
  <!-- jars                                                                 -->
  <!-- ==================================================================== -->
  <target name="jars" 
          depends="classes, build.package.jar, build.jmx.jar" 
	  description="Make jars">
  </target>


  <!-- ==================================================================== -->
  <!-- build.package.jar                                                    -->
  <!-- ==================================================================== -->
  <target name="build.package.jar" description="Make the jar file">
    <jar basedir="${classes}" destfile="${lib}/org.mortbay.jetty-jdk1.2.jar">
       <manifest>    
         <attribute name="Sealed" value="true"/>
         <attribute name="Built-By" value="${user.name}"/>
         <attribute name="Specification-Version" value="${RELEASE.MAJOR}"/>
         <attribute name="Implementation-Version" value="${RELEASE.MAJOR.MINOR}"/>
         <attribute name="Package-Title" value="org.mortbay.http"/>
         <attribute name="Implementation-Vendor" value="Mort Bay Consulting, Pty. Ltd."/>
         <attribute name="Implementation-URL" value="http://jetty.mortbay.org"/>
         <attribute name="Main-Class" value="org.mortbay.http.HttpServer"/>

         <section name="org/mortbay/jetty/">
           <attribute name="Specification-Title" value="Servlet/2.3"/>
           <attribute name="Implementation-Title" value="Jetty/${RELEASE.MAJOR}"/>
         </section>

         <section name="org/mortbay/http/">
           <attribute name="Implementation-Title" value="Mort Bay HTTP Server"/>
         </section>

         <section name="org/mortbay/util/">
           <attribute name="Implementation-Title" value="Mort Bay Misc. Utilities"/>
         </section>
       </manifest>

       <include name="org/mortbay/**"/>
       <exclude name="org/mortbay/start/**" />
       <exclude name="**/jmx/**" />
    </jar>
  </target>

  <!-- ==================================================================== -->
  <!-- build.package.jar                                                    -->
  <!-- ==================================================================== -->
  <target name="build.jmx.jar" description="Make the jmx jar file">
    <jar basedir="${classes}" destfile="${lib}/org.mortbay.jmx-jdk1.2.jar">
       <manifest>    
         <attribute name="Main-Class" value="org.mortbay.util.jmx.Main"/>
         <attribute name="Class-Path" value="org.mortbay.jetty.jar org.mortbay.jetty.jar ../ext/jmxri.jar ../ext/jmxtools.jar"/>
       </manifest>    
       <include name="**/jmx/**" />
    </jar>
  </target>


  <!-- ==================================================================== -->
  <!-- test                                                                 -->
  <!-- ==================================================================== -->
  <target name="test" depends="jars"
          description="run tests">

  </target>


  <!-- ==================================================================== -->
  <!-- all                                                                  -->
  <!-- ==================================================================== -->
  <target name="all" depends="clean, jars" description="default">
  </target>
</project>
