<project name="GoGame" default="dist" basedir=".">

	<description>Simple Framework for Testing Tree Search and Monte-Carlo Go</description>

	<property name="src" location="src" />
	<property name="build" location="build" />
	<property name="dist" location="dist" />
	<property name="test" location="test" />
	<property name="docs" location="docs" />
	<property name="lib" location="lib" />

	<path id="build.classpath">
		<fileset dir="${lib}">
			<include name="**/*.jar" />
		</fileset>
	</path>

	<path id="classpath.test">
		<path refid="build.classpath" />
		<pathelement location="lib/junit-4.10.jar" />
		<pathelement location="${build}" />
	</path>

	<target name="compile" depends="init" description="compile the source ">
		<!-- Compile the java code from ${src} into ${build} -->
		<javac srcdir="${src}" destdir="${build}" classpathref="build.classpath" debug="true" source="1.6" target="1.6"/>
	</target>

	<target name="compile-test" depends="compile">
		<javac srcdir="${test}" destdir="${build}" debug="true">
			<classpath refid="classpath.test" />
		</javac>
	</target>

	<target name="copy-resources">
		<copy todir="${dist}">
			<fileset dir="data" />
		</copy>
	</target>

	<target name="clean" description="clean up">
		<!-- Delete the ${build} and ${dist} directory trees -->
		<delete dir="${build}" />
		<delete dir="${dist}" />
	</target>

	<target name="dist" depends="compile,copy-resources" description="generate the distribution">
		<jar jarfile="${dist}/GoGame.jar">
			<fileset dir="${build}" excludes="**/*Test.class" />
			<manifest>
				<attribute name="Main-Class" value="net.woodyfolsom.msproj.GoGame" />
				<attribute name="Class-Path" value="kgsGtp.jar log4j-1.2.16.jar"/>
			</manifest>
		</jar>
	</target>

	<!-- Creates Javadoc -->
	<target name="docs" depends="compile">
		<javadoc packagenames="src" sourcepath="${src}" destdir="${docs}">
			<!-- Define which files / directory should get included, we include all -->
			<fileset dir="${src}">
				<include name="**" />
			</fileset>
		</javadoc>
	</target>

	<target name="init">
		<!-- Create the build directory structure used by compile -->
		<mkdir dir="${build}" />
	</target>
		
	<target name="test" depends="compile-test">
		<junit haltonfailure="true">
			<classpath refid="classpath.test" />
			<formatter type="brief" usefile="false" />
			<batchtest>
				<fileset dir="${build}" includes="**/*Test.class" />
			</batchtest>
		</junit>
	</target>
	
</project>