<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (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.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<project name="JkStatus" default="dist" basedir=".">


  <!-- ===================== Initialize Property Values =================== -->

  <property file="build.properties" />
  <property file="build.properties.default" />

  <!-- Build Defaults -->
  <property name="jk.build"  value="build"/>
  <property name="jk.dist"   value="dist"/>

    <!-- Construct Catalina classpath -->
  <path id="jtc.classpath">
    <pathelement location="${catalina.build}/server/lib/catalina.jar"/>
    <pathelement location="${catalina.build}/server/lib/catalina-ant.jar"/>
    <pathelement location="${catalina.build}/server/lib/tomcat-util.jar"/>
    <pathelement location="${catalina.build}/server/lib/${commons-modeler.jar}"/>
    <pathelement location="${catalina.build}/bin/${commons-logging.jar}"/>
    <pathelement location="${jmx.jar}"/>
    <pathelement location="${ant.home}/lib/ant.jar"/>
      <pathelement location="${catalina.build}/common/lib/servlet-api.jar"/>
  </path>

    <!-- Source path -->
  <path id="javadoc.sourcepath">
    <pathelement location="src/share"/>
  </path>


  <!-- =================== BUILD: Set compile flags ======================= -->
  <target name="flags">
    <!-- JDK flags -->
    <available property="jdk.1.3.present" 
     classname="java.lang.reflect.Proxy" />
    <available property="jdk.1.4.present" classname="java.nio.Buffer" />
  </target>


  <!-- =================== BUILD: Set compile flags ======================= -->
  <target name="flags.display" depends="flags" unless="flags.hide">

    <echo message="--- Build environment for Catalina ---" />

    <echo message="If ${property_name} is displayed, then the property is not set)" />

    <echo message="--- Build options ---" />
    <echo message="full.dist=${full.dist}" />
    <echo message="build.sysclasspath=${build.sysclasspath}" />
    <echo message="compile.debug=${compile.debug}" />
    <echo message="compile.deprecation=${compile.deprecation}" />
    <echo message="compile.optimize=${compile.optimize}" />

    <echo message="--- Ant Flags ---" />
    <echo message="&lt;style&gt; task available (required)=${style.available}" />

    <echo message="--- JDK ---" />
    <echo message="jdk.1.3.present=${jdk.1.3.present}" />
    <echo message="jdk.1.4.present=${jdk.1.4.present}" />

  </target>

  <!-- =================== BUILD: Create Directories ====================== -->
  <target name="build-prepare">
    <mkdir dir="${catalina.build}"/>
    <mkdir dir="${catalina.build}/classes"/>
    <mkdir dir="${jk.dist}"/>
    <mkdir dir="${jk.build}"/>
    <mkdir dir="${jk.build}/classes"/>
  </target>

  <!-- ================ BUILD: Compile Catalina Components ================ -->
  
  <target name="build-jk-status" depends="build-prepare">
    <!-- Compile internal server components -->
    <javac srcdir="${basedir}/src/share" destdir="${jk.build}/classes"
           debug="${compile.debug}" deprecation="${compile.deprecation}"
           optimize="${compile.optimize}"
           excludes="**/.svn/**"
           encoding="ISO-8859-1">
        <classpath refid="jtc.classpath" />
    </javac>
    <copy file="${basedir}/src/share/org/apache/jk/status/LocalStrings.properties"
    	  tofile="${jk.build}/classes/org/apache/jk/status/LocalStrings.properties"/>
    <copy file="${basedir}/src/share/org/apache/jk/status/mbeans-descriptors.xml"
    	  tofile="${jk.build}/classes/org/apache/jk/status/mbeans-descriptors.xml"/>
    <copy file="${basedir}/src/share/org/apache/jk/status/antlib.xml"
    	  tofile="${jk.build}/classes/org/apache/jk/status/antlib.xml"/>
    <copy file="${basedir}/src/share/org/apache/jk/status/jkstatus.tasks"
    	  tofile="${jk.build}/classes/org/apache/jk/status/jkstatus.tasks"/>
   </target>


  <!-- ================ BUILD: Create Catalina Javadocs =================== -->
  <target name="javadoc">
    <delete dir="${jk.build}/javadoc"/>
    <mkdir dir="${jk.build}/javadoc"/>
    <javadoc packagenames="org.apache.jk.status.*"
      classpathref="jtc.classpath"
      sourcepathref="javadoc.sourcepath"
      destdir="${jk.build}/javadoc"
      author="true"
      version="true"
      windowtitle="Jk Status Internal API Documentation"
      doctitle="Jk Status API"
      bottom="Copyright &amp;#169; 2000-2012 Apache Software Foundation.  All Rights Reserved."
    />
  </target>

  <!-- ======================= BUILD: Clean Directory ===================== -->
  <target name="build-clean">
    <delete dir="${jk.build}"/>
  </target>

  <!-- ==================== BUILD: Rebuild Everything ===================== -->


  <!-- ================ DIST: Create Distribution ========================= -->
  <target name="dist" depends="build-jk-status">
    
    <jar destfile="${jk.dist}/tomcat-jkstatus-ant.jar"
         basedir="${jk.build}/classes">
       <include name="org/apache/jk/status/**" />
       <exclude name="**/package.html" />
       <exclude name="**/LocalStrings_*" />
    </jar>
  </target>

  <target name="copy" depends="dist" >
     <copy file="${jk.dist}/tomcat-jkstatus-ant.jar" todir="${catalina.build}/server/lib" />
     <copy file="conf/jkstatus-tasks.xml" todir="${catalina.build}/bin" />
  </target>
  
  <!-- ======================== DIST: Clean Directory ===================== -->

  <!-- ====================== Convenient Synonyms ========================= -->

</project>
