<!--
  Copyright 2006 The Apache Software Foundation.
  
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  
       http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  
-->
<project name="strictxml" default="test" basedir="." >
	  <!-- The build.properties file defines the path to local jar files -->
	  <property file="build.properties"/>

	  <property name="version" value="0.1"/>
      <property name="target.dir" value="target"/>
	  <property name="classes.dir" value="${target.dir}/classes"/>
	  <property name="test-classes.dir" value="${target.dir}/test-classes"/>

	  <property name="M2_REPO" value="${user.home}/.m2/repository"/>
	  <property name="log4j.version" value="1.2.13"/>
	  <property name="log4j.jar" value="${M2_REPO}/log4j/log4j/${log4j.version}/log4j-${log4j.version}.jar"/>
	  <property name="junit.version" value="3.8.1"/>
	  <property name="junit.jar" value="${M2_REPO}/junit/junit/${junit.version}/junit-${junit.version}.jar"/>
	  <property name="xerces.version" value="2.4.0"/>
	  <property name="xerces.jar" value="${M2_REPO}/xerces/xercesImpl/${xerces.version}/xercesImpl-${xerces.version}.jar"/>
	  <property name="SAXParserFactory" value="org.apache.xerces.jaxp.SAXParserFactoryImpl"/>
	
	  <target name="clean" description="Remove generated artifacts">
	  	  <delete dir="${target.dir}"/>
	  </target>

	  <target name="init">
	  </target>
	  
	  <target name="compile" depends="init" description="Compile">
         <mkdir dir="${classes.dir}"/>
	  	 <javac destdir="${classes.dir}" 
	  	           srcdir="src/main/java"
	  			   includes="**/*.java"
	  	           source="1.3"
	  	           target="1.3"
	  		       classpath="${log4j.jar}"/>
	  </target>
	  	
	  <target name="testCompile" depends="compile" description="Compile tests">
         <mkdir dir="${test-classes.dir}"/>
	  	 <javac destdir="${test-classes.dir}" 
	  	           srcdir="src/test/java"
	  			   includes="**/*.java"
	  	           source="1.3"
	  	           target="1.3"
	  		       classpath="${classes.dir};${log4j.jar};${junit.jar}"/>
	  </target>

	  <target name="test" depends="testCompile, preprocess" description="Run tests">
	    <junit printsummary="yes" 
	    	fork="yes">
	  	  <classpath path="${classes.dir};${test-classes.dir};${log4j.jar};${junit.jar};${xerces.jar}"/>
	  	  <formatter type="plain" usefile="false"/>
	  	  <batchtest>
	  	    <fileset dir="src/test/java" 
	  	    	includes="**/*.java" excludes="**/XLevel.java,**/Mock*.java"/>
	  	  </batchtest>
	  	  <sysproperty key="javax.xml.parsers.SAXParserFactory"
	  	       value="${SAXParserFactory}"/>
	    </junit>
	  </target>

      <target name="preprocess" depends="init" description="Expands included common.xml to avoid bugs in schema processors">
          <mkdir dir="${target.dir}"/>
          <delete>
              <fileset dir="${target.dir}" includes="*.xsd"/>
          </delete>
          <style in="src/xsd/logging.xsd" out="${target.dir}/logging.xsd"
                 style="src/xsl/preprocess.xsl"/>
          <style in="src/xsd/log4j.xsd" out="${target.dir}/log4j.xsd"
                 style="src/xsl/preprocess.xsl"/>
          <style in="src/xsd/log4cxx.xsd" out="${target.dir}/log4cxx.xsd"
                 style="src/xsl/preprocess.xsl"/>
          <replace dir="${target.dir}" includes="*.xsd">
              <replacefilter token="xmlns_default" value="xmlns"/>
              <replacefilter token="xmlns_target" value="xmlns:target"/>
          </replace>
      </target>


</project>