<?xml version="1.0"?>

<!-- ======================================================================= -->
<!-- ANT-Makefile for JCalendar (C) 2011 Kai Toedter                         -->
<!-- ======================================================================= -->

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

	<!-- ===================================================================== -->
	<!-- PROPERTIES                                                            -->
	<!-- ===================================================================== -->

	<property name="version" value="1.4" />
	<property name="modified" value="07/09/2011" />
	<property name="copyright.year" value="1999 - 2011" />
	<property name="looks.jar" value="jgoodies-looks-2.4.1.jar" />
	<property name="common.jar" value="jgoodies-common-1.2.0.jar" />

	<property name="name" value="jcalendar" />
	<property name="Name" value="JCalendar" />

	<property name="jcalendar.home" value=".." />

	<property name="bin.dir" value="bin" />
	<property name="build.dir" value="build" />
	<property name="dist.dir" value="dist" />
	<property name="doc.dir" value="doc" />
	<property name="javadoc.dir" value="${doc.dir}/api" />
	<property name="lib.dir" value="lib" />
	<property name="src.dir" value="src" />

	<property name="src.tests" value="test-junit4" />
	<property name="reports.tests" value="test-reports" />
	<property name="junit.jar" value="junit-4.6.jar" />
	<property name="web.dir" value="d:/Apache2.2/htdocs/jcalendar/ibuild" />

	<!-- ===================================================================== -->
	<!-- COMPILER: classic (JDK 1.1 & 1.2), modern or jikes                    -->
	<!-- ===================================================================== -->
	<property name="build.compiler" value="modern" />

	<property name="manifest" value="src/jcalendar.manifest" />
	<property name="packages" value="com.toedter.calendar.*,com.toedter.components.*, com.toedter.calendar.demo.*" />


	<!-- ===================================================================== -->
	<!-- MAIN                                                                  -->
	<!-- ===================================================================== -->

	<target name="main" depends="compile">
	</target>

	<!-- ===================================================================== -->
	<!-- PREPARE BUILD                                                         -->
	<!-- ===================================================================== -->

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

	<!-- ===================================================================== -->
	<!-- COMPILE                                                               -->
	<!-- ===================================================================== -->

	<target name="compile" depends="prepare">
		<copy todir="${build.dir}">
			<fileset dir="${src.dir}">
				<patternset>
					<include name="**/*.gif" />
					<include name="**/*.properties" />
					<include name="**/classlist" />
				</patternset>
			</fileset>
		</copy>
		<javac srcdir="${src.dir}" destdir="${build.dir}" classpath="lib/${looks.jar};lib/${common.jar}" debug="off" deprecation="on" optimize="on" source="1.4" />
	</target>

	<!-- ===================================================================== -->
	<!-- JAR FILE                                                              -->
	<!-- ===================================================================== -->

	<target name="jar" depends="compile">
		<mkdir dir="${lib.dir}" />
		<jar jarfile="${lib.dir}/jcalendar-${version}.jar" compress="no" basedir="${build.dir}" includes="com/**" manifest="${manifest}" />
	</target>

	<!-- ===================================================================== -->
	<!-- JAVADOC                                                               -->
	<!-- ===================================================================== -->

	<target name="javadocs" depends="prepare">
		<mkdir dir="${javadoc.dir}" />
		<javadoc packagenames="${packages}" sourcepath="${basedir}/${src.dir}" classpath=".;lib/${looks.jar};lib/${common.jar}" destdir="${javadoc.dir}" author="true" version="true" windowtitle="${Name} API" doctitle="${Name}" bottom="Copyright &#169; ${copyright.year} Kai Toedter." />
	</target>

	<!-- ===================================================================== -->
	<!-- DISTRIBUTION                                                          -->
	<!-- ===================================================================== -->

	<target name="dist" depends="jar, javadocs,runTests">
		<echo message="Running JCalendar integration distribution veryion  ${version}, modification date ${modified}" />

		<filter token="VERSION" value="${version}" />
		<filter token="MODIFIED" value="${modified}" />
		<filter token="COPYRIGHTYEAR" value="${copyright.year}" />
		<filter token="LOOKS" value="${looks.jar}" />
		<filter token="COMMON" value="${common.jar}" />

		<delete dir="${dist.dir}" />
		<mkdir dir="${dist.dir}" />
		<mkdir dir="${dist.dir}/${bin.dir}" />
		<mkdir dir="${dist.dir}/${lib.dir}" />
		<mkdir dir="${dist.dir}/${doc.dir}" />
		<mkdir dir="${dist.dir}/${src.dir}" />

		<copy todir="${dist.dir}/${src.dir}">
			<fileset dir="${src.dir}" />
		</copy>
		<copy todir="${dist.dir}/${lib.dir}">
			<fileset dir="${lib.dir}" />
		</copy>
		<copy todir="${dist.dir}/${bin.dir}" filtering="yes">
			<fileset dir="${bin.dir}" />
		</copy>
		<copy todir="${dist.dir}/${javadoc.dir}">
			<fileset dir="${javadoc.dir}" />
		</copy>
		<copy todir="${dist.dir}/${doc.dir}/images">
			<fileset dir="${doc.dir}/images" />
		</copy>
		<copy todir="${dist.dir}/${doc.dir}/images/1.4">
			<fileset dir="${doc.dir}/images/1.4" />
		</copy>

		<copy todir="${dist.dir}" filtering="yes">
			<fileset dir="${basedir}">
				<include name="**/*.txt" />
				<exclude name="**/license.txt" />
			</fileset>
		</copy>
		<copy file="${doc.dir}/license.html" todir="${dist.dir}/${doc.dir}/" filtering="no" />
		<copy file="${doc.dir}/index.html" todir="${dist.dir}/${doc.dir}/" filtering="yes" />
		<copy file="${doc.dir}/demo.html" todir="${dist.dir}/${doc.dir}/" filtering="yes" />
		<copy file="${doc.dir}/new.html" todir="${dist.dir}/${doc.dir}/" filtering="yes" />
		<copy file="${doc.dir}/style.css" todir="${dist.dir}/${doc.dir}/" filtering="no" />

		<!-- create a zip file -->
		<zip zipfile="jcalendar-${version}.zip">
			<zipfileset dir="${dist.dir}">
				<include name="**" />
			</zipfileset>
		</zip>
	</target>

	<!-- =================================================================== -->
	<!-- Non Release Distribution                                   -->
	<!-- =================================================================== -->

	<target name="integrationDist">
		<tstamp />
		<tstamp>
		    <format property="today" pattern="MM/dd/yyyy" locale="en,US"/>
		</tstamp>

		<antcall target="dist">
			<param name="version" value="${version}.v${DSTAMP}${TSTAMP}" />
			<param name="modified" value="${today}" />
		</antcall>
		
		<delete dir="${web.dir}" />
		<mkdir dir="${web.dir}" />
		<copy todir="${web.dir}/${dist.dir}">
			<fileset dir="${dist.dir}" />
		</copy>
		<copy file="jcalendar-${version}.v${DSTAMP}${TSTAMP}.zip" todir="${web.dir}" filtering="no" />

	</target>


	<!-- =================================================================== -->
	<!-- Run Demo                                                            -->
	<!-- =================================================================== -->

	<target name="runDemo" depends="jar">
		<echo message="Running JCalendar demo ..." />
		<java classpath="lib/jcalendar-${version}.jar;lib/${looks.jar};lib/${common.jar}" classname="com.toedter.calendar.demo.JCalendarDemo" fork="yes">
		</java>
	</target>


	<!-- =================================================================== -->
	<!-- Run Tests                                                          -->
	<!-- =================================================================== -->

	<target name="runTests" depends="compile">
		<echo message="Running JCalendar JUnit tests ..." />

		<javac srcdir="${src.tests}" destdir="${build.dir}" classpath="${build.dir};lib/${junit.jar};lib/${looks.jar}" debug="off" deprecation="on" optimize="on" source="1.5" />

		<delete dir="${reports.tests}" />
		<mkdir dir="${reports.tests}/xml" />

		<junit printsummary="yes" haltonfailure="yes">
			<classpath>
				<pathelement location="lib/${junit.jar}" />
				<pathelement location="${build.dir}" />
				<pathelement location="${src.tests}" />
				<pathelement path="${java.class.path}" />
			</classpath>

			<batchtest fork="yes" todir="${reports.tests}/xml">
				<formatter type="xml" />
				<fileset dir="${src.tests}">
					<include name="**/*.java" />
					<exclude name="**/AllTests.java" />
				</fileset>
			</batchtest>
		</junit>

		<junitreport todir="${reports.tests}">
			<fileset dir="${reports.tests}/xml">
				<include name="TEST-*.xml" />
			</fileset>
			<report format="frames" todir="${reports.tests}" />
		</junitreport>


	</target>

	<!-- =================================================================== -->
	<!-- CLEAN                                                               -->
	<!-- =================================================================== -->

	<target name="clean">
		<delete>
			<fileset dir="${lib.dir}" includes="jcalendar*" />
		</delete>
		<delete dir="${build.dir}" />
		<delete dir="${dist.dir}" />
		<delete dir="${javadoc.dir}" />
	</target>

</project>

<!-- End of build.xml -->

