<commit_before><!--
  Ant build file for clapper.org Java utility library

  $Id$
  ===========================================================================
  This software is released under a Berkeley-style license:

  Copyright (c) 2004-2006 <NAME>. All rights reserved.

  Redistribution and use in source and binary forms are permitted provided
  that: (1) source distributions retain this entire copyright notice and
  comment; and (2) modifications made to the software are prominently
  mentioned, and a copy of the original software (or a pointer to its
  location) are included. The name of the author may not be used to endorse
  or promote products derived from this software without specific prior
  written permission.

  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

  Effectively, this means you can do what you want with the software except
  remove this notice or take advantage of the author's name. If you modify
  the software and redistribute your modified version, you must indicate that
  your version is a modification of the original, and you must provide either
  a pointer to or a copy of the original.
-->

<project name="util" default="all" basedir=".">
  <description>
    Build file for "util" Java classes
  </description>

  <!--
  ***************************************************************************
                                Properties
  ***************************************************************************
  -->

  <property environment="env"/>
  <property name="pkg.path" value="org/clapper/util"/>
  <dirname property="top.dir" file="${ant.file}"/> <!-- path to this dir -->
  <property name="src.top.relative" value="src"/>
  <property name="src.top" location="${src.top.relative}"/>
  <property name="src.dir" location="${src.top}/${pkg.path}"/>

  <!--
       <javac> uses a different source directory to prevent constant
       recompilation. See "http://ant.apache.org/faq.html#always-recompiles"
       for details.
  -->
  <property name="javac.src.dir" location="${src.top}"/>
  <property name="build.dir.relative" value="build"/>
  <property name="build.dir"  location="${build.dir.relative}"/>
  <property name="compiled.classes.dir" location="${build.dir}/classes"/>
  <property name="docs.dir" value="${top.dir}/docs"/>
  <property name="javadocs.dir" value="${build.dir}/javadocs"/>
  <property name="javadocs.api.dir" value="${javadocs.dir}/api"/>
  <property name="javac.debug" value="true"/>
  <property name="javac.listfiles" value="no"/>
  <property name="javac.source" value="1.5"/>
  <property name="javac_lint_unchecked_opt" value="-Xlint:unchecked"/>
  <property name="javac_lint_deprecation_opt" value="-Xlint:deprecation"/>
  <property name="build.info.file"
            value="${compiled.classes.dir}/org/clapper/util/misc/BuildInfoBundle.properties"/>
  <property name="code_jar_name" value="ocutil"/>
  <property name="code_jar_file" value="${code_jar_name}.jar"/>
  <property name="code_jar_path" value="${build.dir}/lib/${code_jar_file}"/>
  <property name="docs_top_dir" value="${top.dir}/docs"/>
  <property name="docs_api_dir" value="${docs_top_dir}/api"/>
  <property name="zip_dir_prefix" value="util/"/>
  <property name="release_dir" value="${build.dir}/release"/>
  <property file="build.properties"/>
  <!--
  ***************************************************************************
                            Paths and Patterns
  ***************************************************************************
  -->

  <condition property="third.party.jar.dir" value="/usr/local/java/classes">
      <not>
          <isset property="third.party.jar.dir"/>
      </not>
  </condition>

  <path id="project.class.path">
    <pathelement location="lib/"/>
    <pathelement location="${third.party.jar.dir}/activation.jar"/>
    <pathelement location="${third.party.jar.dir}/mail.jar"/>
    <pathelement location="${third.party.jar.dir}/asm-2.2.1.jar"/>
    <pathelement location="${third.party.jar.dir}/asm-commons-2.2.1.jar"/>
    <pathelement location="${third.party.jar.dir}/asm-util-2.2.1.jar"/>
    <pathelement location="${third.party.jar.dir}/commons-logging.jar"/>
    <pathelement location="${ant.home}/lib/ant.jar"/>
  </path>
  
  <path id="installer.class.path">
      <path refid="project.class.path"/>
      <pathelement location="${third.party.jar.dir}/izpack-compiler.jar"/>
  </path>

  <!--
  ***************************************************************************
                          Initialization Targets
  ***************************************************************************
  -->

  <target name="init">
    <!-- Create the time stamp -->
    <tstamp>
      <format property="build.date" pattern="dd MMMM, yyyy HH:mm:ss z"
              locale="en"/>
    </tstamp>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${compiled.classes.dir}"/>
    <depend srcdir="${src.dir}" destdir="${compiled.classes.dir}"/>
  </target>

  <!--
  ***************************************************************************
                               Code Targets
  ***************************************************************************
  -->

  <target name="all" depends="init,lib,bundles,-build.info,testers"/>

  <target name="bundles">
    <copy todir="${compiled.classes.dir}">
      <fileset dir="${src.top}">
        <include name="**/*.properties"/>
      </fileset>
    </copy>
  </target>

  <target name="testers" depends="lib,lib.testers,mail.testers"/>
  <target name="lib" depends="lib.unconditional,lib.conditional"/>

  <target name="lib.unconditional" depends="init">
    <echo>third.party.jar.dir=${third.party.jar.dir}</echo>
    <javac srcdir="${javac.src.dir}"
           source="${javac.source}"
           debug="${javac.debug}"
           listfiles="${javac.listfiles}"
           deprecation="yes"
           destdir="${compiled.classes.dir}">

      <compilerarg compiler="jikes" value="+Peffective-java"/>
      <compilerarg compiler="jikes" value="+Punused-type-imports"/>
      <compilerarg compiler="jikes" value="+Punused-package-imports"/>
      <compilerarg compiler="jikes" value="+Pmodifier-order"/>
      <compilerarg compiler="jikes" value="+Pserial"/>

      <compilerarg compiler="javac1.5" value="${javac_lint_unchecked_opt}"/>
      <!--
      <compilerarg compiler="javac1.5" value="${javac_lint_deprecation_opt}"/>
      -->

      <classpath refid="project.class.path"/>

      <include name="**/*.java"/>
      <exclude name="${pkg.path}/mail/*.java"/>
      <exclude name="${pkg.path}/classutil/*.java"/>
      <exclude name="**/test/*.java"/>

    </javac>
  </target>

  <target name="lib.conditional" depends="mail,classutil"/>

  <!--
  Can only build the "mail" component if the Java Mail API and
  the Java Activation Framework are both in the CLASSPATH
  -->

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

  <target name="-check.javamail"
          depends="-check.javamail.exists"
          unless="javamail.exists">
    <echo>
*** Ant cannot find the Java Mail API and/or the Java Activation Framework,
*** so, all components that require those packages will be skipped. To enable
*** those components, install the Java Mail API and Java Activation Framework,
*** and make them available in your CLASSPATH. Both packages can be found
*** at http://java.sun.com/
    </echo>
  </target>

  <target name="mail" depends="-check.javamail" if="javamail.exists">
    <echo level="verbose">Found Java Mail API. Compiling mail classes.</echo>
    <javac srcdir="${javac.src.dir}"
           source="${javac.source}"
           debug="${javac.debug}"
           listfiles="${javac.listfiles}"
           deprecation="yes"
           destdir="${compiled.classes.dir}">

      <compilerarg compiler="jikes" value="+Peffective-java"/>
      <compilerarg compiler="jikes" value="+Punused-type-imports"/>
      <compilerarg compiler="jikes" value="+Punused-package-imports"/>
      <compilerarg compiler="jikes" value="+Pmodifier-order"/>
      <compilerarg compiler="jikes" value="+Pserial"/>

      <compilerarg compiler="javac1.5" value="${javac_lint_unchecked_opt}"/>
      <!--
      <compilerarg compiler="javac1.5" value="${javac_lint_deprecation_opt}"/>
      -->

      <classpath refid="project.class.path"/>

      <include name="${pkg.path}/mail/*.java"/>
    </javac>
  </target>

  <!--
  Can only build the "classutil" component if the ASM API is available.
  -->

  <target name="-check.asm.exists">
    <condition property="asm.exists">
      <and>
        <available classname="org.objectweb.asm.ClassReader" classpathref="project.class.path"/>
      </and>
    </condition>
  </target>

  <target name="-check.asm"
          depends="-check.asm.exists"
          unless="asm.exists">
    <echo>
*** Ant cannot find the ASM API. All components that require the ASM API
*** will be skipped. To enable, install the ASM API, and make it available
*** in your CLASSPATH. ASM can be found at http://asm.objecweb.org/
    </echo>
  </target>

  <target name="classutil" depends="-check.asm" if="asm.exists">
    <echo level="verbose">Found ASM API. Compiling classutil classes.</echo>
    <javac srcdir="${javac.src.dir}"
           source="${javac.source}"
           debug="${javac.debug}"
           listfiles="${javac.listfiles}"
           deprecation="yes"
           destdir="${compiled.classes.dir}">

      <compilerarg compiler="jikes" value="+Peffective-java"/>
      <compilerarg compiler="jikes" value="+Punused-type-imports"/>
      <compilerarg compiler="jikes" value="+Punused-package-imports"/>
      <compilerarg compiler="jikes" value="+Pmodifier-order"/>
      <compilerarg compiler="jikes" value="+Pserial"/>

      <compilerarg compiler="javac1.5" value="${javac_lint_unchecked_opt}"/>
      <!--
      <compilerarg compiler="javac1.5" value="${javac_lint_deprecation_opt}"/>
      -->

      <classpath refid="project.class.path"/>

      <include name="${pkg.path}/classutil/*.java"/>
    </javac>
  </target>

  <!-- Load the API version from the appropriate resource bundle -->

  <target name="-get.version" description="Get the version stamp">
    <property file="${compiled.classes.dir}/org/clapper/util/misc/Bundle.properties"/>
    <echo>API Version: ${api.version}</echo>
  </target>

  <target name="version" depends="-get.version"/>

  <target name="-build.info" depends="-get.version"
          description="Create build info properties file">

    <taskdef name="make_build_info"
             classname="org.clapper.util.ant.MakeBuildInfoTask"
             classpath="${compiled.classes.dir}"/>

    <condition property="compiler" value="${build.compiler}">
      <isset property="build.compiler"/>
    </condition>

    <condition property="compiler" value="javac">
      <not>
        <isset property="build.compiler"/>
      </not>
    </condition>

    <make_build_info file="${build.info.file}"
                     antversion="${ant.version}"
                     compiler="${compiler}"/>
  </target>

  <target name="mail.testers" depends="-check.javamail,lib"
          if="javamail.exists"
          description="compile the mail testers">
    <!-- Create the distribution directory -->
    <javac srcdir="${javac.src.dir}"
           source="${javac.source}"
           debug="${javac.debug}"
           listfiles="${javac.listfiles}"
           deprecation="yes"
           destdir="${compiled.classes.dir}">

      <compilerarg compiler="jikes" value="+Peffective-java"/>
      <compilerarg compiler="jikes" value="+Punused-type-imports"/>
      <compilerarg compiler="jikes" value="+Punused-package-imports"/>
      <compilerarg compiler="jikes" value="+Pmodifier-order"/>
      <compilerarg compiler="jikes" value="+Pserial"/>

      <compilerarg compiler="javac1.5" value="${javac_lint_unchecked_opt}"/>
      <!--
      <compilerarg compiler="javac1.5" value="${javac_lint_deprecation_opt}"/>
      -->

      <classpath refid="project.class.path"/>

      <include name="${pkg.path}/mail/test/*.java"/>

    </javac>
  </target>

  <target name="lib.testers"
          description="compile the testers">
    <!-- Create the distribution directory -->
    <javac srcdir="${javac.src.dir}"
           source="${javac.source}"
           debug="${javac.debug}"
           listfiles="${javac.listfiles}"
           destdir="${compiled.classes.dir}">

      <compilerarg compiler="jikes" value="+Peffective-java"/>
      <compilerarg compiler="jikes" value="+Punused-type-imports"/>
      <compilerarg compiler="jikes" value="+Punused-package-imports"/>
      <compilerarg compiler="jikes" value="+Pmodifier-order"/>
      <compilerarg compiler="jikes" value="+Pserial"/>

      <compilerarg compiler="javac1.5" value="${javac_lint_unchecked_opt}"/>
      <!--
      <compilerarg compiler="javac1.5" value="${javac_lint_deprecation_opt}"/>
      -->

      <classpath refid="project.class.path"/>

      <include name="**/test/*.java"/>
      <exclude name="${pkg.path}/mail/test/*.java"/>

    </javac>
  </target>

  <!--
  ***************************************************************************
                              Javadoc targets
  ***************************************************************************
  -->

  <target name="doc"
          description="Generate API Javadocs">
    <mkdir dir="${javadocs.api.dir}"/>
    <javadoc
             destdir="${javadocs.api.dir}"
             sourcepath="${src.top}"
             source="${javac.source}"
             author="true"
             version="true"
             breakiterator="true"
             splitindex="true"
             use="true"
             overview="overview.html"
             excludepackagenames="org.clapper.util.*.test"
             packagenames="org.clapper.util.*"
             classpathref="project.class.path"
             windowtitle="clapper.org Utility API">
      <doctitle><![CDATA[<h1>clapper.org Utility API Documentation</h1>]]></doctitle>
      <bottom><![CDATA[<i>Copyright &#169; 2004-2006 <NAME>. All Rights Reserved.</i>]]></bottom>
    </javadoc>
  </target>

  <target name="docs" depends="doc"/>
  <target name="javadocs" depends="doc"/>
  <target name="javadoc" depends="doc"/>

  <!--
  ***************************************************************************
                             Packaging Targets
  ***************************************************************************
  -->

  <target name="-set.version.properties" depends="-get.version">
    <property name="versioned_src_zipfile"
              value="src-${api.version}.zip"/>

    <property name="versioned_code_jar_file"
              value="${code_jar_name}-${api.version}.jar"/>

    <property name="versioned_docs_zipfile"
              value="javadocs-${api.version}.zip"/>
  </target>

  <target name="code.jar" depends="all"
          description="Generate the distribution">
    <mkdir dir="${build.dir}/lib"/>
    <jar jarfile="${code_jar_path}" basedir="${compiled.classes.dir}"/>
  </target>
  <target name="build" depends="code.jar"/>

  <target name="-doczip" depends="doc"
          description="Builds the javadocs zip file">
    <mkdir dir="${release_dir}"/>
    <zip destfile="${release_dir}/${versioned_docs_zipfile}">
      <zipfileset dir="${docs_top_dir}"
                  prefix="${zip_dir_prefix}"/>
    </zip>
  </target>

  <target name="-srczip" depends=""
          description="Generate the source zip">
    <mkdir dir="${release_dir}"/>
    <zip destfile="${release_dir}/${versioned_src_zipfile}">
      <!--
          WARNING: This file set is essentially duplicated in the installer's
          config file, below. There's no way around that, unfortunately.
      -->
      <zipfileset dir="." prefix="${zip_dir_prefix}" casesensitive="yes">
        <exclude name="${build.dir}/**"/>
        <exclude name="${compiled.classes.dir}"/>
        <exclude name="**/CVS"/>
        <include name="**/*.java"/>
        <include name="**/package.html"/>
        <include name="overview.html"/>
        <include name="**/*.xml"/>
        <include name="**/*.properties"/>
      </zipfileset>
    </zip>
  </target>

  <target name="release"
          depends="build,-set.version.properties,-srczip,-doczip"
          description="Generate the distribution and source jars">
    <copy file="${code_jar_path}"
          tofile="${release_dir}/${versioned_code_jar_file}"/>
  </target>

  <!--
  ***************************************************************************
                             Installer Target
  ***************************************************************************
  -->

  <!--
      If you're going to build the installer, you'll need the IzPack
      utility (http://www.izforge.com/izpack/), and you'll have to set
      this value to the location of the IzPack installation.
  -->
  <property name="izpack.home" value="/usr/local/java/IzPack"/>
  <property name="src.install" value="${src.top}/installer"/>

  <target name="-installer.prep">

    <!-- Define the IzPack task -->

    <taskdef name="izpack" classname="com.izforge.izpack.ant.IzPackTask"
             classpathref="installer.class.path"/>

    <!-- Create a temporary installation directory -->

    <property name="install.tmp" location="${build.dir}/install"/>
    <delete dir="${install.tmp}"/>
    <mkdir dir="${install.tmp}"/>

    <!-- Edit the installer template -->

    <copy file="${src.install}/install.xml" todir="${install.tmp}">
      <filterset>
        <filter token="OCUTIL_VERSION" value="${api.version}"/>
        <filter token="INSTALL_TMP" value="${install.tmp}"/>
        <filter token="SRC_INSTALL" value="${src.install}"/>
        <filter token="RELEASE_DIR" value="${release_dir}"/>
        <filter token="THIRD_PARTY_JAR_DIR" value="${env.wwwtest}"/>
        <filter token="TOP_DIR" value="${top.dir}"/>
        <filter token="SRC_TOP" value="${src.top}"/>
        <filter token="SRC_TOP_RELATIVE" value="${src.top.relative}"/>
        <filter token="CLASSES_DIR" value="${compiled.classes.dir}"/>
        <filter token="BUILD_DIR" value="${build.dir}"/>
        <filter token="BUILD_DIR_RELATIVE" value="${build.dir.relative}"/>
        <filter token="DOCS_DIR" value="${docs.dir}"/>
        <filter token="JAVADOCS_DIR" value="${javadocs.dir}"/>
        <filter token="JAVADOCS_API_DIR" value="${javadocs.api.dir}"/>
        <filter token="VERSIONED_CODE_JAR_FILE"
                value="${versioned_code_jar_file}"/>
      </filterset>
    </copy>

    <!--
        Copy the LICENSE file and "unwrap" it so it's not wrapped weirdly
        in the installer's License GUI screen. Oddly enough, this isn't an
        issue with the README file
    -->

    <copy todir="${install.tmp}" file="LICENSE"/>

    <!-- First, replace all double newlines with "@@@@" -->
    <replace dir="${install.tmp}">
      <include name="LICENSE"/>

      <replacetoken><![CDATA[

]]></replacetoken>
      <replacevalue>@@@@</replacevalue>
    </replace>

    <!-- Next, replace single newlines with blanks -->
    <replace dir="${install.tmp}">
      <include name="LICENSE"/>

      <replacetoken><![CDATA[
]]></replacetoken>
      <replacevalue> </replacevalue>
    </replace>

    <!-- Finally, restore the double newlines -->
    <replace dir="${install.tmp}">
      <include name="LICENSE"/>
      <replacetoken>@@@@</replacetoken>
      <replacevalue><![CDATA[

]]></replacevalue>
    </replace>
  </target>

  <target name="installer"
          depends="-set.version.properties, -installer.prep">

    <!-- Build the installer -->

    <izpack input="${install.tmp}/install.xml"
            output="${release_dir}/install-ocutil.jar"
            installerType="standard"
            basedir="."
            izPackDir="${izpack.home}">
    </izpack>
  </target>

  <!--
  ***************************************************************************
                             Clean-up Targets
  ***************************************************************************
  -->

  <target name="clean"
        description="clean up" >

    <delete failonerror="false" includeEmptyDirs="true">
      <fileset dir="${build.dir}"/>
    </delete>

    <delete dir="${install.tmp}"/>
  </target>
</project>
<commit_msg>NetBeans changes.<commit_after><!--
  Ant build file for clapper.org Java utility library

  $Id$
  ===========================================================================
  This software is released under a Berkeley-style license:

  Copyright (c) 2004-2006 <NAME>. All rights reserved.

  Redistribution and use in source and binary forms are permitted provided
  that: (1) source distributions retain this entire copyright notice and
  comment; and (2) modifications made to the software are prominently
  mentioned, and a copy of the original software (or a pointer to its
  location) are included. The name of the author may not be used to endorse
  or promote products derived from this software without specific prior
  written permission.

  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

  Effectively, this means you can do what you want with the software except
  remove this notice or take advantage of the author's name. If you modify
  the software and redistribute your modified version, you must indicate that
  your version is a modification of the original, and you must provide either
  a pointer to or a copy of the original.
-->

<project name="util" default="all" basedir=".">
  <description>
    Build file for "util" Java classes
  </description>

  <!--
  ***************************************************************************
                                Properties
  ***************************************************************************
  -->

  <property environment="env"/>
  <property name="pkg.path" value="org/clapper/util"/>
  <dirname property="top.dir" file="${ant.file}"/> <!-- path to this dir -->
  <property name="src.top.relative" value="src"/>
  <property name="src.top" location="${src.top.relative}"/>
  <property name="src.dir" location="${src.top}/${pkg.path}"/>

  <!--
       <javac> uses a different source directory to prevent constant
       recompilation. See "http://ant.apache.org/faq.html#always-recompiles"
       for details.
  -->
  <property name="javac.src.dir" location="${src.top}"/>
  <property name="build.dir.relative" value="build"/>
  <property name="build.dir"  location="${build.dir.relative}"/>
  <property name="compiled.classes.dir" location="${build.dir}/classes"/>
  <property name="docs.dir" value="${top.dir}/docs"/>
  <property name="javadocs.dir" value="${build.dir}/javadocs"/>
  <property name="javadocs.api.dir" value="${javadocs.dir}/api"/>
  <property name="javac.debug" value="true"/>
  <property name="javac.listfiles" value="no"/>
  <property name="javac.source" value="1.5"/>
  <property name="javac_lint_unchecked_opt" value="-Xlint:unchecked"/>
  <property name="javac_lint_deprecation_opt" value="-Xlint:deprecation"/>
  <property name="build.info.file"
            value="${compiled.classes.dir}/org/clapper/util/misc/BuildInfoBundle.properties"/>
  <property name="code_jar_name" value="ocutil"/>
  <property name="code_jar_file" value="${code_jar_name}.jar"/>
  <property name="code_jar_path" value="${build.dir}/lib/${code_jar_file}"/>
  <property name="docs_top_dir" value="${top.dir}/docs"/>
  <property name="docs_api_dir" value="${docs_top_dir}/api"/>
  <property name="zip_dir_prefix" value="util/"/>
  <property name="release_dir" value="${build.dir}/release"/>
  <property file="build.properties"/>
  <!--
  ***************************************************************************
                            Paths and Patterns
  ***************************************************************************
  -->

  <condition property="third.party.jar.dir" value="/usr/local/java/classes">
    <not>
      <isset property="third.party.jar.dir"/>
    </not>
  </condition>

  <path id="project.class.path">
    <pathelement location="lib/"/>
    <pathelement location="${third.party.jar.dir}/activation.jar"/>
    <pathelement location="${third.party.jar.dir}/mail.jar"/>
    <pathelement location="${third.party.jar.dir}/asm-2.2.1.jar"/>
    <pathelement location="${third.party.jar.dir}/asm-commons-2.2.1.jar"/>
    <pathelement location="${third.party.jar.dir}/asm-util-2.2.1.jar"/>
    <pathelement location="${third.party.jar.dir}/commons-logging.jar"/>
    <pathelement location="${ant.home}/lib/ant.jar"/>
  </path>
  
  <path id="installer.class.path">
    <path refid="project.class.path"/>
    <pathelement location="${third.party.jar.dir}/izpack-compiler.jar"/>
  </path>

  <!--
  ***************************************************************************
                          Initialization Targets
  ***************************************************************************
  -->

  <target name="init">
    <!-- Create the time stamp -->
    <tstamp>
      <format property="build.date" pattern="dd MMMM, yyyy HH:mm:ss z"
              locale="en"/>
    </tstamp>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${compiled.classes.dir}"/>
    <depend srcdir="${src.dir}" destdir="${compiled.classes.dir}"/>
  </target>

  <!--
  ***************************************************************************
                               Code Targets
  ***************************************************************************
  -->

  <target name="all" depends="init,lib,bundles,-build.info,testers"/>

  <target name="bundles">
    <copy todir="${compiled.classes.dir}">
      <fileset dir="${src.top}">
        <include name="**/*.properties"/>
      </fileset>
    </copy>
  </target>

  <target name="testers" depends="lib,lib.testers,mail.testers"/>
  <target name="lib" depends="lib.unconditional,lib.conditional"/>

  <target name="lib.unconditional" depends="init">
    <echo>third.party.jar.dir=${third.party.jar.dir}</echo>
    <javac srcdir="${javac.src.dir}"
           source="${javac.source}"
           debug="${javac.debug}"
           listfiles="${javac.listfiles}"
           deprecation="yes"
           destdir="${compiled.classes.dir}">

      <compilerarg compiler="jikes" value="+Peffective-java"/>
      <compilerarg compiler="jikes" value="+Punused-type-imports"/>
      <compilerarg compiler="jikes" value="+Punused-package-imports"/>
      <compilerarg compiler="jikes" value="+Pmodifier-order"/>
      <compilerarg compiler="jikes" value="+Pserial"/>

      <compilerarg compiler="javac1.5" value="${javac_lint_unchecked_opt}"/>
      <!--
      <compilerarg compiler="javac1.5" value="${javac_lint_deprecation_opt}"/>
      -->

      <classpath refid="project.class.path"/>

      <include name="**/*.java"/>
      <exclude name="${pkg.path}/mail/*.java"/>
      <exclude name="${pkg.path}/classutil/*.java"/>
      <exclude name="**/test/*.java"/>

    </javac>
  </target>

  <target name="lib.conditional" depends="mail,classutil"/>

  <!--
  Can only build the "mail" component if the Java Mail API and
  the Java Activation Framework are both in the CLASSPATH
  -->

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

  <target name="-check.javamail"
          depends="-check.javamail.exists"
          unless="javamail.exists">
    <echo>
*** Ant cannot find the Java Mail API and/or the Java Activation Framework,
*** so, all components that require those packages will be skipped. To enable
*** those components, install the Java Mail API and Java Activation Framework,
*** and make them available in your CLASSPATH. Both packages can be found
*** at http://java.sun.com/
    </echo>
  </target>

  <target name="mail" depends="-check.javamail" if="javamail.exists">
    <echo level="verbose">Found Java Mail API. Compiling mail classes.</echo>
    <javac srcdir="${javac.src.dir}"
           source="${javac.source}"
           debug="${javac.debug}"
           listfiles="${javac.listfiles}"
           deprecation="yes"
           destdir="${compiled.classes.dir}">

      <compilerarg compiler="jikes" value="+Peffective-java"/>
      <compilerarg compiler="jikes" value="+Punused-type-imports"/>
      <compilerarg compiler="jikes" value="+Punused-package-imports"/>
      <compilerarg compiler="jikes" value="+Pmodifier-order"/>
      <compilerarg compiler="jikes" value="+Pserial"/>

      <compilerarg compiler="javac1.5" value="${javac_lint_unchecked_opt}"/>
      <!--
      <compilerarg compiler="javac1.5" value="${javac_lint_deprecation_opt}"/>
      -->

      <classpath refid="project.class.path"/>

      <include name="${pkg.path}/mail/*.java"/>
    </javac>
  </target>

  <!--
  Can only build the "classutil" component if the ASM API is available.
  -->

  <target name="-check.asm.exists">
    <condition property="asm.exists">
      <and>
        <available classname="org.objectweb.asm.ClassReader" classpathref="project.class.path"/>
      </and>
    </condition>
  </target>

  <target name="-check.asm"
          depends="-check.asm.exists"
          unless="asm.exists">
    <echo>
*** Ant cannot find the ASM API. All components that require the ASM API
*** will be skipped. To enable, install the ASM API, and make it available
*** in your CLASSPATH. ASM can be found at http://asm.objecweb.org/
    </echo>
  </target>

  <target name="classutil" depends="-check.asm" if="asm.exists">
    <echo level="verbose">Found ASM API. Compiling classutil classes.</echo>
    <javac srcdir="${javac.src.dir}"
           source="${javac.source}"
           debug="${javac.debug}"
           listfiles="${javac.listfiles}"
           deprecation="yes"
           destdir="${compiled.classes.dir}">

      <compilerarg compiler="jikes" value="+Peffective-java"/>
      <compilerarg compiler="jikes" value="+Punused-type-imports"/>
      <compilerarg compiler="jikes" value="+Punused-package-imports"/>
      <compilerarg compiler="jikes" value="+Pmodifier-order"/>
      <compilerarg compiler="jikes" value="+Pserial"/>

      <compilerarg compiler="javac1.5" value="${javac_lint_unchecked_opt}"/>
      <!--
      <compilerarg compiler="javac1.5" value="${javac_lint_deprecation_opt}"/>
      -->

      <classpath refid="project.class.path"/>

      <include name="${pkg.path}/classutil/*.java"/>
    </javac>
  </target>

  <!-- Load the API version from the appropriate resource bundle -->

  <target name="-get.version" description="Get the version stamp">
    <property file="${compiled.classes.dir}/org/clapper/util/misc/Bundle.properties"/>
    <echo>API Version: ${api.version}</echo>
  </target>

  <target name="version" depends="-get.version"/>

  <target name="-build.info" depends="-get.version"
          description="Create build info properties file">

    <taskdef name="make_build_info"
             classname="org.clapper.util.ant.MakeBuildInfoTask"
             classpath="${compiled.classes.dir}"/>

    <condition property="compiler" value="${build.compiler}">
      <isset property="build.compiler"/>
    </condition>

    <condition property="compiler" value="javac">
      <not>
        <isset property="build.compiler"/>
      </not>
    </condition>

    <make_build_info file="${build.info.file}"
                     antversion="${ant.version}"
                     compiler="${compiler}"/>
  </target>

  <target name="mail.testers" depends="-check.javamail,lib"
          if="javamail.exists"
          description="compile the mail testers">
    <!-- Create the distribution directory -->
    <javac srcdir="${javac.src.dir}"
           source="${javac.source}"
           debug="${javac.debug}"
           listfiles="${javac.listfiles}"
           deprecation="yes"
           destdir="${compiled.classes.dir}">

      <compilerarg compiler="jikes" value="+Peffective-java"/>
      <compilerarg compiler="jikes" value="+Punused-type-imports"/>
      <compilerarg compiler="jikes" value="+Punused-package-imports"/>
      <compilerarg compiler="jikes" value="+Pmodifier-order"/>
      <compilerarg compiler="jikes" value="+Pserial"/>

      <compilerarg compiler="javac1.5" value="${javac_lint_unchecked_opt}"/>
      <!--
      <compilerarg compiler="javac1.5" value="${javac_lint_deprecation_opt}"/>
      -->

      <classpath refid="project.class.path"/>

      <include name="${pkg.path}/mail/test/*.java"/>

    </javac>
  </target>

  <target name="lib.testers"
          description="compile the testers">
    <!-- Create the distribution directory -->
    <javac srcdir="${javac.src.dir}"
           source="${javac.source}"
           debug="${javac.debug}"
           listfiles="${javac.listfiles}"
           destdir="${compiled.classes.dir}">

      <compilerarg compiler="jikes" value="+Peffective-java"/>
      <compilerarg compiler="jikes" value="+Punused-type-imports"/>
      <compilerarg compiler="jikes" value="+Punused-package-imports"/>
      <compilerarg compiler="jikes" value="+Pmodifier-order"/>
      <compilerarg compiler="jikes" value="+Pserial"/>

      <compilerarg compiler="javac1.5" value="${javac_lint_unchecked_opt}"/>
      <!--
      <compilerarg compiler="javac1.5" value="${javac_lint_deprecation_opt}"/>
      -->

      <classpath refid="project.class.path"/>

      <include name="**/test/*.java"/>
      <exclude name="${pkg.path}/mail/test/*.java"/>

    </javac>
  </target>

  <!--
  ***************************************************************************
                              Javadoc targets
  ***************************************************************************
  -->

  <target name="doc"
          description="Generate API Javadocs">
    <mkdir dir="${javadocs.api.dir}"/>
    <javadoc
             destdir="${javadocs.api.dir}"
             sourcepath="${src.top}"
             source="${javac.source}"
             author="true"
             version="true"
             breakiterator="true"
             splitindex="true"
             use="true"
             overview="overview.html"
             excludepackagenames="org.clapper.util.*.test"
             packagenames="org.clapper.util.*"
             classpathref="project.class.path"
             windowtitle="clapper.org Utility API">
      <doctitle><![CDATA[<h1>clapper.org Utility API Documentation</h1>]]></doctitle>
      <bottom><![CDATA[<i>Copyright &#169; 2004-2006 <NAME>. All Rights Reserved.</i>]]></bottom>
    </javadoc>
  </target>

  <target name="docs" depends="doc"/>
  <target name="javadocs" depends="doc"/>
  <target name="javadoc" depends="doc"/>

  <!--
  ***************************************************************************
                             Packaging Targets
  ***************************************************************************
  -->

  <target name="-set.version.properties" depends="-get.version">
    <property name="versioned_src_zipfile"
              value="src-${api.version}.zip"/>

    <property name="versioned_code_jar_file"
              value="${code_jar_name}-${api.version}.jar"/>

    <property name="versioned_docs_zipfile"
              value="javadocs-${api.version}.zip"/>
  </target>

  <target name="code.jar" depends="all"
          description="Generate the distribution">
    <mkdir dir="${build.dir}/lib"/>
    <jar jarfile="${code_jar_path}" basedir="${compiled.classes.dir}"/>
  </target>
  <target name="build" depends="code.jar"/>

  <target name="-doczip" depends="doc"
          description="Builds the javadocs zip file">
    <mkdir dir="${release_dir}"/>
    <zip destfile="${release_dir}/${versioned_docs_zipfile}">
      <zipfileset dir="${docs_top_dir}"
                  prefix="${zip_dir_prefix}"/>
    </zip>
  </target>

  <target name="-srczip" depends=""
          description="Generate the source zip">
    <mkdir dir="${release_dir}"/>
    <zip destfile="${release_dir}/${versioned_src_zipfile}">
      <!--
          WARNING: This file set is essentially duplicated in the installer's
          config file, below. There's no way around that, unfortunately.
      -->
      <zipfileset dir="." prefix="${zip_dir_prefix}" casesensitive="yes">
        <exclude name="${build.dir}/**"/>
        <exclude name="${compiled.classes.dir}"/>
        <exclude name="**/CVS"/>
        <include name="**/*.java"/>
        <include name="**/package.html"/>
        <include name="overview.html"/>
        <include name="**/*.xml"/>
        <include name="**/*.properties"/>
      </zipfileset>
    </zip>
  </target>

  <target name="release"
          depends="build,-set.version.properties,-srczip,-doczip"
          description="Generate the distribution and source jars">
    <copy file="${code_jar_path}"
          tofile="${release_dir}/${versioned_code_jar_file}"/>
  </target>

  <!--
  ***************************************************************************
                             Installer Target
  ***************************************************************************
  -->

  <!--
      If you're going to build the installer, you'll need the IzPack
      utility (http://www.izforge.com/izpack/), and you'll have to set
      this value to the location of the IzPack installation.
  -->
  <property name="izpack.home" value="/usr/local/java/IzPack"/>
  <property name="src.install" value="${src.top}/installer"/>

  <target name="-installer.prep">

    <!-- Define the IzPack task -->

    <taskdef name="izpack" classname="com.izforge.izpack.ant.IzPackTask"
             classpathref="installer.class.path"/>

    <!-- Create a temporary installation directory -->

    <property name="install.tmp" location="${build.dir}/install"/>
    <delete dir="${install.tmp}"/>
    <mkdir dir="${install.tmp}"/>

    <!-- Edit the installer template -->

    <copy file="${src.install}/install.xml" todir="${install.tmp}">
      <filterset>
        <filter token="OCUTIL_VERSION" value="${api.version}"/>
        <filter token="INSTALL_TMP" value="${install.tmp}"/>
        <filter token="SRC_INSTALL" value="${src.install}"/>
        <filter token="RELEASE_DIR" value="${release_dir}"/>
        <filter token="THIRD_PARTY_JAR_DIR" value="${env.wwwtest}"/>
        <filter token="TOP_DIR" value="${top.dir}"/>
        <filter token="SRC_TOP" value="${src.top}"/>
        <filter token="SRC_TOP_RELATIVE" value="${src.top.relative}"/>
        <filter token="CLASSES_DIR" value="${compiled.classes.dir}"/>
        <filter token="BUILD_DIR" value="${build.dir}"/>
        <filter token="BUILD_DIR_RELATIVE" value="${build.dir.relative}"/>
        <filter token="DOCS_DIR" value="${docs.dir}"/>
        <filter token="JAVADOCS_DIR" value="${javadocs.dir}"/>
        <filter token="JAVADOCS_API_DIR" value="${javadocs.api.dir}"/>
        <filter token="VERSIONED_CODE_JAR_FILE"
                value="${versioned_code_jar_file}"/>
      </filterset>
    </copy>

    <!--
        Copy the LICENSE file and "unwrap" it so it's not wrapped weirdly
        in the installer's License GUI screen. Oddly enough, this isn't an
        issue with the README file
    -->

    <copy todir="${install.tmp}" file="LICENSE"/>

    <!-- First, replace all double newlines with "@@@@" -->
    <replace dir="${install.tmp}">
      <include name="LICENSE"/>

      <replacetoken><![CDATA[

]]></replacetoken>
      <replacevalue>@@@@</replacevalue>
    </replace>

    <!-- Next, replace single newlines with blanks -->
    <replace dir="${install.tmp}">
      <include name="LICENSE"/>

      <replacetoken><![CDATA[
]]></replacetoken>
      <replacevalue> </replacevalue>
    </replace>

    <!-- Finally, restore the double newlines -->
    <replace dir="${install.tmp}">
      <include name="LICENSE"/>
      <replacetoken>@@@@</replacetoken>
      <replacevalue><![CDATA[

]]></replacevalue>
    </replace>
  </target>

  <target name="installer"
          depends="-set.version.properties, -installer.prep">

    <!-- Build the installer -->

    <izpack input="${install.tmp}/install.xml"
            output="${release_dir}/install-ocutil.jar"
            installerType="standard"
            basedir="."
            izPackDir="${izpack.home}">
    </izpack>
  </target>

  <!--
  ***************************************************************************
                             Clean-up Targets
  ***************************************************************************
  -->

  <target name="clean"
        description="clean up" >

    <delete failonerror="false" includeEmptyDirs="true">
      <fileset dir="${build.dir}"/>
    </delete>

    <delete dir="${install.tmp}"/>
  </target>
</project>

{'fraction_non_alphanumeric': 0.22318351608627546, 'fraction_numerical': 0.00260272321966502, 'mean_word_length': 3.2420772848088326, 'pattern_counts': {'":': 0, '<': 671, '<?xml version=': 0, '>': 671, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '552230', 'n_tokens_mistral': 12031, 'n_tokens_neox': 11557, 'n_words': 2401}