<project name="Commons Combo" default="dist" basedir=".">


    <!-- $Id: build.xml,v 1.7 2003/03/31 23:09:41 craigmcc Exp $ -->


    <!--  This package does not build any new functionality of its own.     -->
    <!--  Instead, it combines specific tagged versions of all of the       -->
    <!--  packages in jakarta-commons into a single integrated JAR file,    -->
    <!--  as well as producing integrated JavaDocs for the entire suite.    -->
    <!--                                                                    -->
    <!--  Checklist for adding a new Commons package "foo":                 -->
    <!--                                                                    -->
    <!--  * Create a "commons-foo.jar" property pointing at where the       -->
    <!--    new JAR file will be created.  Include the version number       -->
    <!--    suffix if your package generates JAR files including them.      -->
    <!--                                                                    -->
    <!--  * Create a "foo.tag" property defining the CVS tag to be pulled   -->
    <!--    (normally the tag for the current released version).            -->
    <!--                                                                    -->
    <!--  * Add properties defining external dependencies as required.      -->
    <!--                                                                    -->
    <!--  * Update the "classpath" and "sourcepath" elements in the         -->
    <!--    "javadoc" target to include the new package.                    -->
    <!--                                                                    -->
    <!--  * Add a new "antcall" element to the "rebuild" target for         -->
    <!--    building the new package, taking care to maintain proper        -->
    <!--    dependency order for cross-commons-package dependencies.        -->
    <!--                                                                    -->
    <!--  Checklist for updating a Commons package version number:          -->
    <!--                                                                    -->
    <!--  * Update the filename for the "commons-foo.jar" if this           -->
    <!--    Commons package generates JAR filenames with version numbers.   -->
    <!--                                                                    -->
    <!--  * Update the "foo.tag" property to reflect the new                -->
    <!--    CVS tag to be pulled.                                           -->
    <!--                                                                    -->
    <!--  * Review the external dependency properties, and add any new      -->
    <!--    ones required by the new version.                               -->
    <!--                                                                    -->
    <!--  * Review the build order in the "rebuild" target to ensure that   -->
    <!--    cross-commons-package dependencies are still maintained.        -->
    <!--                                                                    -->



    <!-- ========== CVS Repository Properties ============================= -->

    <!-- Prior to executing this script, you must have done a "cvs login"   -->
    <!-- with the username and password for anonymous CVS access to the     -->
    <!-- Apache CVS repository, as outlined on the Jakarta web site at      -->
    <!--          http://jakarta.apache.org/site/cvsindex.html              -->

    <property name="cvs.root"
                      value=":pserver:anoncvs@cvs.apache.org:/home/cvspublic"/>
    <property name="cvs.base"
                      value="jakarta-commons"/>


    <!-- ========== Directory Path Properties ============================= -->

    <property name="combo.build.home" value="${basedir}/build"/>
    <property name="combo.dist.home"  value="${basedir}/dist"/>
    <property name="combo.build.base" value="${combo.build.home}/${cvs.base}"/>


    <!-- ========== Commons JAR Files ===================================== -->

    <!-- Whenever a new package is added, create a property defining the    -->
    <!-- path to the JAR file that will be built.  These properties are     -->
    <!-- used to ensure that all included packages are build against the    -->
    <!-- version of their dependencies that is also included.               -->

    <!-- WARNING:  Some Commons packages create JAR files with version      -->
    <!-- suffixes on the name.  Be sure you update the JAR filename when    -->
    <!-- you update the CVS tag for one of these packages.                  -->

    <property name="commons-beanutils.jar"
             value="${combo.build.base}/beanutils/dist/commons-beanutils.jar"/>
    <property name="commons-betwixt.jar"
             value="${combo.build.base}/betwixt/dist/commons-betwixt-1.0-beta-1.jar"/>
    <property name="commons-cli.jar"
             value="${combo.build.base}/cli/dist/commons-cli-1.0-beta-2-dev.jar"/>
    <property name="commons-collections.jar"
             value="${combo.build.base}/collections/dist/commons-collections.jar"/>
    <property name="commons-dbcp.jar"
             value="${combo.build.base}/dbcp/dist/commons-dbcp.jar"/>
    <property name="commons-digester.jar"
             value="${combo.build.base}/digester/dist/commons-digester.jar"/>
    <property name="commons-discovery.jar"
             value="${combo.build.base}/discovery/dist/commons-discovery.jar"/>
    <property name="commons-fileupload.jar"
             value="${combo.build.base}/fileupload/dist/commons-fileupload-1.0-dev.jar"/>
    <property name="commons-httpclient.jar"
             value="${combo.build.base}/httpclient/dist/commons-httpclient.jar"/>
    <property name="commons-jxpath.jar"
             value="${combo.build.base}/jxpath/dist/commons-jxpath.jar"/>
    <property name="commons-lang.jar"
             value="${combo.build.base}/lang/dist/commons-lang-1.0.1.jar"/>
    <property name="commons-latka.jar"
             value="${combo.build.base}/latka/dist/commons-latka.jar"/>
    <property name="commons-logging.jar"
             value="${combo.build.base}/logging/dist/commons-logging.jar"/>
    <property name="commons-modeler.jar"
             value="${combo.build.base}/modeler/dist/commons-modeler.jar"/>
    <property name="commons-net.jar"
             value="${combo.build.base}/net/dist/commons-net-1.0.0-dev.jar"/>
    <property name="commons-pool.jar"
             value="${combo.build.base}/pool/dist/commons-pool.jar"/>
    <property name="commons-validator.jar"
             value="${combo.build.base}/validator/dist/commons-validator.jar"/>


    <!-- ========== Initialize Properties ================================= -->

    <!-- This section must appear AFTER the property settings for the       -->
    <!-- Commons JAR files in order for the local settings to override      -->
    <!-- whatever the user might have otherwise specified.                  -->

    <property file="build.properties"/>                <!-- Component local -->
    <property file="../build.properties"/>             <!-- Commons local   -->
    <property file="${user.home}/build.properties"/>   <!-- User local      -->


    <!-- ========== Package Version Tags ================================== -->

    <!-- Specify the CVS tag to pull for each included package, or use a    -->
    <!-- zero-length string to specify the HEAD branch.  Add a new property -->
    <!-- for each package that is added to the combo.                       -->

    <!-- WARNING:  Some Commons packages create JAR files with version      -->
    <!-- suffixes on the name.  Be sure you update the JAR name properties  -->
    <!-- (above) when you update the CVS tag for one of these pacakges.     -->

    <property name="beanutils.tag"      value="BEANUTILS_1_6_1"/>
    <property name="betwixt.tag"        value="BETWIXT_1_0_ALPHA_1"/> <!-- FIXME: release it -->
    <property name="cli.tag"            value="CLI_1_0"/>
    <property name="collections.tag"    value="COLLECTIONS_2_1"/>
    <property name="dbcp.tag"           value="DBCP_1_0"/>
    <property name="digester.tag"       value="DIGESTER_1_4_1"/>
    <property name="discovery.tag"      value="DISCOVERY_0_1"/>
    <property name="fileupload.tag"      value="FILEUPLOAD_1_0_B1"/> <!-- FIXME: release it -->
    <property name="httpclient.tag"     value="HTTPCLIENT_1_0"/>
    <property name="jxpath.tag"         value="JXPATH_1_1"/>
    <property name="lang.tag"           value="LANG_1_0_1"/>
    <property name="latka.tag"          value="LATKA-1-0-alpha1"/>
    <property name="logging.tag"        value="LOGGING_1_0_2"/>
    <property name="modeler.tag"        value="MODELER_1_0"/>
    <property name="net.tag"            value="NET_1_0_0"/>
    <property name="pool.tag"           value="POOL_1_0_1"/>
    <property name="validator.tag"      value="VALIDATOR_1_0_1"/>


    <!-- ========== External Dependencies ================================= -->

    <!-- These properties point at JAR files for external dependencies.     -->
    <!-- The values actually used may be overridden with your local         -->
    <!-- "build.properties" file settings.                                  -->

    <property name="jdbc20ext.jar"      value="/classes/jdbc2_0-stdext.jar"/>
    <property name="jmx.jar"            value="/usr/local/mx4j-1.0b3/lib/mx4j.jar"/>
    <property name="junit.jar"          value="/usr/local/junit3.7/junit.jar"/>
    <property name="oro.jar"            value="/usr/local/jakarta-oro-2.0.7/jakarta-oro-2.0.7.jar"/>


    <!-- ========== Primary Processing Targets ============================ -->


    <!-- Clean out all destination directories.                             -->

    <target name="clean" description="Clean out all destination directories">

        <delete     dir="${combo.build.home}"/>
        <delete     dir="${combo.dist.home}"/>

    </target>


    <!-- Overall default build target.                                      -->

    <target name="dist" depends="clean,rebuild,jar,javadoc"
     description="Create consolidated commons-combo.jar and documentation"/>


    <!-- Build the combination JAR file -->

    <target name="jar" description="Build combination JAR file">

        <delete    file="${combo.dist.home}/commons-combo.jar"/>
        <!-- FIXME - need to build a consolidated manifest file -->
        <jar    jarfile="${combo.dist.home}/commons-combo.jar"
                basedir="${combo.build.home}/classes"
               excludes="META-INF/**"/>

    </target>


    <!-- Whenever a new package is added, insert the appropriate entries    -->
    <!-- in the classpath and sourcepath elements.                          -->

    <target name="javadoc"
     description="Create integrated JavaDocs">

        <javadoc
                      author="true"
                      bottom="Copyright (c) 2002-2003, Apache Software Foundation"
                     destdir="${combo.dist.home}/docs/api"
                    doctitle="&lt;h1&gt;Apache Commons Packages - Combo API&lt;/h1&gt;"
                packagenames="org.apache.commons.*"
                     private="true"
                  splitindex="true"
                         use="true"
                     version="true"
                 windowtitle="Apache Commons Packages - Combo API"
>
            <classpath>
                <pathelement location="${commons-beanutils.jar}"/>
                <pathelement location="${commons-betwixt.jar}"/>
                <pathelement location="${commons-cli.jar}"/>
                <pathelement location="${commons-collections.jar}"/>
                <pathelement location="${commons-dbcp.jar}"/>
                <pathelement location="${commons-digester.jar}"/>
                <pathelement location="${commons-discovery.jar}"/>
                <pathelement location="${commons-fileupload.jar}"/>
                <pathelement location="${commons-httpclient.jar}"/>
                <pathelement location="${commons-jxpath.jar}"/>
                <pathelement location="${commons-lang.jar}"/>
<!--
                <pathelement location="${commons-latka.jar}"/>
-->
                <pathelement location="${commons-logging.jar}"/>
                <pathelement location="${commons-modeler.jar}"/>
                <pathelement location="${commons-net.jar}"/>
                <pathelement location="${commons-pool.jar}"/>
                <pathelement location="${commons-validator.jar}"/>
            </classpath>
            <sourcepath>
                <pathelement location="${combo.build.base}/beanutils/src/java"/>
                <pathelement location="${combo.build.base}/betwixt/src/java"/>
                <pathelement location="${combo.build.base}/cli/src/java"/>
                <pathelement location="${combo.build.base}/collections/src/java"/>
                <pathelement location="${combo.build.base}/dbcp/src/java"/>
                <pathelement location="${combo.build.base}/digester/src/java"/>
                <pathelement location="${combo.build.base}/discovery/src/java"/>
                <pathelement location="${combo.build.base}/fileupload/src/java"/>
                <pathelement location="${combo.build.base}/httpclient/src/java"/>
                <pathelement location="${combo.build.base}/jxpath/src/java"/>
                <pathelement location="${combo.build.base}/lang/src/java"/>
<!--
                <pathelement location="${combo.build.base}/latka/src/java"/>
-->
                <pathelement location="${combo.build.base}/logging/src/java"/>
                <pathelement location="${combo.build.base}/modeler/src/java"/>
                <pathelement location="${combo.build.base}/net/src/java"/>
                <pathelement location="${combo.build.base}/pool/src/java"/>
                <pathelement location="${combo.build.base}/validator/src/share"/>
            </sourcepath>
        </javadoc>

    </target>


    <!-- Prepare directories for processing.                                -->

    <target name="prepare" description="Prepare directories for processing">

        <mkdir      dir="${combo.build.home}"/>
        <mkdir      dir="${combo.build.home}/classes"/>
<!--
        <mkdir      dir="${combo.build.home}/${cvs.base}"/>
        <copy    tofile="${combo.build.home}/${cvs.base}/LICENSE"
                   file="LICENSE.txt"/>
-->
        <mkdir      dir="${combo.dist.home}"/>
        <mkdir      dir="${combo.dist.home}/docs"/>
        <mkdir      dir="${combo.dist.home}/docs/api"/>

    </target>


    <!-- Whenever a new package is added, insert a new antcall element to   -->
    <!-- check out and build the new package.  These elements MUST respect  -->
    <!-- the dependency order of the commons packages themselves.           -->

    <target name="rebuild" depends="prepare"
     description="Check out and rebuild all included packages">

        <antcall target="package">
            <param name="jar"     value="${commons-net.jar}"/>
            <param name="package" value="net"/>
            <param name="tag"     value="${net.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-logging.jar}"/>
            <param name="package" value="logging"/>
            <param name="tag"     value="${logging.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-discovery.jar}"/>
            <param name="package" value="discovery"/>
            <param name="tag"     value="${discovery.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-collections.jar}"/>
            <param name="package" value="collections"/>
            <param name="tag"     value="${collections.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-lang.jar}"/>
            <param name="package" value="lang"/>
            <param name="tag"     value="${lang.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-beanutils.jar}"/>
            <param name="package" value="beanutils"/>
            <param name="tag"     value="${beanutils.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-cli.jar}"/>
            <param name="package" value="cli"/>
            <param name="tag"     value="${cli.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-digester.jar}"/>
            <param name="package" value="digester"/>
            <param name="tag"     value="${digester.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-httpclient.jar}"/>
            <param name="package" value="httpclient"/>
            <param name="tag"     value="${httpclient.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-jxpath.jar}"/>
            <param name="package" value="jxpath"/>
            <param name="tag"     value="${jxpath.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-modeler.jar}"/>
            <param name="package" value="modeler"/>
            <param name="tag"     value="${modeler.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-pool.jar}"/>
            <param name="package" value="pool"/>
            <param name="tag"     value="${pool.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-validator.jar}"/>
            <param name="package" value="validator"/>
            <param name="tag"     value="${validator.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-betwixt.jar}"/>
            <param name="package" value="betwixt"/>
            <param name="tag"     value="${betwixt.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-dbcp.jar}"/>
            <param name="package" value="dbcp"/>
            <param name="tag"     value="${dbcp.tag}"/>
        </antcall>

        <antcall target="package">
            <param name="jar"     value="${commons-fileupload.jar}"/>
            <param name="package" value="fileupload"/>
            <param name="tag"     value="${fileupload.tag}"/>
        </antcall>

<!-- FIXME - build failures
        <antcall target="package">
            <param name="jar"     value="${commons-latka.jar}"/>
            <param name="package" value="latka"/>
            <param name="tag"     value="${latka.tag}"/>
        </antcall>
-->

    </target>


    <!-- ========== Called Subroutines ==================================== -->


    <!-- All-in-one target to process the Commons package specified by      -->
    <!-- the "package" property.                                            -->

    <target name="package"
         depends="package.clean,package.checkout,package.build,package.unpack"/>



    <!-- Call the "dist" target of the specified package to build it.       -->

    <target name="package.build">
        <ant      dir="${combo.build.base}/${package}" target="dist"/>
    </target>


    <!-- Clean out the package directory for the specified package.         -->
    <target name="package.clean">
        <delete   dir="${combo.build.base}/${package}"/>
    </target>


    <!-- Perform CVS checkout or update of the package specified by the     -->
    <!-- "package" property, using the tag specified by the "tag" property. -->

    <target name="package.checkout">
        <echo message="Checking out package ${package} with tag ${tag}"/>
        <cvs  cvsRoot="${cvs.root}"        command="checkout"
              package="${cvs.base}/${package}" tag="${tag}"
                 dest="${combo.build.home}"/>
        <copy    tofile="${combo.build.home}/${cvs.base}/LICENSE"
                   file="LICENSE.txt"/>
    </target>


    <!-- Unpack JAR file specified by the "jar" property into the           -->
    <!-- consolidated classes directory.                                    -->

    <target name="package.unpack">
        <unjar    src="${jar}"
                 dest="${combo.build.home}/classes"/>
    </target>


</project>
