<?xml version="1.0"?>

<!--
==============================================================================

 Ant build file

Authors:
 Peter Donald <peter@apache.org>

Legal:
  Copyright (c) 2000 The Apache Software Foundation. All Rights Reserved.

==============================================================================
-->

<project name="myrmidon" default="main" basedir=".">

    <!--
    Give user a chance to override without editing this file
    (and without typing -D each time he compiles it)
    -->
    <property file=".ant.properties"/>
    <property file="${user.home}/.ant.properties"/>

    <property name="name" value="myrmidon"/>
    <property name="Name" value="Myrmidon"/>
    <property name="version" value="0.01"/>
    <property name="year" value="2000-2001"/>

    <!--
    these are here only for those who use jikes compiler. For other
    developers this part makes no difference.
    -->
    <property name="build.compiler" value="jikes"/>
    <property name="build.compiler.emacs" value="on"/>
    <property name="build.compiler.pedantic" value="true"/>
    <property name="build.compiler.depend" value="true"/>
    <property name="build.compiler.fulldepend" value="true"/>

    <property name="debug" value="on"/>
    <property name="optimize" value="off"/>
    <property name="deprecation" value="on"/>

    <property name="build.dir" value="build"/>
    <property name="build.lib" value="${build.dir}/lib"/>
    <property name="build.bin" value="${build.dir}/bin"/>
    <property name="build.ext" value="${build.dir}/ext"/>
    <property name="build.src" value="${build.dir}/src"/>
    <property name="build.classes" value="${build.dir}/classes"/>

    <property name="src.base" value="src"/>
    <property name="manifest.dir" value="${src.base}/manifest"/>
    <property name="java.dir" value="${src.base}/java"/>
    <property name="script.dir" value="${src.base}/script"/>
    <property name="lib.dir" value="lib"/>

    <property name="dist.name" value="${Name}-${version}"/>
    <property name="dist.dir" value="dist"/>
    <property name="dist.bin" value="${dist.dir}/bin"/>
    <property name="dist.lib" value="${dist.dir}/lib"/>
    <property name="dist.ext" value="${dist.dir}/ext"/>

    <property name="gen.dir" value="${build.dir}/gen"/>

    <property name="test.dir" value="${build.dir}/test"/>
    <property name="test.working.dir" value="${test.dir}/test"/>
    <property name="test.classes" value="${test.dir}/classes"/>

    <property name="constants.file" value="org/apache/myrmidon/Constants.java"/>

    <path id="project.class.path">
        <pathelement path="${java.class.path}" />
        <pathelement location="../../lib/optional/junit.jar" />
        <pathelement location="../xdocs/lib/xdoclet.jar" />
        <pathelement location="../xdocs/lib/log4j-core.jar" />
        <fileset dir="${lib.dir}">
            <include name="*.jar" />
        </fileset>
        <pathelement path="${build.classes}" />
    </path>

    <!-- Main target -->
    <target name="main" depends="dist-lite" description="Builds the distribution"/>

    <!-- lets see what is available -->
    <target name="check_for_optional_packages">
        <available property="jdk1.2+" classname="java.lang.ThreadLocal" />
        <available property="jdk1.3+" classname="java.lang.StrictMath" />
        <available property="jdk1.4+" classname="java.lang.CharSequence" />
        <available property="bsf.present"
            classname="com.ibm.bsf.BSFManager"
            classpathref="project.class.path" />
        <available property="netrexx.present"
            classname="netrexx.lang.Rexx"
            classpathref="project.class.path" />
        <available property="trax.present"
            classname="javax.xml.transform.Transformer"
            classpathref="project.class.path" />
        <available property="xslp.present"
            classname="com.kvisco.xsl.XSLProcessor"
            classpathref="project.class.path" />
        <available property="xalan.present"
            classname="org.apache.xalan.xslt.XSLTProcessorFactory"
            classpathref="project.class.path" />
        <available property="xalan2.present"
            classname="org.apache.xalan.transformer.TransformerImpl"
            classpathref="project.class.path" />
        <available property="ejb.ejbc.present"
            classname="weblogic.ejbc"
            classpathref="project.class.path" />
        <available property="ejb.DDCreator.present"
            classname="weblogic.ejb.utils.DDCreator"
            classpathref="project.class.path" />
        <available property="ejb.wls.present"
            classname="weblogic.Server"
            classpathref="project.class.path" />
        <available property="junit.present"
            classname="junit.framework.TestCase"
            classpathref="project.class.path" />
        <available property="netcomp.present"
            classname="com.oroinc.net.ftp.FTPClient"
            classpathref="project.class.path" />
        <available property="jcifs.present"
            classname="jcifs.smb.SmbFile"
            classpathref="project.class.path" />
        <available property="starteam.present"
            classname="com.starbase.util.Platform"
            classpathref="project.class.path" />
        <available property="antlr.present"
            classname="antlr.Tool"
            classpathref="project.class.path"/>
        <available property="vaj.present"
            classname="com.ibm.ivj.util.base.Workspace"
            classpathref="project.class.path"/>
        <available property="stylebook.present"
            classname="org.apache.stylebook.Engine"
            classpathref="project.class.path"/>
        <available property="jakarta.regexp.present"
            classname="org.apache.regexp.RE"
            classpathref="project.class.path"/>
        <available property="jakarta.oro.present"
            classname="org.apache.oro.text.regex.Perl5Matcher"
            classpathref="project.class.path" />
        <available property="jmf.present"
            classname="javax.sound.sampled.Clip"
            classpathref="project.class.path"/>
        <available property="icontract.present"
            classname="com.reliablesystems.iContract.IContracted"
            classpathref="project.class.path"/>
        <available property="jdepend.present"
            classname="jdepend.framework.JDepend"
            classpathref="project.class.path"/>
        <available property="log4j.present"
            classname="org.apache.log4j.Category"
            classpathref="project.class.path"/>
        <!-- this is just a way to check for a TraX implementation -->
        <available property="trax.impl.present"
            resource="META-INF/services/javax.xml.transform.TransformerFactory"
            classpathref="project.class.path"/>
        <available property="xalan.envcheck"
            classname="org.apache.xalan.xslt.EnvironmentCheck"
            classpathref="project.class.path" />

        <available property="servlet.present"
            classname="javax.servlet.Servlet"
            classpathref="project.class.path"/>

        <available property="adaptx.present"
            classname="org.exolab.adaptx.xslt.XSLTProcessor"
            classpathref="project.class.path" />
        <available property="xerces.present"
            classname="org.apache.xerces.parsers.SAXParser"
            classpathref="project.class.path" />
        <available property="bcel.present"
            classname="org.apache.bcel.Constants"
            classpathref="project.class.path" />

        <condition property="javamail.complete">
            <and>
                <available classname="javax.activation.DataHandler"
                    classpathref="project.class.path"/>
                <available classname="javax.mail.Transport"
                    classpathref="project.class.path"/>
            </and>
        </condition>
    </target>

    <!-- Compiles and installs the custom build tasks -->
    <target name="custom-tasks">
        <property name="custom-tasks-dir" value="${build.dir}/tasks"/>
        <property name="custom-package-dir" value="${custom-tasks-dir}/org/apache/myrmidon/build"/>
        <mkdir dir="${custom-tasks-dir}"/>
        <javac srcdir="src/make" destdir="${custom-tasks-dir}">
            <classpath refid="project.class.path"/>
        </javac>

        <copy file="${manifest.dir}/ant-descriptor.j" todir="${custom-package-dir}"/>
        <copy file="${manifest.dir}/ant-roles.j" todir="${custom-package-dir}"/>
        <!-- <copy file="${manifest.dir}/type.j" todir="${custom-package-dir}"/> -->

        <taskdef name="antlib-jar" classname="org.apache.myrmidon.build.AntlibJarTask">
            <classpath location="${custom-tasks-dir}"/>
        </taskdef>

        <taskdef name="antlib-descriptor"
            classname="org.apache.myrmidon.build.AntlibDescriptorTask">
            <classpath>
                <pathelement location="${custom-tasks-dir}"/>
                <path refid="project.class.path"/>
            </classpath>
        </taskdef>
    </target>

    <!-- Compiles the source code -->
    <target name="compile" depends="check_for_optional_packages, setup-patterns">

        <tstamp/>
        <mkdir dir="${build.src}"/>
        <copy file="${java.dir}/${constants.file}" tofile="${build.src}/${constants.file}"/>
        <replace file="${build.src}/${constants.file}" token="@@VERSION@@" value="${version}" />
        <replace file="${build.src}/${constants.file}" token="@@DATE@@" value="${TODAY}" />

        <mkdir dir="${build.classes}"/>
        <javac
            destdir="${build.classes}"
            debug="${debug}"
            deprecation="${deprecation}" >
            <classpath refid="project.class.path"/>
            <src location="src/todo"/>
            <src path="${java.dir}" />
            <!--
            <exclude name="${constants.file}"/>
            <src path="${build.src}" />
            -->

            <patternset refid="myrmidon-launcher.include"/>
            <patternset refid="myrmidon-api.include"/>
            <patternset refid="myrmidon-container.include"/>
            <patternset refid="aut.include"/>
            <patternset refid="ant1.todo.include"/>
            <patternset refid="selftest.include"/>
            <patternset refid="selftest-extension1.include"/>
            <include name="org/apache/antlib/**"/>
        </javac>

        <mkdir dir="${test.classes}"/>
        <javac srcdir="src/test"
            destdir="${test.classes}"
            debug="${debug}"
            deprecation="${deprecation}">
            <classpath refid="project.class.path"/>
            <exclude name="**/SmbFileSystemTestCase.java" unless="jcifs.present"/>
            <exclude name="**/FtpFileSystemTestCase.java" unless="netcomp.present"/>
        </javac>

        <copy todir="${build.classes}">
            <fileset dir="${java.dir}">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>

    </target>

    <target name="setup-patterns" depends="check_for_optional_packages">
        <patternset id="myrmidon-launcher.include">
            <include name="org/apache/myrmidon/launcher/**" />
        </patternset>

        <patternset id="myrmidon-api.include">
            <include name="org/apache/myrmidon/api/**" />
            <include name="org/apache/myrmidon/aspects/**" />
            <include name="org/apache/myrmidon/interfaces/**" />
            <include name="org/apache/myrmidon/listeners/**" />
            <include name="org/apache/myrmidon/framework/**" />
        </patternset>

        <patternset id="myrmidon-container.include">
            <include name="org/apache/myrmidon/components/**" />
            <include name="org/apache/myrmidon/frontends/**" />
            <include name="org/apache/myrmidon/*" />
        </patternset>

        <patternset id="aut.include">
            <include name="org/apache/aut/**" />
            <exclude name="org/apache/aut/vfs/provider/ftp/**" unless="netcomp.present"/>
            <exclude name="org/apache/aut/vfs/provider/smb/**" unless="jcifs.present"/>
        </patternset>

        <property name="ant.package" value="org/apache/tools/todo"/>
        <property name="taskdefs.package" value="${ant.package}/taskdefs"/>
        <property name="antlib.package" value="org/apache/antlib"/>
        <property name="optional.type.package" value="${ant.package}/types/optional"/>
        <property name="util.package" value="${ant.package}/util"/>
        <property name="regexp.package" value="${util.package}/regexp"/>

        <patternset id="ant1.todo.include">
            <include name="org/apache/tools/**" />
            <exclude name="${regexp.package}/JakartaRegexp*.java"
                unless="jakarta.regexp.present" />
            <exclude name="${regexp.package}/JakartaOro*.java"
                unless="jakarta.oro.present" />
            <exclude name="${regexp.package}/Jdk14Regexp*.java"
                unless="jdk1.4+" />
            <exclude name="${ant.package}/AntSecurityManager.java"
                unless="jdk1.2+" />
            <exclude name="${ant.package}/listener/Log4jListener.java"
                unless="log4j.present" />

            <exclude name="${taskdefs.package}/IContract.java"
                unless="icontract.present" />
            <exclude name="${taskdefs.package}/Script.java"
                unless="bsf.present" />
            <exclude name="${taskdefs.package}/stylebook/StyleBook.java"
                unless="stylebook.present" />
            <exclude name="${taskdefs.package}/NetRexxC.java"
                unless="netrexx.present" />
            <exclude name="${antlib.package}/xml/TraXLiaison.java"
                unless="trax.present" />
            <exclude name="${antlib.package}/xml/XalanLiaison.java"
                unless="xalan.present" />
            <exclude name="${taskdefs.package}/Javah.java"
                unless="jdk1.2+" />
            <exclude name="${taskdefs.package}/junit/*"
                unless="junit.present" />
            <exclude name="${taskdefs.package}/net/**.java"
                unless="netcomp.present" />
            <exclude name="${taskdefs.package}/net/MimeMail.java"
                unless="javamail.complete" />
            <exclude name="${taskdefs.package}/scm/AntStarTeam*.java"
                unless="starteam.present" />
            <exclude name="${taskdefs.package}/ANTLR.java"
                unless="antlr.present" />
            <exclude name="${taskdefs.package}/perforce/*.java"
                unless="jakarta.oro.present" />
            <exclude name="${taskdefs.package}/junit/XMLResultAggregator.java"
                unless="trax.present" />
            <exclude name="${taskdefs.package}/junit/AggregateTransformer.java"
                unless="trax.present" />
            <exclude name="${taskdefs.package}/junit/XMLResultAggregator.java"
                unless="xalan2.present" />
            <exclude name="${taskdefs.package}/junit/AggregateTransformer.java"
                unless="xalan2.present" />
            <exclude name="${taskdefs.package}/junit/XalanExecutor.java"
                unless="xalan2.present" />
            <exclude name="${taskdefs.package}/junit/Xalan2Executor.java"
                unless="xalan2.present" />
            <exclude name="${taskdefs.package}/junit/Xalan1Executor.java"
                unless="xalan.present" />
            <exclude name="${taskdefs.package}/jdepend/*"
                unless="jdepend.present" />
            <exclude name="${taskdefs.package}/sitraka/**"
                unless="some.regexp.support"/>
            <exclude name="${taskdefs.package}/metamata/MAudit*"
                unless="jakarta.oro.present"/>
            <exclude name="${taskdefs.package}/metamata/MMetrics*"
                unless="trax.present"/>
            <exclude name="${taskdefs.package}/metamata/**"
                unless="jdk1.2+" />
            <exclude name="${optional.type.package}/depend/*.java"
                unless="bcel.present" />
            <exclude name="${util.package}/depend/*.java"
                unless="bcel.present" />
            <exclude name="${optional.type.package}/depend/*.java"
                unless="jdk1.2+" />
            <exclude name="${util.package}/depend/*.java"
                unless="jdk1.2+" />
        </patternset>

        <patternset id="selftest.include">
            <include name="org/apache/antlib/selftest/**" />
            <exclude name="org/apache/antlib/selftest/extension1/**" />
        </patternset>

        <patternset id="selftest-extension1.include">
            <include name="org/apache/antlib/selftest/extension1/**" />
        </patternset>
    </target>

    <!-- The generation of the descriptor is kept separated from the packaging
       of the jars, since jarring is fast and XDoclet is really slow.-->
    <target name="antlib-descriptors"
        depends="setup-patterns, custom-tasks"
        unless="antlib-descriptors.omit"
        description="Generates Antlib descriptors using XDoclet.">

        <antlib-descriptor libName="builtin"
            destdir="${gen.dir}"
            classpathref="project.class.path">
            <fileset dir="${java.dir}">
                <patternset refid="myrmidon-api.include"/>
            </fileset>
        </antlib-descriptor>

        <antlib-descriptor libName="container"
            destdir="${gen.dir}"
            classpathref="project.class.path">
            <fileset dir="${java.dir}">
                <patternset refid="myrmidon-container.include"/>
            </fileset>
        </antlib-descriptor>

        <antlib-descriptor libName="aut"
            destdir="${gen.dir}"
            classpathref="project.class.path">
            <fileset dir="${java.dir}">
                <patternset refid="aut.include"/>
            </fileset>
        </antlib-descriptor>

        <antlib-descriptor libName="selftest"
            destdir="${gen.dir}"
            classpathref="project.class.path">
            <fileset dir="${java.dir}">
                <patternset refid="selftest.include"/>
            </fileset>
        </antlib-descriptor>
    </target>

    <target name="test-xdocs" depends="antlib-descriptors" description="Generate documentation for antlibs">
        <!-- start to test xdocs generation -->
        <ant antfile="antlib.xml" target="antlib-docs">
            <property name="antlib.name" value="core"/>
        </ant>
    </target>

    <!-- Package the jar files -->
    <target name="jars" depends="custom-tasks, compile, antlib-descriptors">

        <mkdir dir="${build.bin}"/>
        <mkdir dir="${build.bin}/lib"/>
        <mkdir dir="${build.lib}"/>
        <mkdir dir="${build.ext}"/>

        <jar jarfile="${build.bin}/myrmidon-launcher.jar"
            basedir="${build.classes}"
            manifest="${manifest.dir}/myrmidon-launcher.mf">
            <patternset refid="myrmidon-launcher.include"/>
        </jar>

        <antlib-jar jarfile="${build.bin}/lib/myrmidon-container.jar"
            basedir="${build.classes}"
            manifest="${manifest.dir}/myrmidon-container.mf"
            rolesDescriptor="${gen.dir}/container-ant-roles.xml"
            descriptor="${gen.dir}/container-ant-descriptor.xml" >
            <patternset refid="myrmidon-container.include"/>
        </antlib-jar>

        <antlib-jar jarfile="${build.lib}/myrmidon-api.jar"
            basedir="${build.classes}"
            manifest="${manifest.dir}/myrmidon-api.mf"
            rolesDescriptor="${gen.dir}/builtin-ant-roles.xml"
            descriptor="${gen.dir}/builtin-ant-descriptor.xml"
            servicesDescriptor="${manifest.dir}/core-services.xml" >
            <patternset refid="myrmidon-api.include"/>
        </antlib-jar>

        <antlib-jar jarfile="${build.lib}/aut.jar"
            basedir="${build.classes}"
            manifest="${manifest.dir}/aut.mf"
            rolesDescriptor="${gen.dir}/aut-ant-roles.xml"
            descriptor="${gen.dir}/aut-ant-descriptor.xml" >
            <patternset refid="aut.include"/>
        </antlib-jar>

        <antlib-jar jarfile="${build.lib}/ant1_todo.jar"
            basedir="${build.classes}"
            descriptor="${manifest.dir}/ant1-ant-descriptor.xml" >
            <patternset refid="ant1.todo.include"/>
        </antlib-jar>

        <antlib-jar jarfile="${build.ext}/selftest.atl"
            basedir="${build.classes}"
            manifest="${manifest.dir}/selftest.mf"
            descriptor="${gen.dir}/selftest-ant-descriptor.xml"
            rolesDescriptor="${gen.dir}/selftest-ant-roles.xml">
            <patternset refid="selftest.include"/>
        </antlib-jar>

        <jar jarfile="${build.ext}/selftest-extension1.jar"
            basedir="${build.classes}"
            manifest="${manifest.dir}/selftest-extension1.mf">
            <patternset refid="selftest-extension1.include" />
        </jar>

        <!-- Simple cases handled by antlib.xml -->
        <ant antfile="antlib.xml">
            <property name="antlib.name" value="core"/>
        </ant>

        <ant antfile="antlib.xml">
            <property name="antlib.name" value="file"/>
        </ant>

        <ant antfile="antlib.xml">
            <property name="antlib.name" value="archive"/>
        </ant>

        <ant antfile="antlib.xml">
            <property name="antlib.name" value="cvslib"/>
        </ant>

        <ant antfile="antlib.xml">
            <property name="antlib.name" value="nativelib"/>
        </ant>

        <ant antfile="antlib.xml">
            <property name="antlib.name" value="security"/>
        </ant>

        <ant antfile="antlib.xml">
            <property name="antlib.name" value="runtime"/>
        </ant>

        <ant antfile="antlib.xml">
            <property name="antlib.name" value="sound"/>
        </ant>

        <ant antfile="antlib.xml">
            <property name="antlib.name" value="vfile"/>
        </ant>

        <ant antfile="antlib.xml">
            <property name="antlib.name" value="java"/>
        </ant>
    </target>

    <!-- Compiles and runs the unit tests -->
    <target name="run-tests" depends="dist-lite" if="junit.present">
        <!-- Compile the unit tests -->
        <mkdir dir="${test.classes}"/>
        <javac srcdir="src/test"
            destdir="${test.classes}"
            debug="${debug}"
            deprecation="${deprecation}">
            <classpath refid="project.class.path"/>
            <exclude name="**/SmbFileSystemTestCase.java" unless="jcifs.present"/>
            <exclude name="**/FtpFileSystemTestCase.java" unless="netcomp.present"/>
        </javac>

        <!-- Prepare test files -->
        <delete dir="${test.working.dir}"/>

        <!-- Prepare a dummy installation -->
        <copy todir="${test.working.dir}/dist">
            <fileset dir="${dist.dir}"/>
        </copy>

        <!-- Copy the resources from source tree into working test dir -->
        <copy todir="${test.working.dir}">
            <fileset dir="src/test">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>

        <!-- Prepare the VFS tests -->
        <property name="test.vfs.dir" location="${test.working.dir}/org/apache/aut/vfs/test"/>
        <mkdir dir="${test.vfs.dir}/write-tests"/>
        <mkdir dir="${test.vfs.dir}/basedir/emptydir"/>
        <zip zipfile="${test.vfs.dir}/test.zip">
            <fileset dir="${test.vfs.dir}" includes="basedir/**"/>
        </zip>
        <zip zipfile="${test.vfs.dir}/nested.zip">
            <fileset dir="${test.vfs.dir}" includes="test.zip"/>
        </zip>

        <!-- Prepare deployer tests -->
        <property name="test.deployer.dir"
            value="${test.working.dir}/org/apache/myrmidon/components/deployer/test"/>
        <mkdir dir="${test.deployer.dir}"/>
        <jar jarfile="${test.deployer.dir}/test.atl">
            <zipfileset dir="${test.deployer.dir}" prefix="META-INF" includes="*.xml"/>
        </jar>

        <!-- Prepare type factory tests -->
        <property name="test.type.dir"
            value="${test.working.dir}/org/apache/myrmidon/interfaces/type/test"/>
        <mkdir dir="${test.type.dir}"/>
        <jar jarfile="${test.type.dir}/types.jar">
            <fileset dir="${test.classes}" includes="org/apache/myrmidon/interfaces/type/test/MyType1.class"/>
        </jar>

        <!-- Prepare the project tests -->
        <antlib-descriptor libName="unittests"
            destdir="${gen.dir}"
            classpathref="project.class.path">
            <fileset dir="src/test">
                <include name="org/apache/antlib/**"/>
                <include name="org/apache/myrmidon/framework/**"/>
            </fileset>
        </antlib-descriptor>
        <copy file="${gen.dir}/unittests-ant-descriptor.xml"
            tofile="${test.classes}/META-INF/ant-descriptor.xml"/>

        <!-- Run all the tests -->
        <junit printsummary="on" fork="true" failureProperty="test.failed">
            <formatter type="brief" usefile="false"/>
            <classpath location="${build.classes}"/>
            <classpath>
                <fileset dir="${test.working.dir}/dist/bin/lib" includes="**/*.jar"/>
                <fileset dir="${test.working.dir}/dist/lib" includes="**/*.jar, **/*.atl" excludes="crimson.jar"/>
            </classpath>
            <classpath location="${test.classes}"/>

            <!-- Pass config to the tests -->
            <sysproperty key="test.basedir" value="${test.working.dir}"/>
            <sysproperty key="test.smb.uri" value="smb://${vfs.user}:${vfs.password}@${vfs.host}/${vfs.user}/vfs"/>
            <sysproperty key="test.ftp.uri" value="ftp://${vfs.user}:${vfs.password}@${vfs.host}/home/${vfs.user}/vfs"/>

            <batchtest>
                <fileset dir="${test.classes}">
                    <include name="**/*TestCase.class" unless="single.test"/>
                    <exclude name="**/Abstract*TestCase.class"/>
                    <include name="**/${single.test}TestCase.class" if="single.test"/>
                    <exclude name="**/BzipTestCase.class" unless="test.bzip"/>
                    <exclude name="**/SmbFileSystemTestCase.class" unless="test.smb"/>
                    <exclude name="**/FtpFileSystemTestCase.class" unless="test.ftp"/>
                </fileset>
            </batchtest>
        </junit>
    </target>

    <target name="test" if="test.failed" depends="run-tests">
        <fail> - One or more tests failed.</fail>
    </target>

    <target name="checkstyle" description="Checkstyle">

        <!-- this invocation of checkstyle requires that checkstyle be downloaded and setup -->
        <!-- thats why you are required to define do.checkstyle property to generate the report -->
        <taskdef name="checkstyle"
            classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
            <classpath refid="project.class.path"/>
        </taskdef>
        <checkstyle
            lcurlyType="nl"
            lcurlyMethod="nl"
            lcurlyOther="nl"
            rcurly="ignore"
            allowProtected="false"
            allowPackage="false"
            allowNoAuthor="false"
            maxLineLen="100"
            maxMethodLen="100"
            maxConstructorLen="100"
            memberPattern="^m_[a-z][a-zA-Z0-9]*$"
            staticPattern="^c_[a-z][a-zA-Z0-9]*$"
            constPattern="(^c_[a-z][a-zA-Z0-9]*$)|([A-Z_]*$)"
            ignoreImportLen="true"
            allowTabs="false"
            javadocScope="protected"
            ignoreWhitespace="true"
            cacheFile="checkstyle.cache"
            failOnViolation="false"
            ignoreCastWhitespace="true">
            <fileset dir="${java.dir}">
                <include name="**/*.java"/>
            </fileset>
            <formatter type="plain"/>
            <formatter type="xml" toFile="build/checkstyle-results.xml"/>
        </checkstyle>
    </target>

    <target name="checkstyle-report"
        depends="checkstyle"
        if="do.checkstyle"
        description="Generate Checkstyle Report">

        <mkdir dir="${build.reports}/checkstyle"/>
        <style style="../../src/etc/checkstyle-frames.xsl" in="build/checkstyle-results.xml"
            out="${build.reports}/checkstyle/delete-me.html"/>

    </target>

    <!-- Creates the distribution -->
    <target name="dist-lite"
        depends="jars"
        description="Generates a minimal working distribution.">

        <mkdir dir="${dist.bin}"/>
        <mkdir dir="${dist.lib}"/>
        <mkdir dir="${dist.ext}"/>

        <copy todir="${dist.bin}">
            <fileset dir="${build.bin}"/>
        </copy>

        <copy todir="${dist.lib}">
            <fileset dir="${build.lib}"/>
        </copy>

        <copy todir="${dist.ext}">
            <fileset dir="${build.ext}"/>
        </copy>

        <copy todir="${dist.lib}">
            <fileset dir="${lib.dir}">
                <exclude name="xdoclet.jar"/>
                <exclude name="jdepend.jar"/>
            </fileset>
        </copy>

        <copy todir="${dist.bin}">
            <fileset dir="${script.dir}"/>
        </copy>

        <chmod dir="${dist.dir}" perm="go-rwx" />
        <chmod file="${dist.bin}/ant" perm="u+x"/>
        <fixcrlf srcdir="${dist.bin}" eol="crlf" includes="**/*.bat" />
        <fixcrlf srcdir="${dist.bin}" eol="lf" includes="**/*.sh" />
        <fixcrlf srcdir="${dist.bin}" eol="lf" includes="ant" />
    </target>

    <target name="dist-extralite"
        description="A faster version of dist-lite (no XDoclet).">
        <property name="antlib-descriptors.omit" value="true"/>
        <antcall target="dist-lite"/>
    </target>

    <!-- Creates the distribution -->
    <target name="dist" depends="dist-lite, test" description="Builds the distribution"/>

    <!-- Cleans up build and distribution directories -->
    <target name="clean" description="Deletes all built files">
        <delete dir="${build.dir}"/>
        <delete dir="${dist.dir}" failonerror="false"/>
    </target>

    <!-- Cleans up the compiled classes -->
    <target name="clean-classes">
        <delete dir="${build.classes}"/>
    </target>

    <!-- Rebuilds the distribution -->
    <target name="rebuild" description="Rebuilds the distribution">
        <antcall target="clean"/>
        <antcall target="main"/>
    </target>

    <!-- Recompiles the classes, and builds the distribution -->
    <target name="recompile" description="Recompiles and builds the the distribution">
        <antcall target="clean-classes"/>
        <antcall target="main"/>
    </target>

</project>
