<?xml version="1.0"?>

<!DOCTYPE book [

<!-- default sources -->
<!ENTITY % ent._shared SYSTEM "../_shared/_shared.ant-ent.xml">
%ent._shared;
]>



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

    <!-- Property Defines -->
    <property name="product" value="GroboUtils" />
    <property name="version" value="5" />
    
    
    &inc._shared;
    
    <!-- replace default properties and tasks -->
    &inc._shared.common-ant-replace;
    
    &inc._shared.common-ant-tasks-init;
    &inc._shared.common-ant-tasks-clean;
    &inc._shared.common-ant-tasks-javac;
    &inc._shared.common-ant-tasks-jar;
    &inc._shared.common-ant-tasks-doc;
    &inc._shared.common-ant-tasks-jdkdepend;
<!--
    &inc._shared.common-ant-tasks-test;
    &inc._shared.common-ant-tasks-deploy;
-->


    
    
    <property name="dirs.tmp" value="${basedir}/tmp" />
    <property name="dirs.deploy.website" value="${dirs.deploy}/website" />
    <property name="tmp.include-jar" value="deploy/*/lib/*-core.jar" />
    
    <!-- include every 3rd party library -->
    <path id="classpath.base">
        <pathelement location="${libs.log4j.current}" />
        <pathelement location="${libs.junit.current}" />
        <pathelement location="${libs.easymock.current}" />
        <pathelement location="${libs.mockobjects.current.core}" />
        <pathelement location="${libs.ant.current.core}" />
        <pathelement location="${libs.bcel.current}" />
        <pathelement location="${libs.sax.current}" />
        <pathelement location="${libs.xalan.current}" />
        <pathelement location="${libs.xalan.current.xmlapi}" />
        <pathelement location="${libs.xerces.current.impl}" />
        <pathelement location="${libs.xerces.current.api}" />
        <pathelement location="${libs.xml4j.current}" />
        <pathelement location="${libs.xml4j.current}" />
    </path>
    
    
    
    <!-- ****************************************************************** -->
    
    <!-- Targets -->

    <target name="all" depends="init,clean,deploy" />
    <target name="main">
        <!-- this target does nothing -->
    </target>

    <target name="deploy" depends="init,dirs,getprojects,assemble,output" />
    <target name="init" depends="_shared.common.init" />
    <target name="clean" depends="_shared.common.clean" >
        <delete dir="${dirs.tmp}" failonerror="false" />
    </target>
    
    <!-- ****************************************************************** -->
    
    
    <target name="dirs" depends="init">
        <mkdir dir="${dirs.deploy-base}" />
        <mkdir dir="${dirs.deploy}" />
        
        <mkdir dir="${dirs.deploy.lib}" />
        
        <mkdir dir="${dirs.deploy.docs}" />
        <mkdir dir="${dirs.deploy.api-docs}" />
        
        <mkdir dir="${dirs.deploy.website}" />
    </target>
    
    
    <target name="getprojects" depends="init,dirs">
        <!-- always clean out the temporary directory -->
        <delete dir="${dirs.tmp}" failonerror="false" />
        <mkdir dir="${dirs.tmp}" />
        

        <!-- copy source files for easier documentation generation -->
        <mkdir dir="${dirs.tmp}/src" />
        <copy todir="${dirs.tmp}/src">
            <!-- for JavaDoc reasons, don't just include Java files. -->
            <fileset dir="${basedir}/..">
                <include name="*/sources/dev/**" />
                
                <!-- exclude the non-source projects -->
                <exclude name="_projects/**" />
                <exclude name="_shared/**" />
                <exclude name="website/**" />
                
                <!-- exclude the unsupported projects -->
                <exclude name="eventbus/**" />
                <exclude name="gui/**" />
                <exclude name="jplugin/**" />
                <exclude name="testing-mbtf/**" />
                <exclude name="tmp/**" />
                <exclude name="util-jdi/**" />
                <exclude name="util-states/**" />
                <exclude name="xml-resource/**" />
                <exclude name="xml-xdstates/**" />
            </fileset>
<!--                from=".*/sources/dev/(.*)\.java$$"
                to="\1\.java" />
 -->
            <mapper type="regexp"
                from="^[^\/\\]*[\/\\]sources[\/\\]dev[\/\\](.*)$$"
                to="\1" />
        </copy>
        
        
        <!--
        Get generated JAR files for all subproject
        
        Let's hope that none of the unsupported projects contain any of these
        files.
        -->
        <mkdir dir="${dirs.deploy.lib}/core" />
        <copy todir="${dirs.deploy.lib}/core" flatten="true">
            <fileset dir="${basedir}/..">
                <!-- the core jar files can take on many naming convensions,
                but will not match the testing format. -->
                <include name="*/deploy/*/lib/*.jar" />
                <exclude name="**/*-*tests.jar" />
            </fileset>
        </copy>
        
        <mkdir dir="${dirs.deploy.lib}/eutests" />
        <copy todir="${dirs.deploy.lib}/eutests" flatten="true">
            <fileset dir="${basedir}/..">
                <include name="*/deploy/*/lib/*-eutests.jar" />
            </fileset>
        </copy>
        
        <mkdir dir="${dirs.deploy.lib}/utests" />
        <copy todir="${dirs.deploy.lib}/utests" flatten="true">
            <fileset dir="${basedir}/..">
                <include name="*/deploy/*/lib/*-utests.jar" />
            </fileset>
        </copy>
        
        <mkdir dir="${dirs.deploy.lib}/iutests" />
        <copy todir="${dirs.deploy.lib}/iutests" flatten="true">
            <fileset dir="${basedir}/..">
                <include name="*/deploy/*/lib/*-iutests.jar" />
            </fileset>
        </copy>
        
        <mkdir dir="${dirs.deploy.lib}/aitests" />
        <copy todir="${dirs.deploy.lib}/aitests" flatten="true">
            <fileset dir="${basedir}/..">
                <include name="*/deploy/*/lib/*-aitests.jar" />
            </fileset>
        </copy>

    </target>
    
    
    <target name="assemble" depends="getprojects, assemble.docs,
        assemble.jars, assemble.src, assemble.commons, assemble.website" />
    
    
<!--
    <target name="assemble.jars" depends="getprojects, assemble.docs">
-->
    <target name="assemble.jars" depends="getprojects" >
        <jar jarfile="${output.jar-name.dev}" compress="true"
                duplicate="preserve" >
            <zipgroupfileset dir="${dirs.deploy.lib}/core"
                includes="*.jar" />
        </jar>
        <jar jarfile="${output.jar-name.eut}" compress="true"
                duplicate="preserve" >
            <zipgroupfileset dir="${dirs.deploy.lib}/eutests"
                includes="*.jar" />
        </jar>
        <jar jarfile="${output.jar-name.ut}" compress="true"
                duplicate="preserve" >
            <zipgroupfileset dir="${dirs.deploy.lib}/utests"
                includes="*.jar" />
        </jar>
        <jar jarfile="${output.jar-name.iut}" compress="true"
                duplicate="preserve" >
            <zipgroupfileset dir="${dirs.deploy.lib}/iutests"
                includes="*.jar" />
        </jar>
        <jar jarfile="${output.jar-name.ait}" compress="true"
                duplicate="preserve" >
            <zipgroupfileset dir="${dirs.deploy.lib}/aitests"
                includes="*.jar" />
        </jar>
        
        
        <zip destfile="${dirs.deploy-base}/${product}-${version}-jars.zip"
                compress="false" whenempty="fail" duplicate="fail">
            <fileset dir="${dirs.deploy.lib}">
                <include name="*/*.jar" />
            </fileset>
        </zip>
    </target>
    
    <target name="assemble.src">
        
        <!-- Source zip file will contain EVERYTHING needed to build!
        ... but not 3rd party libraries - allow those for separate download.
        ... and don't include the javadoc zip files - those are available
            through a separate download already.
        -->
        <zip destfile="${output.src-zip}">
            <fileset dir="${basedir}/.." >
                <exclude name="*/CVS/**" />
                <exclude name="*/CVS" />
                <exclude name="**/CVS/**" />
                <exclude name="**/CVS" />
                <exclude name="*/work/**" />
                <exclude name="*/work" />
                <exclude name="*/deploy/**" />
                <exclude name="*/deploy" />
                <exclude name="*/*.jar" />
                <exclude name="${output.src-zip}" />
                <exclude name="website/out/**" />
                <exclude name="website/out" />
                <exclude name="*/tmp/**" />
                <exclude name="*/tmp" />
                
                <exclude name="_shared/3rdparty/**/*.jar" />
                <exclude name="_shared/3rdparty/**/*.zip" />
                
                <exclude name="website/import/javadoc/*.zip" />
            </fileset>
        </zip>
        
        <!-- also do a tar-ball for compactness -->
        <tar tarfile="${dirs.tmp}/${product}-${version}-src.tar"
            basedir="${basedir}/.."
            longfile="gnu" >
                <exclude name="*/CVS/**" />
                <exclude name="*/CVS" />
                <exclude name="**/CVS/**" />
                <exclude name="**/CVS" />
                <exclude name="*/deploy/**" />
                <exclude name="*/deploy" />
                <exclude name="*/work/**" />
                <exclude name="*/work" />
                <exclude name="*/*.jar" />
                <exclude name="website/out/**" />
                <exclude name="website/out" />
                <exclude name="*/tmp/**" />
                <exclude name="*/tmp" />
                
                <exclude name="_shared/3rdparty/**/*.jar" />
                <exclude name="_shared/3rdparty/**/*.zip" />
                <exclude name="_shared/3rdparty/**/.tmp/**" />
                <exclude name="_shared/3rdparty/**/.tmp" />
                
                <exclude name="website/import/javadoc/*.zip" />
        </tar>
        <gzip zipfile="${dirs.deploy-base}/${product}-${version}-src.tar.gz"
            src="${dirs.tmp}/${product}-${version}-src.tar" />
        
        <!-- also do a bzip2 file -->
        <bzip2 zipfile="${dirs.deploy-base}/${product}-${version}-src.tar.bz2"
            src="${dirs.tmp}/${product}-${version}-src.tar" />
        
        <!-- no need to keep the tar file around -->
        <delete file="${dirs.tmp}/${product}-${version}-src.tar" />
        
        <!-- now, create the 3rd party package -->
        <tar tarfile="${dirs.tmp}/${product}-${version}-3rdparty.tar"
            basedir="${basedir}/.."
            longfile="gnu" >
                <!-- include all zip and jar files, as well as licenses
                and readme files.  That means include everything except
                for our specific files. -->
                <include name="_shared/3rdparty/**/*" />
                <exclude name="_shared/3rdparty/**/*.ant-inc.xml" />
                <exclude name="_shared/3rdparty/**/*.ant-ent.xml" />
                <exclude name="_shared/3rdparty/**/package-list" />
                <exclude name="_shared/3rdparty/jdk/*/package-list.*" />
                <exclude name="_shared/3rdparty/**/CVS/*" />
                <exclude name="_shared/3rdparty/**/.tmp/**" />
                <exclude name="_shared/3rdparty/**/.tmp" />
        </tar>
        <gzip zipfile="${dirs.deploy-base}/${product}-${version}-3rdparty.tar.gz"
            src="${dirs.tmp}/${product}-${version}-3rdparty.tar" />
        <delete file="${dirs.tmp}/${product}-${version}-3rdparty.tar" />

        <!-- the tar.gz file is about 3/4 the size of the zip file -->
        <copy file="${dirs.deploy-base}/${product}-${version}-src.tar.gz"
            tofile="${dirs.deploy}/site-src.tar.gz" />
        
        <!-- test output - someone may want it.
        <zip destfile="${dirs.deploy}/test-out.zip" >
            <fileset dir="${basedir}/.." >
                <include name="*/work/test-out/*.xml" />
                <include name="*/work/coverage/*.xml" />
                <include name="*/work/*.html" />
            </fileset>
        </zip>
        -->
    </target>
    
    
    <!-- Create JAR files of the most common bundles -->
    <target name="assemble.commons" depends="dirs, getprojects,
        assemble.commons.autodoc">
    </target>
    
    
    <target name="assemble.commons.autodoc" depends="dirs, getprojects">
        <jar duplicate="preserve"
            jarfile="${_shared.common.dirs.deploy-base}/GroboAutodoc-${version}.jar"
            compress="true" >
            <zipgroupfileset
                dir="${basedir}/.."
                excludes="_shared/**"
                includes="
                    testing-autodoc/${tmp.include-jar},
                    testing-tp/${tmp.include-jar},
                    pmti/${tmp.include-jar},
                    util-xml/${tmp.include-jar},
                    util-classes/${tmp.include-jar}" />
        </jar>
    </target>
    
    
    <target name="assemble.docs" depends="dirs, getprojects">
        <!-- make the javadoc of EVERYTHING -->
        <javadoc sourcepath="${dirs.tmp}/src"
            destdir="${dirs.deploy.api-docs}"
            Version="true"
            Use="true"
            Author="true"
            Windowtitle="${product}"
            Doctitle="${product} API"
            bottom="&lt;i&gt;Copyright &amp;copy; 2001-2003 by The GroboUtils Project&lt;/i&gt;"
            serialwarn="true"
        >
            <packageset dir="${dirs.tmp}/src">
                <exclude name="**/doc-files/**" />
                <exclude name="**/CVS/**" />
            </packageset>
            
            <classpath>
                <path refid="classpath.base" />
                <path refid="classpath.bootstrap" />
            </classpath>
            
            <!-- Customize: set the libraries for links here -->
            &inc.javadoc.ant.1_6beta;
            &inc.javadoc.bcel.5_1;
            &inc.javadoc.easymock.0_8;
            &inc.javadoc.jdk.1_4;
            &inc.javadoc.junit.3_8_1;
            &inc.javadoc.log4j.1_2_8;
            &inc.javadoc.mockobjects.0_4rc1;
            &inc.javadoc.sax.2_0_1;
            &inc.javadoc.xalan.2_5_1;
            &inc.javadoc.xerces.2_4_0;
        </javadoc>
        
        <zip zipfile="${output.doc-zip}" basedir="${dirs.deploy.docs}"
            compress="true" whenempty="fail" />
    </target>
    
    

<!--
    <target name="assemble.website" depends="assemble.docs">
-->
    <target name="assemble.website" >
        <!-- assemble everything for easy uploading to the website -->
        <mkdir dir="${dirs.deploy.website}/docs" />
        <mkdir dir="${dirs.deploy.website}/docs/projects" />
        
        <copy todir="${dirs.deploy.website}">
            <fileset dir="${basedir}/../website/out" />
        </copy>
        
        <mkdir dir="${dirs.deploy.website}/docs/projects/${version}" />
        <copy todir="${dirs.deploy.website}/docs/projects/${version}">
            <fileset dir="${dirs.deploy.docs}" />
        </copy>
        
        <!-- Create the CHANGES.TXT file for the whole site -->
        <loadfile property="changes.project"
            srcfile="${basedir}/../CHANGES.TXT" />
        <loadfile property="changes.codecoverage"
            srcfile="${basedir}/../codecoverage/CHANGES.TXT" />
        <loadfile property="changes.pmti"
            srcfile="${basedir}/../pmti/CHANGES.TXT" />
        <loadfile property="changes.testing-autodoc"
            srcfile="${basedir}/../testing-autodoc/CHANGES.TXT" />
        <loadfile property="changes.testing-junit"
            srcfile="${basedir}/../testing-junit/CHANGES.TXT" />
        <loadfile property="changes.testing-mbtf"
            srcfile="${basedir}/../testing-mbtf/CHANGES.TXT" />
        <loadfile property="changes.testing-tp"
            srcfile="${basedir}/../testing-tp/CHANGES.TXT" />
        <loadfile property="changes.uicapture"
            srcfile="${basedir}/../uicapture/CHANGES.TXT" />
        <loadfile property="changes.util-classes"
            srcfile="${basedir}/../util-classes/CHANGES.TXT" />
        <loadfile property="changes.util-datastruct"
            srcfile="${basedir}/../util-datastruct/CHANGES.TXT" />
        <loadfile property="changes.util-io"
            srcfile="${basedir}/../util-io/CHANGES.TXT" />
        <loadfile property="changes.util-states"
            srcfile="${basedir}/../util-states/CHANGES.TXT" />
        <loadfile property="changes.util-thread"
            srcfile="${basedir}/../util-thread/CHANGES.TXT" />
        <loadfile property="changes.util-xml"
            srcfile="${basedir}/../util-xml/CHANGES.TXT" />
            
        <echo file="${dirs.deploy.website}/CHANGES.TXT">
---------------------------------------------------------------------
GroboUtils Project:
${changes.project}

---------------------------------------------------------------------
GroboTestingJUnit:
${changes.testing-junit}

---------------------------------------------------------------------
GroboUtilClasses:
${changes.util-classes}

---------------------------------------------------------------------
GroboTestingAutodoc:
${changes.testing-autodoc}

---------------------------------------------------------------------
GroboUtilXML:
${changes.util-xml}

---------------------------------------------------------------------
GroboPMTI:
${changes.pmti}

---------------------------------------------------------------------
GroboTestingTP:
${changes.testing-tp}

---------------------------------------------------------------------
GroboUtilIO:
${changes.util-io}

---------------------------------------------------------------------
GroboUtilDatastruct:
${changes.util-datastruct}

---------------------------------------------------------------------
GroboCodeCoverage:
${changes.codecoverage}

---------------------------------------------------------------------
GroboUICapture:
${changes.uicapture}

---------------------------------------------------------------------
GroboUtilThread:
${changes.util-thread}
</echo>

        <echo>
    *** Not done yet ***
        </echo>
    </target>
    

    <target name="output">
        <!-- assemble everything for easy uploading to SourceForge files -->
        <copy todir="${dirs.deploy-base}" flatten="true">
            <fileset dir="${dirs.deploy.lib}/core" />
            <fileset dir="${dirs.deploy.lib}">
                <include name="*-core.jar" />
            </fileset>
            
            <fileset dir="${basedir}/..">
                <include name="*/deploy/*.zip" />
                <exclude name="*/deploy/*-src.zip" />
                <exclude name="*/deploy/*-doc.zip" />
            </fileset>
        </copy>

        
        <zip zipfile="${dirs.deploy-base}/${product}-${version}-website.zip"
            basedir="${dirs.deploy.website}"
            compress="true" whenempty="skip" />
        
        
        <!-- Create the code coverage file -->
        <zip zipfile="${dirs.deploy-base}/${product}-${version}-codecoverage.zip"
                compress="true">
            <fileset dir="${dirs.deploy-base}">
                <include name="GroboCodeCoverage-*-ant.jar" />
                <include name="GroboCodeCoverage-*-runtime.jar" />
                <include name="CHANGES.TXT" />
            </fileset>
            <zipfileset dir="${basedir}/../codecoverage/work/reg-docs" prefix="docs" />
            <fileset dir="${basedir}/../codecoverage/sources">
                <include name="example*/**" />
                <exclude name="*/CVS**" />
            </fileset>
            <fileset dir="${basedir}/../_shared/license">
                <include name="COPYING.txt" />
                <include name="NOTICE" />
            </fileset>
        </zip>
        
        
        <!-- create the complete deploy file -->
        <zip zipfile="${dirs.deploy-base}/${product}-${version}.zip"
            compress="true" >
            <fileset dir="${dirs.deploy-base}">
                <include name="${product}-${version}/**" />
                <exclude name="*/website" />
                <exclude name="*/website/**" />
                <exclude name="*/test-out.zip" />
            </fileset>
        </zip>
        <tar tarfile="${dirs.tmp}/${product}-${version}.tar"
            basedir="${dirs.deploy-base}"
            longfile="gnu" >
                <include name="${product}-${version}/**" />
                <exclude name="*/website" />
                <exclude name="*/website/**" />
                <exclude name="*/test-out.zip" />
        </tar>
        <gzip zipfile="${dirs.deploy-base}/${product}-${version}.tar.gz"
            src="${dirs.tmp}/${product}-${version}.tar" />
        
        <!-- also do a bzip2 file -->
        <bzip2 zipfile="${dirs.deploy-base}/${product}-${version}.tar.bz2"
            src="${dirs.tmp}/${product}-${version}.tar" />
        
        <!-- no need to keep the tar file around -->
        <delete file="${dirs.tmp}/${product}-${version}.tar" />
        
        <!-- clean up the temporary directory -->
        <delete dir="${dirs.tmp}" />
    </target>
    
</project>
