<!--
  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="log4j-concurrent" default="dist" 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.3alpha8"/>
	  <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"/>
	
	  <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="jar" depends="compile" description="Prepare jar">	    
	    <delete file="${target.dir}/log4j-concurrent-${version}.jar"/>
	    <mkdir dir="${target.dir}/"/>
	    
	    <jar jarfile="${target.dir}/log4j-concurrent-${version}.jar" 
	    	 basedir="${classes.dir}">
	      <manifest>
	        <attribute name="Manifest-version" value="1.0"/>
	        <section name="org/apache/log4j/formatter/">
	          <attribute name="Implementation-Title" value="Concurrent appenders for log4j 1.3"/>
	          <attribute name="Implementation-Version" value="${version}"/>
	          <attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
	        </section>
	      </manifest>
	    </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" description="Run tests">
	    <junit printsummary="yes" 
	    	fork="yes">
	  	  <classpath path="${test-classes.dir};${classes.dir};${log4j.jar};${junit.jar}"/>
	  	  <formatter type="plain" usefile="false"/>
	  	  <batchtest>
	  	    <fileset dir="src/test/java" 
	  	    	includes="**/*.java"/>
	  	  </batchtest>
	    </junit>
	  </target>

	 <target name="javadoc" description="Prepare Javadocs">	    
	    <mkdir dir="${target.dir}/javadoc" />	    
	    <javadoc
	             destdir="${target.dir}/javadoc"
	             packagenames="org.apache.log4j.concurrent"
	             version="true"
	             author="true"
	             use="true"
	             doctitle="log4j concurrent version ${version}&lt;br&gt;API Specification"
	             windowtitle="Log4j Concurrent Version ${version}"
	             bottom="Copyright 2006 Apache Software Foundation.">
	         <sourcepath>
	            <pathelement path="src/main/java"/>
	         </sourcepath>
	        <classpath path="${log4j.jar}"/>
	    </javadoc>
	 </target>
	
	  <target name="dist" depends="test, jar, javadoc"
	     description="Prepare distribution">
	    <tar tarfile="${target.dir}/logging-log4j-concurrent-${version}.tar.gz"
	         compression="gzip"
	         longfile="gnu">
	    	 <tarfileset dir="." 
	  				prefix="logging-log4j-concurrent-${version}"
	  	            excludes="target/** .* .settings/**"/>
	    	 <tarfileset dir="target" 
	  				prefix="logging-log4j-concurrent-${version}"
	  	            includes="*.jar javadoc/**"/>
	    </tar>
	  </target>

</project>