<project name="LiquidTestProject-02-08-09" default="runtests">

	<property name="src" value="src" />
	<property name="build" value="build" />
	<property name="bin" value="${build}/bin" />
	<property name="junit.log.dir" value="${build}/log" />

	<!-- NOTE: Set the versions of LiquidTest Server and JUnit to the versions you are using -->
	<property name="junit.version" value="4.5" />
	<property name="liquidtest.server.version" value="1.0.11" />

	<!-- Creating a target to remove the old compiled code -->
	<target name="clean">
		<delete dir="${build}"/>
	</target>

	<!-- The compile step for the tests -->
	<target name="compile">
		<mkdir dir="${bin}"/>
		<javac srcdir="${src}"
	         destdir="${bin}"
	        debug="off"
	         source="1.5">
			<classpath>
				<path location="liquidtest-nodeps-${liquidtest.server.version}.jar" />
				<path location="junit-${junit.version}.jar" />
			</classpath>
		</javac>
		<copy file="liquidtest.properties" todir="${bin}" />
	</target>

	<!-- The run step of the build file -->
	<target name="runtests" depends="clean, compile">
		<mkdir dir="${junit.log.dir}"/>
		<junit showoutput="true" failureproperty="test.failed" printsummary="true" fork="true">
			<!-- Setting up our Java classpath -->
			<classpath>
				<pathelement path="${bin}"/>
				<pathelement path="liquidtest-nodeps-${liquidtest.server.version}.jar"/>
				<pathelement path="junit-${junit.version}.jar"/>
			</classpath>
			<formatter type="xml"/>

			<!-- building a task for all .java files -->
			<batchtest todir="${junit.log.dir}">
				<fileset dir="${src}">
		            <!-- Add includes and excludes to select which tests to run ** means any directory -->
					<include name="**/*.java" />
				</fileset>
			</batchtest>
		</junit>

		<!-- Specifying a task for LiquidTest Script (Groovy) tests -->
		<runliquidtest todir="${junit.log.dir}">
		    <fileset dir="." includes="**/*.lqt"/>
	        <classpath>
	        	<pathelement path="${bin}"/> <!-- NOTE CHANGED THIS FROM bin -->
				<pathelement path="liquidtest-nodeps-${liquidtest.server.version}.jar"/>
	        </classpath>
		</runliquidtest>
	</target>

	<taskdef name="runliquidtest" classname="com.jadeliquid.liquidtest.ant.scripting.RunLiquidTestsTask">
	    <classpath>
	    	<pathelement path="${bin}"/>
			<pathelement path="liquidtest-nodeps-${liquidtest.server.version}.jar"/>
	    </classpath>
	</taskdef>

</project>
