<project name="test-7z-task" default="all">

	<path id="compile.classpath">
		<pathelement path="."/>
	</path>
	<path id="test.classpath">
		<pathelement path="build"/>
		<pathelement path="lib/7z.jar"/>
	</path>

	
	<target name="compile">
		<mkdir dir="build"/>
		<javac srcdir="src\SevenZip\Compression\LZ" destdir="build" classpathref="compile.classpath" debug="on"/>
		<javac srcdir="src\SevenZip\Compression\RangeCoder" destdir="build" classpathref="compile.classpath" debug="on"/>
		<javac srcdir="src\SevenZip" destdir="build" classpathref="compile.classpath" debug="on" includes="ICodeProgress.java"/>
		<javac srcdir="src\SevenZip\Compression\LZMA" destdir="build" classpathref="compile.classpath" debug="on"/>
		<javac srcdir="src\SevenZip" destdir="build" classpathref="compile.classpath" debug="on"/>
		<javac srcdir="src\org\apache\tools\ant" destdir="build" classpathref="compile.classpath" debug="on"/>
		<javac srcdir="src\LZMA" destdir="build" classpathref="compile.classpath" debug="on"/>
		<javac srcdir="src" destdir="build" classpathref="compile.classpath" debug="on" includes="UnLzma.java"/>
	</target>
	
	<target name="jar">
		<mkdir dir="lib"/>
		<jar destfile="lib/7z.jar" basedir="build"/>
	</target>
	
	<target name="all">
		<antcall target="compile"/>
		<antcall target="jar"/>
	</target>
	
	<target name="test">
		<taskdef name="sevenzip" classname="org.apache.tools.ant.SevenZip" classpath="build"/>
		<echo>------------------------------------------------------------------------------------------------</echo>
		<echo>NOTE: To run the test requires some extra memory to be allocated to the Java Virtual Machine.</echo>
		<echo>This can be done by setting the environment variable 'ANT_OPTS' to '-Xmx256M' before running ant</echo>
		<echo>Otherwise you might find the test fails with 'java.lang.OutOfMemoryError: Java heap space'</echo>
		<echo>------------------------------------------------------------------------------------------------</echo>
		<echo/>
		<mkdir dir="test"/>
		<echo>Compressing resources/test.zip to test/test.lzma</echo>
		<sevenzip task="encode" input="resources/test.zip" output="test/test.lzma"/>
		<echo>Uncompressing test/test.lzma to test/test.zip</echo>
		<sevenzip task="decode" input="test/test.lzma" output="test/test.zip"/>
	</target>
	
	<target name="test-clean">
		<delete dir="test"/>
	</target>

	<target name="compile-clean">
		<delete dir="lib"/>
		<delete dir="build"/>
	</target>
	
	<target name="clean">
		<antcall target="compile-clean"/>
		<antcall target="test-clean"/>
	</target>
</project>