<!--
build.xml
Copyright 2004 Christoph Csallner and Yannis Smaragdakis.
2004-10-28 started

====================================================================
Testee Ant build file, located in testee root directory
Compiles testee, calls cnc.xml to generate, compile, run, and archive tests.
Adapt properties below to your project and environment settings.
====================================================================
-->

<project name="P1 by s1" default="test" basedir=".">
  <description>
		Build and Check 'n Crash testee.
	</description>
	
  <!-- project properties -->
  <property name="src" value="src"/>
  <property name="test" value="test"/>  <!--write test case sources to dir-->	
  <property name="bin" value="bin"/>
	<property name="classpath" value=""/>	
	<property name="testee.list.name" value="testees.txt"/>
	<property name="esc.params" value="-ea -source 1.4 -loop 1.5"/>
	<property name="cnc.params" value=""/>  <!--CnC specific, like -NPE-->
	
  <!-- environment properties -->
	<property name="cnc.version" value="0.4.10"/>	
  <property name="simplify" value="Simplify-1.5.4.exe"/>
  <property name="java.rt.jar" value="c:\bin\j2sdk1.4.2_05\jre\lib\rt.jar"/>
  <property name="cnc.jar" value="c:\lib\cnc-bundle-${cnc.version}.jar"/>
	
	
	<path id="esc.params.classpath">
		<pathelement location="${java.rt.jar}"/>
		<pathelement path="${classpath}"/>
		<pathelement location="${bin}"/>
	</path>
	
	<path id="esc.params.sourcepath">
		<pathelement location="${src}"/>
	</path>
	
	<path id="esc.params.specs">
		<!--<pathelement location="${cnc.jar}"/>-->  <!--comment out to ignore JDK specs-->	
		<pathelement location="${src}"/>
	</path>
	
	
	<!--init-->
  <target name="init">
		<mkdir dir="${bin}"/>
		<mkdir dir="${test}"/>
	</target>
	
	<!--compile-->
	<target name="compile" depends="init"
			description="compile the testee's Java sources from directory ${src} to ${bin}" >
		<loadfile property="testee.list" srcFile="${testee.list.name}">
			<filterchain> <!--convert line separation between entries to a comma-->
				<tokenfilter>
					<filetokenizer/>
					<trim/>
					<replaceregex pattern="(\s)+(\S)" replace=",\2" flags="g"/>
				</tokenfilter>
			</filterchain>
		</loadfile>
		<!--we want source line numbers in any exception trace,
		just like we would get by default when calling javac without arguments-->
		<javac srcdir="${src}" destdir="${bin}"
				classpath="${classpath}"
				debug="true"
				debuglevel="source,lines"
				includes="${testee.list}"
				source="1.4"
		/>
	</target>
		
	<!--test-->
	<target name="test" depends="compile"
			description=
				"generate tests to ${test}, compile them to ${bin}, run, and archive them" >
		<unjar src="${cnc.jar}" dest=".">
			<patternset includes="use.xml"/>
		</unjar>
		<!--generate, compile, run, and archive tests-->
		<ant antfile="use.xml" dir=".">
			<reference refid="esc.params.classpath"/>
			<reference refid="esc.params.sourcepath"/>
			<reference refid="esc.params.specs"/>
		</ant>
		<delete file="use.xml"/>
	</target>
	
	<!--clean-->
	<target name="clean"
			description="delete the generated test sources and all binaries" >
		<delete dir="${test}"/>		
		<delete dir="${bin}"/>
	</target>			
</project>
