<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="buildJar" name="fbreader">
	<property name="src.path" value="src:platform/swing/src"/>
	<property name="bin.dir" value="bin"/>
	<property name="cache.dir" value="depcache"/>
	<property name="icons.dir" value="icons"/>
	<property name="data.dir" value="data"/>
	<property name="test.dir" value="test"/>
	<property name="manifest.file" value="manifest.mf"/>
	<property name="main.jar" value="FBReaderJ.jar"/>

	<target name="prepare">
		<mkdir dir="${bin.dir}" />
	</target>

	<target name="depend" depends="prepare">
		<depend srcdir="${src.path}" destdir="${bin.dir}" cache="${cache.dir}" closure="yes" />
	</target>

	<target name="compile" depends="depend">
		<javac srcdir="${src.path}" destdir="${bin.dir}" />
	</target>

	<target name="buildJar" depends="compile">
		<jar destfile="${main.jar}" manifest="${manifest.file}">
			<fileset dir="${bin.dir}" includes="**/*.class"/>
			<fileset dir="." includes="${icons.dir}/**/*.png"/>
			<fileset dir="." includes="${data.dir}/**"/>
			<fileset dir="platform/swing" includes="${icons.dir}/**/*.png"/>
			<fileset dir="platform/swing" includes="${data.dir}/**"/>
		</jar>
	</target>

	<target name="test" depends="compile">
		<javac srcdir="${test.dir}" destdir="${bin.dir}">
			<classpath>
				<pathelement location="lib/junit.jar"/>
			</classpath>
		</javac>
	</target>

	<target name="runtests" depends="test">
		<junit printsummary="yes" showoutput="yes">
			<classpath>
				<pathelement location="lib/junit.jar"/>
				<pathelement location="${bin.dir}"/>
			</classpath>
			<test name="org.test.zlibrary.model.TestAll"/>
			<test name="org.test.zlibrary.options.TestAll"/>
			<test name="org.test.zlibrary.core.resources.AllTests"/>
			<test name="org.test.fbreader.formats.fb2.AllTests"/>
			<test name="org.test.zlibrary.filesystem.TestALL"/>
			<test name="org.test.fbreader.collection.AllTests"/>
			<test name="org.test.zlibrary.description.AllTests"/>
			<test name="org.test.zlibrary.hyphenation.TestAll"/>
		</junit>
	</target>

	<target name="clean">
		<delete dir="${bin.dir}"/>
		<delete dir="${cache.dir}"/>
		<delete file="${main.jar}"/>
		<delete file="FBReaderJ.jad"/>
		<delete dir="platform/android/res/raw"/>
		<delete dir="platform/android/res/drawable"/>
		<delete file="platform/android/src/org/geometerplus/zlibrary/ui/android/R.java"/>
	</target>
</project>
