<?xml version="1.0"?>
<!--
 -
 - Copyright (c) 2006 The Apache Software Foundation
 -
 - Licensed 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.
 -
 -->

<!-- AMQP STAC Java build file -->

<project name="management-stac" default="jar" basedir=".">
    <property name="lib" value="${basedir}/lib"/>
    <property name="src" value="${basedir}/src"/>
    <property name="tests" value="${basedir}/test"/>
    <property name="classes" value="${basedir}/classes"/>
    <property name="testclasses" value="${basedir}/testclasses"/>
    <property name="dist" value="${basedir}/dist"/>
    <property name="amqp.root" value="${basedir}/../../clients_java"/>
    <property name="amqp.lib" value="${amqp.root}/lib"/>
    <property name="amqp.dist" value="${amqp.root}/dist"/>
    <property name="managementcore.root" value="${basedir}/../core"/>
    <property name="managementcore.dist" value="${managementcore.root}/dist"/>
    <property name="managementcore.lib" value="${managementcore.root}/lib"/>

    <!-- Setup details -->
    <target name="init">
        <tstamp>
            <format property="release" pattern="-dMMMyy" locale="en" timezone="GMT"/>
        </tstamp>

        <mkdir dir="${classes}"/>
        <mkdir dir="${testclasses}"/>
        <mkdir dir="${dist}"/>
    </target>

    <path id="core.classpath">
        <fileset dir="${lib}">
            <include name="**/*.jar"/>
        </fileset>
        <pathelement path="${classes}"/>
        <pathelement path="${testclasses}/"/>
        <fileset dir="${managementcore.dist}">
            <include name="**/*.jar"/>
        </fileset>
        <fileset dir="${managementcore.lib}">
            <include name="**/*.jar"/>
        </fileset>
        <fileset dir="${amqp.dist}">
            <include name="**/*.jar"/>
        </fileset>
        <fileset dir="${amqp.lib}">
            <include name="**/*.jar"/>
        </fileset>
    </path>

    <!-- Remove all built files -->
    <target name="clean" depends="init">
        <delete dir="${classes}"/>
        <delete dir="${dist}"/>
        <delete dir="${testclasses}"/>
    </target>

    <!-- Compile Java -->
    <target name="compile" depends="init">
        <javac destdir="${classes}" target="1.5" source="1.5" debug="on">
            <classpath refid="core.classpath"/>
            <src path="${src}"/>
        </javac>

        <copy todir="${classes}">
            <!-- copy any non java src files into the build tree, e.g. log4j.properties -->
            <fileset dir="${src}">
                <exclude name="**/*.java"/>
                <exclude name="**/package.html"/>
            </fileset>
        </copy>
    </target>


    <target name="compiletests" depends="compile">
        <javac destdir="${testclasses}" target="1.5" source="1.5" classpathref="core.classpath"
               debug="on">
            <src path="${tests}"/>
        </javac>

        <copy todir="${testclasses}">
            <!-- copy any non java src files into the build tree, e.g. log4j.properties -->
            <fileset dir="${tests}">
                <exclude name="**/*.java"/>
                <exclude name="**/package.html"/>
            </fileset>
        </copy>
    </target>

    <!-- Build jar archive -->
    <target name="jar" depends="compiletests">
        <mkdir dir="${dist}"/>
        <jar basedir="${classes}" jarfile="${dist}/amqp-stac.jar"/>
        <jar basedir="${testclasses}" jarfile="${dist}/amqp-stac-tests.jar"/>
    </target>


    <target name="javadoc" depends="compile, compiletests">
        <mkdir dir="${dist}/docs/api"/>
        <javadoc sourcepath="${src}" destdir="${dist}/docs/api"
                 packagenames="org.apache.qpid.*" classpathref="amqp.classpath" author="true"
                 version="true" windowTitle="AMQP STAC API" doctitle="AMQP STAC API"
                 footer="See &lt;a href=&quot;http://www.amqp.org&quot;&gt;www.amqp.org&lt;/a&gt; for more information."
                 use="true" verbose="false"/>
    </target>
</project>
