<!--
  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="Qpid Proton Design" default="dist" basedir=".">
  <description>
    simple example build file
  </description>

  <!-- global properties for this build -->
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="dist"  location="dist"/>
  <property name="classes" location="${build}/classes"/>
  <property name="docs" location="${build}/docs"/>
  <property name="umlgraph.jar" location="/usr/share/java/umlgraph.jar"/>

  <target name="init">
    <tstamp/>
    <mkdir dir="${classes}"/>
  </target>

  <target name="compile" depends="init" description="compile the source ">
    <javac srcdir="${src}" destdir="${classes}"/>
  </target>

  <target name="uml">
    <property name="uml.dir" value="${docs}/uml"/>
    <mkdir dir="${uml.dir}"/>
    <path id="uml.source.path">
      <pathelement path="${src}/"/>
    </path>
    <javadoc sourcepathref="uml.source.path" packagenames="*" package="true">
      <doclet name="org.umlgraph.doclet.UmlGraph" path="${umlgraph.jar}">
        <param name="-d" value="${uml.dir}"/>
      </doclet>
    </javadoc>
    <apply executable="dot" dest="${uml.dir}" parallel="false">
      <arg value="-Tpng"/>
      <arg value="-o"/>
      <targetfile/>
      <srcfile/>
      <fileset dir="${uml.dir}" includes="*.dot"/>
      <mapper type="glob" from="*.dot" to="*.png"/>
    </apply>
  </target>

  <target name="apidoc">
    <javadoc destdir="${docs}/api" author="true" version="true" use="true"
             windowtitle="Qpid Proton API">

      <fileset dir="src" defaultexcludes="yes">
        <include name="proton/**.java"/>
      </fileset>

      <doctitle><![CDATA[<h1>Qpid Proton</h1>]]></doctitle>
      <bottom><![CDATA[<i>Copyright &#169; 2011 Rafael Schloming All Rights Reserved.</i>]]></bottom>
      <tag name="todo" scope="all" description="To do:"/>
      <link offline="true" href="http://download.oracle.com/javase/6/docs/api/" packagelistLoc="C:\tmp"/>
      <link href="http://developer.java.sun.com/developer/products/xml/docs/api/"/>
    </javadoc>
  </target>

  <target name="doc" depends="uml,apidoc"/>

  <target name="dist" depends="compile,doc" description="generate the distribution">
    <mkdir dir="${dist}/lib"/>

    <jar jarfile="${dist}/lib/qpidproton.jar" basedir="${classes}"/>
    <zip destfile="${dist}/docs.zip" basedir="${docs}"/>
    <zip destfile="${dist}/srcs.zip" basedir="${basedir}" excludes="build/**,dist/**"/>
  </target>

  <target name="clean" description="clean up" >
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
  </target>
</project>
