<project name="jailer" default="help" basedir=".">
	<target name="help">
		<echo>
available targets:

     - help                     (this page)
     - compile                  (compiles sources)
     - package                  (generates jailer.jar)
		</echo>
	</target>

	<property name="BUILD_DIR" location="out" />
	<property name="COMPILE_DIR" location="${BUILD_DIR}/classes" />
	<property name="TEST_DIR" location="${BUILD_DIR}/test/classes" />
	<property name="SRC_DIR" location="src" />
	<property name="JAR" location="jailer.jar" />
	<property name="TEST_BASE_DIR" location="src/test" />
	<property file="src/test/test.properties"/>
	
	<path id="default.classpath">
		<fileset dir="lib">
			<include name="**/*.jar" />
		</fileset>
	</path>

	<path id="test.classpath">
		<pathelement location="jailer.jar" />
		<pathelement location="${TEST_DIR}" />
		<path refid="default.classpath" />
	</path>

	<target name="clean" description="Cleans up the whole build area.">
		<delete dir="${BUILD_DIR}" />
	</target>

	<target name="compile" depends="clean">
		<delete file="${JAR}" />
		<mkdir dir="${COMPILE_DIR}" />
		<javac destdir="${COMPILE_DIR}" srcdir="${SRC_DIR}/main" debug="on" deprecation="off" encoding="ISO-8859-1">
			<classpath>
				<path refid="default.classpath" />
			</classpath>
			<include name="**/*.java" />
		</javac>
		<copy todir="${COMPILE_DIR}/net/sf/jailer/resource">
			<fileset dir="${SRC_DIR}/main/net/sf/jailer/resource">
				<include name="**/*" />
			</fileset>
		</copy>
	</target>

	<target name="package" depends="compile">
		<jar destfile="${JAR}" basedir="${COMPILE_DIR}">
			<manifest>
				<attribute name="Main-Class" value="net.sf.jailer.ui.ExtractionModelFrame" />
				<attribute name="Class-Path" value="lib/prefuse.jar lib/junit.jar lib/commons-logging.jar lib/log4j.jar lib/args4j.jar lib/spring.jar lib/sdoc-0.5.0-beta.jar config/" />
			</manifest>
		</jar>
	</target>

	<target name="compile-test" depends="compile">
		<mkdir dir="${TEST_DIR}" />
		<javac destdir="${TEST_DIR}" srcdir="${SRC_DIR}/test" debug="on" deprecation="off" encoding="ISO-8859-1">
			<classpath>
				<path refid="test.classpath" />
			</classpath>
			<include name="**/*.java" />
		</javac>
	</target>

	<target name="db2-test" depends="package, compile-test">
		<junit fork="no">
			<sysproperty key="DB_URL" value="${DB2_DB_URL}"/>
			<sysproperty key="DRIVER_CLASS" value="${DB2_DRIVER_CLASS}"/>
			<sysproperty key="DB_USER" value="${DB2_DB_USER}"/>
			<sysproperty key="DB_PASSWORD" value="${DB2_DB_PASSWORD}"/>
			<sysproperty key="DB_SUPPORTS_SESSION_LOCAL" value="yes"/>
			<sysproperty key="BASE_DIR" value="${TEST_BASE_DIR}/single-row-cycle:${TEST_BASE_DIR}/general:${TEST_BASE_DIR}/pseudocolumns:${TEST_BASE_DIR}/pseudocolumns2"/>
			<classpath refid="test.classpath" />
			<formatter type="brief" usefile="false"/>
			<test name="net.sf.jailer.GeneralDbmsTestSuite" />
		</junit>
	</target>

	<target name="oracle-test" depends="package, compile-test">
		<junit fork="no">
			<sysproperty key="DB_URL" value="${ORACLE_DB_URL}"/>
			<sysproperty key="DRIVER_CLASS" value="${ORACLE_DRIVER_CLASS}"/>
			<sysproperty key="DB_USER" value="${ORACLE_DB_USER}"/>
			<sysproperty key="DB_PASSWORD" value="${ORACLE_DB_PASSWORD}"/>
			<sysproperty key="DB_SUPPORTS_SESSION_LOCAL" value="yes"/>
			<sysproperty key="BASE_DIR" value="${TEST_BASE_DIR}/single-row-cycle:${TEST_BASE_DIR}/general:${TEST_BASE_DIR}/pseudocolumns:${TEST_BASE_DIR}/pseudocolumns2"/>
			<classpath refid="test.classpath" />
			<formatter type="brief" usefile="false"/>
			<test name="net.sf.jailer.GeneralDbmsTestSuite" />
		</junit>
	</target>

	<target name="mysql-test" depends="package, compile-test">
		<junit fork="no">
			<sysproperty key="DB_URL" value="${MYSQL_DB_URL}"/>
			<sysproperty key="DRIVER_CLASS" value="${MYSQL_DRIVER_CLASS}"/>
			<sysproperty key="DB_USER" value="${MYSQL_DB_USER}"/>
			<sysproperty key="DB_PASSWORD" value="${MYSQL_DB_PASSWORD}"/>
			<sysproperty key="DB_SUPPORTS_SESSION_LOCAL" value="no"/>
			<sysproperty key="BASE_DIR" value="${TEST_BASE_DIR}/single-row-cycle:${TEST_BASE_DIR}/general:${TEST_BASE_DIR}/pseudocolumns:${TEST_BASE_DIR}/pseudocolumns2"/>
			<classpath refid="test.classpath" />
			<formatter type="brief" usefile="false"/>
			<test name="net.sf.jailer.GeneralDbmsTestSuite" />
		</junit>
	</target>

	<target name="postgre-test" depends="package, compile-test">
		<junit fork="no">
			<sysproperty key="DB_URL" value="${POSTGRE_DB_URL}"/>
			<sysproperty key="DRIVER_CLASS" value="${POSTGRE_DRIVER_CLASS}"/>
			<sysproperty key="DB_USER" value="${POSTGRE_DB_USER}"/>
			<sysproperty key="DB_PASSWORD" value="${POSTGRE_DB_PASSWORD}"/>
			<sysproperty key="DB_SUPPORTS_SESSION_LOCAL" value="yes"/>
			<sysproperty key="BASE_DIR" value="${TEST_BASE_DIR}/single-row-cycle:${TEST_BASE_DIR}/general:${TEST_BASE_DIR}/pseudocolumns:${TEST_BASE_DIR}/pseudocolumns2"/>
			<classpath refid="test.classpath" />
			<formatter type="brief" usefile="false"/>
			<test name="net.sf.jailer.GeneralDbmsTestSuite" />
		</junit>
	</target>

</project>
