<!--
 * $Id: build.xml,v 1.10 2003/05/30 01:45:17 juanco Exp $
 *
 * RCS (Revision Control System) archive parsing and manipulation in Java.

 * ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2001 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" and
 *    "Apache JRCS" must not be used to endorse or promote products
 *    derived from this software without prior written permission. For
 *    written permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    "Apache JRCS", nor may "Apache" appear in their name, without
 *    prior written permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
-->

<!-- ANT
     This is an Ant script for building the JRCS library.
     Ant is the Jakarta project's build tool.
	  You can get a copy of Ant from:
	  
	      http://jakarta.apache.org/ant/

	  You'll need to also download the optional Ant tasks if you'll be
     running JavaCC or the JUnit tests (more information below).
-->  

<!-- Jakarta ORO
     The Jakarta ORO Regexp library is used for RCS keyword management.
	  You can get a copy of Jakarta ORO from:

       http://jakarta.apache.org/oro/

	  A copy of Jakarta ORO is included in the full distribution of this
	  library.
-->  

<!-- JavaCC
     The RCS parser is constructed using the JavaCC compiler compiler.
	  You can get a copy of JavaCC from:
	     
		   http://www.metamata.com/javacc/
	
	  JavaCC is not distributable, so you must get a copy of it yourself
	  if you intend to use it.
	  Keep in mind that, as distributed, this library does not require 
	  JavaCC to be compiled because all the JavaCC generated .java files 
	  are included. 
	  
	  If you decide to use JavaCC, please adjust the "javacc.lib.dir" 
	  property as needed. You'll also need to download the set of optional
	  tasks for Ant.
-->

<!-- JUnit
     The library tests are written for the JUnit Testing Framework. 
	  For distributions and documentation see:
	     
        http://www.junit.org/

     You'll need to place a copy of junit.jar in Ant's lib directory
     to run the tests.
-->

<project name="RCS archive parsing and manipulation in Java."
			default="test" 
			basedir="." >

  <!-- Allow any user specific values to override the defaults -->
  <property file="${user.home}/build.properties" />
  <!-- Allow user defaults for this project -->
  <property file="build.properties" />

  <property name="app.name" value="jrcs" />
  <property name="version"  value="0.1.7" />

  <property name="src.dir"   value="${basedir}/src" />
  <property name="java.dir"  value="${src.dir}/java" />
  <property name="tests.dir" value="${src.dir}/test" />
  <property name="lib.dir"   value="${basedir}/lib" />
  <property name="doc.dir"   value="${basedir}/doc" />
  <property name="javadoc"   value="${doc.dir}/api" />
  <property name="dist.dir"  value="${doc.dir}/dist" />
  <property name="classes"   value="${basedir}/classes" />
  <property name="test.classes" value="${basedir}/test-classes" />
  <property name="maven.repo" value="C:\Documents and Settings\andrew\.maven\repository"/>

  <property name="javacc.lib.dir" value="${javacc.home}/bin/lib" />

<!-- <property name="build.compiler" value="jikes" /> -->
<!-- <property name="build.compiler" value="classic"/> -->

  <property name="rcs.jar"    value="${lib.dir}/org.apache.commons.jrcs.rcs.jar" />
  <property name="diff.jar"   value="${lib.dir}/org.apache.commons.jrcs.diff.jar" />
  <property name="tests.jar"  value="${lib.dir}/org.apache.commons.jrcs.tests.jar" />
  <property name="regexp.jar" value="${lib.dir}/oro-2.0.8.jar" />
  <property name="junit.jar"  value="${maven.repo}/junit/jars/junit-3.8.1.jar" />
  <property name="libs"
            value="${diff.jar};${rcs.jar};${regexp.jar};${tests.jar};${junit.jar}" />

  <target name="prepare">
    <available file="${javacc.lib.dir}/JavaCC.zip" property="javacc.present" />
    <mkdir dir="${classes}" />
    <mkdir dir="${test.classes}" />
    <mkdir dir="${lib.dir}" />
  </target>

  <target name="tidy">
    <delete dir="${classes}" />
  </target>

  <target name="clean" depends="tidy">
    <delete dir="${javadoc}" />
    <delete dir="${dist.dir}" />

    <delete file="${diff.jar}" />
    <delete file="${rcs.jar}" />
    <delete file="${tests.jar}" />
  </target>

  <patternset id="non.java.sources">
    <include name="**/*.properties" />
    <include name="**/*.html" />
    <include name="**/defaultManifest.mf" />
  </patternset>

  <target name="diff" depends="prepare">
    <copy todir="${classes}">
      <fileset dir="${java.dir}">
        <patternset refid="non.java.sources" />
      </fileset>
    </copy>

    <javac srcdir="${java.dir}" 
	        destdir="${classes}" 
			  classpath="${libs}"
           debug="on" optimize="on" deprecation="on" >
           <include name="**/jrcs/diff/**/*.java" />
           <include name="**/jrcs/util/**/*.java" />
      <exclude name="**/*Test*.class" />
    </javac>

    <jar jarfile="${diff.jar}" basedir="${classes}" >
      <include name="org/apache/commons/jrcs/diff/**" />
      <include name="org/apache/commons/jrcs/util/**" />
      <exclude name="**/*Test*.class" />
    </jar>
  </target>

  <target name="parser" if="javacc.present" >
    <javacc 
      target="${java.dir}/org/apache/commons/jrcs/rcs/ArchiveParser.jj" 
      outputdirectory="${java.dir}/org/apache/commons/jrcs/rcs/"
      javacchome="${javacc.lib.dir}" 
		optimizetokenmanager="true"
    />
    <echo message="parser built" />  
  </target>

  <target name="rcs" depends="prepare,diff,parser">
    <javac srcdir="${java.dir}" 
	        destdir="${classes}" 
			  classpath="${libs};classes"
           debug="on" optimize="on" deprecation="on" >
      <include name="**/jrcs/rcs/**/*.java" />
      <exclude name="**/*Test*.class" />
    </javac>

    <jar jarfile="${rcs.jar}" basedir="${classes}" >
      <include name="org/apache/commons/jrcs/rcs/**" />
      <exclude name="**/*Test*.class" />
    </jar>
  </target>

  <target name="tests" depends="prepare,diff,rcs">
    <javac srcdir="${tests.dir}" 
	 		  destdir="${test.classes}" 
           classpath="${libs};${classes}"
           debug="on" optimize="on" deprecation="on">
      <include name="**/*.java" />
    </javac>

    <jar jarfile="${tests.jar}" basedir="${test.classes}" >
      <include name="**/*test*.class" />
      <include name="**/*Test*.class" />
    </jar>
  </target>

  <target name="libs" depends="diff,rcs">
  </target>

  <target name="test" depends="tests">
    <junit printsummary="yes" >
      <classpath>
        <pathelement path="${libs}" />
        <pathelement location="${libs}/*.jar" />
      </classpath>
    
      <formatter type="plain" />
    
      <test name="org.apache.commons.jrcs.AllTests" 
				haltonfailure="no" 
				 >
        <!-- <formatter type="plain" usefile="no" /> -->
      </test>
    </junit>

<!--  
    <java classname="tests" 
	       classpath="${libs}"
          fork="yes" 
			 failonerror="yes" 
			 />
-->			 
  </target>

  <target name="javadoc" depends="libs">
    <mkdir dir="${javadoc}" />
    <javadoc packagenames="org.apache.commons.jrcs.*"
             sourcepath="${java.dir}" 
             destdir="${javadoc}" 
             classpath="${libs};classes"
				 author="true"
             version="true" 
             private="yes"
             overview="${java.dir}/org/apache/commons/jrcs/overview.html"
				 windowtitle="${app.name} API"
    		    doctitle="${app.name}"
             bottom="Copyright 2002 the Apache Software Foundation&lt;br&gt;
                     Copyright &#169; 1999-2001 Juancarlo A&#241;ez, Caracas, Venezuela.&lt;br&gt;
				         All rights reserved&lt;br&gt;.
                     http://www.suigeneris.org/jrcs"
            >
    </javadoc>
  </target>

  <target name="all" depends="prepare,libs,test,javadoc" />

  <target name="compact.dist" depends="all">
    <mkdir dir="${dist.dir}" />
    <property name="tarfile" value="${dist.dir}/jrcs-${version}.tar" />
    <delete file="${tarfile}" />

    <tar tarfile="${tarfile}" basedir="${basedir}">
      <exclude name="classes/**/*" />
      <exclude name="test-classes/**/*" />
      <exclude name="dist/**/*" />
      <exclude name="lib/gnu*.jar" />
      <exclude name="lib/junit*.jar" />
      <exclude name="lib/JavaCC.zip" />
    </tar>

    <delete file="${tarfile}.gz" />
    <gzip zipfile="${tarfile}.gz" src="${tarfile}" />

    <delete file="${tarfile}" />

    <property name="zipfile" value="${dist.dir}/jrcs-${version}.zip" />
    <zip zipfile="${zipfile}" basedir="${basedir}">
      <exclude name="classes/**/*" />
      <exclude name="test-classes/**/*" />
      <exclude name="dist/**/*" />
      <exclude name="lib/gnu*.jar" />
      <exclude name="lib/junit*.jar" />
      <exclude name="lib/JavaCC.zip" />
    </zip>

  </target>

  <target name="full.dist" depends="all">
    <mkdir dir="${dist.dir}" />
    <property name="full.tarfile" value="${dist.dir}/jrcs-full-${version}.tar" />
    <property name="full.zipfile" value="${dist.dir}/jrcs-full-${version}.zip" />
    <delete file="${full.tarfile}" />

    <tar tarfile="${full.tarfile}" basedir="${basedir}">
      <exclude name="**/CVS/*" />
      <exclude name="classes/**/*" />
      <exclude name="test-classes/**/*" />
      <exclude name="dist/**/*" />
      <exclude name="lib/JavaCC.zip" />
    </tar>

    <delete file="${full.tarfile}.gz" />
    <gzip zipfile="${full.tarfile}.gz" src="${full.tarfile}" />

    <delete file="${full.tarfile}" />

    <zip zipfile="${full.zipfile}" basedir="${basedir}">
      <exclude name="**/CVS/*" />
      <exclude name="classes/**/*" />
      <exclude name="test-classes/**/*" />
      <exclude name="dist/**/*" />
      <exclude name="lib/JavaCC.zip" />
    </zip>
  </target>

  <target name="dist" depends="compact.dist,full.dist" />

  <target name="changelog" >
     <cvschangelog destfile="changelog.xml" />
  </target>
</project>

