<!-- *************************************************************************
/*
 * Copyright (c) 2003 by Pankaj Kumar.  All Rights Reserved.
 *
 * This program is open source software; you may use, copy, modify, and
 * redistribute it under the terms of the LICENSE with which it was
 * originally distributed. The LICENSE or reference to the LICENSE
 * can be found in file LICENSE.txt in the base directory of distributed
 * software.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * LICENSE for more details.
 *
 * This software is released with GNU Version 2 License.
 */
 ************************************************************************* -->

<project default="java2html" basedir=".">

  <!--
    Give user a chance to override without editing this file
    (and without typing -D each time he compiles it)
  -->
  <property file=".ant.properties"/>
  
  <!-- =================================================================== -->
  <!-- Initialization target                                               -->
  <!-- =================================================================== -->
  <target name="init">
    <tstamp/>
    <property name="fullname" value="Java Code to HTML Converter"/>
    <property name="Name"     value="jc2h"/>
    <property name="name"     value="jc2h"/>
    <property name="version"  value="0.8"/>
    <property name="year"     value="2003"/>

    <echo message="------- ${fullname} ${version} [${year}] -------"/>

    <property name="build.dir"      value="./build"/>
    <property name="tmp.dir"        value="${build.dir}/tmp"/>
    <property name="class.dir"      value="${tmp.dir}/classes"/>
    <property name="outdir"         value="${build.dir}/html"/>
  </target>

  
  <!-- =================================================================== -->
  <!-- Creates the HTML rendering of source files                          -->
  <!-- =================================================================== -->
  <taskdef name="java2html" classname="com.java2html.Java2HTMLTask"/>

  <target name="check-srcdir" depends="init">
    <available property="srcdir.present" file="${srcdir}" type="dir"/>
  </target>
  <target name="check-jarfile" depends="init">
    <available property="jarfile.present" file="${jarfile}"/>
  </target>
  <target name="check-classes" depends="init">
    <available property="classes.present" file="${class.dir}" type="dir"/>
  </target>
  
  <target name="ensure-srcdir" depends="check-srcdir" unless="srcdir.present">
    <fail>
Specify source directory through Ant property "srcdir".
    </fail>
  </target>
  <target name="ensure-jarfile" depends="check-jarfile" unless="jarfile.present">
    <fail>
Specify jar file through Ant property "jarfile".
    </fail>
  </target>
  <target name="ensure-classes" depends="check-classes" unless="classes.present">
    <fail>
Specify class directory through Ant property "class.dir".
    </fail>
  </target>
  
  <target name="java2html" depends="ensure-srcdir">
    <mkdir dir="${outdir}"/>
    <java2html title="${title}" simple="no" tabsize="4" marginsize="2"
	header="true" footer="false" destination="${outdir}">
      <fileset dir="${srcdir}">
	<include name="**/*.java"/>
      </fileset>
      <!--
      <javadoc localRef="c:\j2se\j2sdk1.4.1_02\docs\api" httpRef="http://java.sun.com/j2se/1.4.2/docs/api"/>
      -->
    </java2html>
  </target>

  <target name="jar2html" depends="jar2class, class2java, java2html"/>
  
  <target name="jar2class" depends="ensure-jarfile">
    <unjar src="${jarfile}" dest="${class.dir}"/>
  </target>
  
  <target name="class2java" depends="ensure-classes">
    <property name="srcdir" value="${tmp.dir}/src"/>
    <mkdir dir="${srcdir}"/>
    <exec executable="jad.exe">
      <arg line="-sjava -o -r -d${srcdir} ${class.dir}/**/*.class"/>
    </exec>
  </target>
  
  <!-- =================================================================== -->
  <!-- Clean targets                                                       -->
  <!-- =================================================================== -->
  <target name="clean" depends="init" description="Cleans the build directories">
    <delete dir="${build.dir}"/>
  </target>
  
</project>

<!-- End of file -->
