<?xml version="1.0" encoding="iso-8859-1"?>
<!--
$Id: build.xml,v 1.12 2002/06/09 19:02:23 kevem Exp $
This file is part of jxDBCon: http://jxdbcon.sourceforge.net

Copyright (c) 2002 Keve Müller

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


jxDBCon is hosted by SourceForge.
SourceForge is a trademark of VA Linux Systems, Inc.
-->
<project name="jx" default="help" basedir=".">
  <!-- user override -->
  <property file="${user.home}/.jx.properties.${ant.java.version}"/>
  <property file="${user.home}/.jx.properties" />

  <property name="jxUtil.version" value="0.6"/>
  <property name="jxDBCon.version" value="0.9z"/>

  <property name="stage.dir" value="stage"/>

  <property name="cvsuser" value="${user.name}"/>
  <property name="cvsroot.jxUtil.Pro"
      value=":ext:${cvsuser}@cvs.jxutil.sourceforge.net:/cvsroot/jxutil"/>
  <property name="cvsroot.jxUtil"
      value=":pserver:anonymous@cvs.jxutil.sourceforge.net:/cvsroot/jxutil"/>
  <property name="cvsroot.jxDBCon.Pro"
      value=":ext:${cvsuser}@cvs.jxdbcon.sourceforge.net:/cvsroot/jxdbcon"/>
  <property name="cvsroot.jxDBCon"
      value=":pserver:anonymous@cvs.jxdbcon.sourceforge.net:/cvsroot/jxdbcon"/>

  <property name="prereq.log4j-JAR" value="jxUtil/lib/log4j.jar"/>
  <property name="prereq.junit-JAR" value="jxUtil/lib/junit.jar"/>
  <property name="prereq.daedalos-JAR" value="jxUtil/lib/junitextensions.jar"/>
  <property name="prereq.jsse-DIR" value="jxUtil/lib/"/>

  <path id="cp">
    <pathelement location="${prereq.log4j-JAR}"/>
    <pathelement location="${prereq.junit-JAR}"/>
    <pathelement location="${prereq.daedalos-JAR}"/>
    <fileset dir="${prereq.jsse-DIR}">
      <include name="**/jcert.jar"/>
      <include name="**/jnet.jar"/>
      <include name="**/jsse.jar"/>
    </fileset>
  </path>

  <target name="help">
    <echo><![CDATA[
This is the top-level Ant buildfile $Revision: 1.12 $ for jxDBCon & jxUtil.
This file helps you to build a complete environment for compiling jxDBCon.
It can:
* fetch the prerequisites for you
* fetch the sources

You may choose between three ways to fetch the sources:
* get.jxDBCon - get the source distribution from the download area
* checkout.jxDBCon - checkout anonymously from CVS
* checkout.jxDBCon.Pro - checkout with user name from CVS

Please read more about this on the project's homepage:
http://jxdbcon.sourceforge.net/developers
]]></echo>
  </target>

  <target name="prepare">
    <echo message="This is toplevel build.xml $Revision: 1.12 $"/>
    <delete dir="jxUtil"/>
    <delete dir="jxDBCon"/>
    <mkdir dir="jxUtil"/>
    <mkdir dir="jxUtil/lib"/>
    <mkdir dir="jxDBCon"/>
  </target>

  <target name="prereq">
    <!--
    -->
    <available classname="junit.framework.TestCase" property="have.JUnit"
        classpathref="cp"/>
    <available classname="com.daedalos.junit.TestResource" property="have.djux"
        classpathref="cp"/>
    <available classname="org.apache.log4j.Category" property="have.log4j"
        classpathref="cp"/>
    <condition property="have.collections">
      <or>
        <available classname="java.util.Collection" classpathref="cp"/>
        <available classname="com.sun.java.util.collections.Collection"
            classpathref="cp"/>
      </or>
    </condition>
    <condition property="have.jsse">
      <or>
        <available classname="javax.net.ssl.SSLSocketFactory"
            classpathref="cp"/>
        <equals arg1="${ant.java.version}" arg2="1.1"/>
      </or>
    </condition>
  </target>

  <target name="prepare.stage" depends="prepare">
    <mkdir dir="${stage.dir}"/>
  </target>

  <target name="get.JUnit" depends="prepare.stage" unless="have.JUnit">
    <property name="download.junit"
        value="http://download.sourceforge.net/junit/junit3.7.zip"/>
    <echo message="JUnit not found - fetching from ${download.junit}"/>
    <get src="${download.junit}" dest="${stage.dir}/junit3.7.zip" usetimestamp="true"/>
    <unzip src="${stage.dir}/junit3.7.zip" dest="${stage.dir}"/>
    <copy file="${stage.dir}/junit3.7/junit.jar" todir="jxUtil/lib"/>
  </target>

  <!-- provides both djux and JUnit -->
  <target name="get.djux" depends="prepare.stage" unless="have.djux">
    <property name="download.djux"
      value="http://www.daedalos.com/DE/DOWNLOAD/JUnitExtensions/JUnit_Extensions_100.zip"/>
    <echo message="JUnit extensions not found - fetching from ${download.djux}"/>
    <get src="${download.djux}" dest="${stage.dir}/djux.zip" usetimestamp="true"/>
    <unzip src="stage/djux.zip" dest="${stage.dir}"/>
    <copy todir="jxUtil/lib">
      <fileset dir="${stage.dir}/JUnit Extensions 1.0">
        <include name="*.jar"/>
      </fileset>
    </copy>
    <delete dir="${stage.dir}/JUnit Extensions 1.0"/>
  </target>

  <target name="get.log4j" depends="prepare.stage" unless="have.log4j">
    <property name="download.log4j"
        value="http://jakarta.apache.org/log4j/jakarta-log4j-1.1.3.tar.gz"/>
    <echo message="Log4j not found - fetching from ${download.log4j}"/>
    <get src="${download.log4j}" dest="${stage.dir}/log4j.tar.gz" usetimestamp="true"/>
    <gunzip src="${stage.dir}/log4j.tar.gz" dest="${stage.dir}/log4j.tar"/>
    <untar src="${stage.dir}/log4j.tar" dest="${stage.dir}"/>
    <copy file="${stage.dir}/jakarta-log4j-1.1.3/dist/lib/log4j.jar" todir="jxUtil/lib"/>
    <delete dir="${stage.dir}/jakarta-log4j-1.1.3"/>
    <delete file="${stage.dir}/log4j.tar"/>
  </target>

  <target name="get.collections" depends="prepare.stage"
      unless="have.collections">
    <property name="download.collections"
      value="http://jxutil.sourceforge.net/etc/classpath-collections.jar"/>
    <get src="${download.collections}" dest="lib/collections.jar" usetimestamp="true"/>
  </target>

  <target name="get.jsse" unless="have.jsse">
    <echo><![CDATA[
The Java Secure Socket Extensions (JSSE) could not be found.
Either update to the JDK 1.4, which includes JSSE or download the optional package directly from Sun: http://java.sun.com/products/jsse/
Install JSSE according to the instructions in the software bundle.
Then edit the build properties file and add a key
  prereq.jsse-DIR=<the path you installed JSSE to>
that points to the path you installed JSSE to.
]]></echo>
    <fail/>
  </target>

<!--
  anonymous checkout of jxUtil
-->
  <target name="checkout.jxUtil" depends="prepare, prereq, get.djux, get.log4j, get.collections">
    <echo>Checking out jxUtil</echo>
    <cvs cvsroot="${cvsroot.jxUtil}" package="jxUtil"/>
  </target>

<!--
  anonymous checkout of jxDBCon
-->
  <target name="checkout.jxDBCon" depends="prepare, prereq, get.jsse, checkout.jxUtil">
    <echo>Checking out jxDBCon</echo>
	  <cvs cvsroot="${cvsroot.jxDBCon}" package="jxDBCon"/>
  </target>

<!--
  developer checkout of jxUtil
-->
  <target name="checkout.jxUtil.Pro" depends="prepare, prereq, get.djux, get.log4j, get.collections">
    <echo>Checking out jxUtil as developer ${cvsuser}</echo>
    <cvs cvsroot="${cvsroot.jxUtil.Pro}" package="jxUtil"/>
  </target>

<!--
  developer checkout of jxDBCon
-->
  <target name="checkout.jxDBCon.Pro" depends="prepare, prereq, get.jsse, checkout.jxUtil.Pro">
    <echo>Checking out jxDBCon as developer ${cvsuser}</echo>
	  <cvs cvsroot="${cvsroot.jxDBCon.Pro}" package="jxDBCon"/>
  </target>


<!--
  download and expand the source distribution of jxUtil
-->
  <target name="get.jxUtil" depends="prepare, prereq, get.djux, get.log4j, get.collections">
    <property name="download.jxUtil"
        value="http://prdownloads.sourceforge.net/jxutil/jxUtil-src-${jxUtil.version}.zip"/>
    <echo message="Fetching jxUtil source distribution from ${download.jxUtil}"/>
    <get src="${download.jxUtil}"
        dest="${stage.dir}/jxUtil.zip"
        usetimestamp="true"/>
    <unzip src="${stage.dir}/jxUtil.zip" dest="."/>
    <move todir="jxUtil">
      <fileset dir="jxUtil-${jxUtil.version}"/>
    </move>
  </target>

<!--
  download and expand the source distribution of jxDBCon
-->
  <target name="get.jxDBCon" depends="prepare, prereq, get.jsse, get.jxUtil">
    <property name="download.jxDBCon"
        value="http://prdownloads.sourceforge.net/jxdbcon/jxDBCon-src-${jxDBCon.version}.zip"/>
    <echo message="Fetching jxDBCon source distribution from ${download.jxDBCon}"/>
    <get src="${download.jxDBCon}"
        dest="${stage.dir}/jxDBCon.zip"
        usetimestamp="true"/>
    <unzip src="${stage.dir}/jxDBCon.zip" dest="."/>
    <move todir="jxDBCon">
      <fileset dir="jxDBCon-${jxDBCon.version}"/>
    </move>
  </target>
</project>
