<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
 * @(#)build.xml  2002-07-26-hughes
 *
 * Version 1.02
 *
 * Copyright (C) 26 juillet 2002 hughes monget
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * 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
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 -->

<!--
<ant>
 \_/
\(_)/
-(_)-
/(_)\
-->

<project name="JPassGen" default="final" basedir=".">

    <!-- Properties declaration. -->
    <property name="app.name"       value="JPassGen" />
    <property name="app.version"    value="1.03" />

    <property name="backup"         value="backup" />
    <property name="build"          value="build" />
    <property name="dist"           value="dist" />
    <property name="doc"            value="doc" />
    <property name="src"            value="src" />

    <property name="manifest"       value="${src}/manifest.mf" />
    <property name="class.list"     value="${src}/classes.txt" />
    <property name="the.jar"        value="${dist}/JPassGen.jar" />
    <property name="the.package"    value="net/sourceforge/jpassgen" />

    <!-- Initialization -->
    <target name="init">
        <tstamp />
        <property name="build.compiler" value="jikes" />
    </target>

    <!-- Compilation -->
    <target name="compil" depends="init">
        <javac srcdir="${src}"
               debug="false"
               destdir="${build}" 
               includes="**/*.java"
               verbose="no" 
               optimize="true" />
    </target>

    <!-- Distrib -->
    <target name="distrib" depends="compil">
        <mkdir dir="${dist}" />
        <!-- Create jar -->
        <jar jarfile="${the.jar}"
             basedir="${build}"
             manifest="${manifest}"
             update="false"
             compress="true" />
    </target>

    <!-- Daily backup -->
    <target name="backup" depends="distrib">
        <mkdir dir="${backup}" />
        <copy todir="${backup}">
            <fileset dir="${src}">
                <patternset> 
                    <include name="**/*.java" />
                </patternset>
            </fileset>
            <mapper type="glob" from="*.java" to="${DSTAMP}-*.java" />
        </copy>
    </target>

    <!-- Re-compil all -->
    <target name="rebuild">
        <delete dir="${build}" />
        <mkdir dir="${build}" />
        <!-- Copy icons for JOptionPane -->
        <copy todir="${build}/com/incors/plaf/kunststoff/icons">
            <fileset dir="${src}/com/incors/plaf/kunststoff/icons" />
        </copy>
        <!-- Copy icon for JFrame -->
        <copy todir="${build}/org/javalobby/icons">
            <fileset dir="${src}/org/javalobby/icons" />
        </copy>
        <!-- Copy licence -->
        <copy file="${src}/org/apache/avalon/excalibur/cli/LICENSE.txt"
            tofile="${build}/org/apache/avalon/excalibur/cli/LICENSE.txt" />
        <copy file="${src}/com/incors/plaf/kunststoff/licence.txt"
            tofile="${build}/com/incors/plaf/kunststoff/licence.txt" />
        <copy file="LICENCE"
            tofile="${build}/net/sourceforge/jpassgen/src/LICENCE" />
        <!-- Copy properties -->
        <copy todir="${build}/${the.package}/">
            <fileset dir="${src}">
                <include name="*.properties" />
            </fileset>
        </copy>
        <!-- Copy sources -->
        <copy todir="${build}/${the.package}/src">
            <fileset dir="${src}">
                <include name="*.java" />
            </fileset>
        </copy>

        <ant target="final" />
    </target>

    <!-- Clean -->
    <target name="final" depends="backup">
        <ant target="exec" />
    </target>

    <!-- Execute -->
    <target name="exec">
        <java jar="${the.jar}" fork="true" />
    </target>

    <!-- Test -->
    <target name="test">
        <ant target="compil" /> 
        <java jar="net.sourceforge.jpassgen.JPassGenSource" 
            dir="${build}" fork="true" />
    </target>

    <!-- Check java style -->
    <target name="check">
        <taskdef name="checkstyle"
               classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" />
        <checkstyle>
            <fileset dir="${src}" includes="*.java" />
            <property key="checkstyle.pattern.member" value="^_[a-z][a-zA-Z0-9]*$"/>
        </checkstyle>
    </target>

    <!-- Create javadoc -->
    <target name="doc">
        <ant target="check" />
        <delete dir="${doc}" />
        <javadoc
            sourcepath="src"
            packageList="${class.list}"
            destdir="doc"
            private="true"
        />
        <!-- Read javadoc -->
        <exec 
            dir="." 
            executable="cmd.exe" 
            os="Windows 2000"> 
          <arg line="/C start ${doc}/index.html" />
        </exec>
    </target>
</project>

