<project name="LBClassicTest" default="usage" basedir=".">

	<property file="build.properties" />

	<!-- The base directory relative to which most targets are built -->
	<property name="base" value="." />

	<!-- The directory where source files are stored. -->
	<property name="project.source" value="../src/java/" />
	<property name="project.classes" value="../classes/" />

	<property name="core.classes" value="../../core/classes/" />
	<property name="core.test.classes" value="../../core/test/classes/" />
	
	<property name="tests.source" value="./src/java/" />

	<!-- The stem where most LB core source code is located. -->
	<property name="stem" value="com/logback/core" />

	<!-- Destination for compiled files -->
	<property name="javac.dest" value="./classes" />


	<path id="tests.classpath">
		<pathelement location="${core.classes}" />
		<pathelement location="${core.test.classes}" />
		<pathelement location="${project.source}" />
		<pathelement location="${project.classes}" />
		<pathelement location="${tests.source}" />
		<pathelement location="${javac.dest}" />
		<pathelement location="../../core/lib/janino.jar"/>
	</path>


	<!-- ================================================================= -->
	<!--                        TARGETS                                    -->
	<!-- ================================================================= -->



	<!-- ================================================================= -->
	<!-- Default target                                                    -->
	<!-- ================================================================= -->

	<target name="usage">
		<echo>
      
      These are the targets supported by this ANT build scpript:
      
      build - compile all project files, if a certain library is missing, 
              then the compilation of its dependents are skipped.
     
      all - run all available tests
    </echo>
	</target>

	<target name="prepare">
		<mkdir dir="${javac.dest}" />
		<mkdir dir="./output" />
	</target>

	<!-- ================================================================= -->
	<!-- Check if prerequisites are available                              -->
	<!-- ================================================================= -->

	<target name="check" depends="junitCheck">
	</target>

	<target name="junitCheck">
		
		<available classname="junit.framework.Test" property="junit-present">
			<classpath refid="tests.classpath" />
		</available>

		<fail unless="junit-present">
      Could not find junit classes. Is the file junit.jar missing? 
      See the documentation for the junit task in the Apache Ant Manual.
    </fail>
	</target>

	<!-- Clean the parent project                                          -->
	<!-- ================================================================= -->
	<target name="parentClean">
		<ant dir=".." target="clean" inheritRefs="true" />
	</target>



	<!-- ================================================================= -->
	<!-- Build the parent project                                          -->
	<!-- ================================================================= -->
	<target name="parentBuild">
		<ant dir=".." target="build" inheritRefs="true" />
	</target>

	<!-- ================================================================= -->
	<!-- Compile test cases and related source files.                      -->
	<!-- ================================================================= -->
	<target name="build" depends="parentBuild, prepare">
		<property name="haltonfailure" value="yes" />
		<javac srcdir="${tests.source}" destdir="${javac.dest}" 
			   excludes="${stem}/xynz/toto.java" 
			   deprecation="${deprecation}" 
			   debug="on">
			<classpath refid="tests.classpath" />
		</javac>
	</target>

	<!-- ================================================================= -->
	<!-- Remove all generated files such as compiled class files and test  -->
	<!-- case output.                                                     -->
	<!-- ================================================================= -->
	<target name="clean">
		<delete dir="${javac.dest}/" />
		<delete dir="./output/" />
	</target>

	<target name="cleanOutputDir">
		<delete>
			<fileset dir="./output/" includes="**" />
		</delete>
	</target>

	<!-- ================================================================= -->
	<!-- Run all tests                                                     -->
	<!-- ================================================================= -->
	<target name="all" depends="build, AllUnit,
		                        	BasicJoran,
                              EvaluatorJoran" />


	<target name="AllUnit" depends="check, build, cleanOutputDir">
		<junit printsummary="yes" fork="yes" haltonfailure="yes">
			<classpath refid="tests.classpath" />
			<formatter type="plain" usefile="false" />
			<test name="com.logback.classic.AllTest" />
		</junit>
	</target>

	<target name="BasicJoran" depends="check, build, cleanOutputDir">
		<junit printsummary="yes" fork="yes" haltonfailure="yes">
				<classpath refid="tests.classpath" />
				<formatter type="plain" usefile="false" />
				<test name="com.logback.classic.joran.BasicJoranTest" />
		</junit>
	</target>
	
	<target name="EvaluatorJoran" depends="check, build, cleanOutputDir">
		<junit printsummary="yes" fork="yes" haltonfailure="yes">
				<classpath refid="tests.classpath" />
				<formatter type="plain" usefile="false" />
				<test name="com.logback.classic.joran.EvaluatorJoranTest" />
		</junit>
	</target>
	
			
	
</project>
