<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="all" name="Compile and build java classes plus jar archives">

	<target name="all" depends="clean,build,pack,create_run_jar,create_release_zip" />

	<target name="clean">
		<delete>
			<fileset dir="bin">
				<include name="**" />
			</fileset>
		</delete>
	</target>

	<target name="build">
		<javac srcdir="src" destdir="bin" target="1.5" debug="true">
			<include name="org/openstreetmap/gui/jmapviewer/**" />
		</javac>

		<copy todir="bin">
			<fileset dir="src">
				<include name="**/*.png" />
			</fileset>
		</copy>
	</target>

	<target name="pack">
		<delete file="JMapViewer.jar" />
		<delete file="JMapViewer_src.jar" />
		<!-- Create the JAR file containing the compiled class files -->
		<jar destfile="JMapViewer.jar" filesetmanifest="mergewithoutmain">
			<fileset dir="bin" includes="**/jmapviewer/**" />
		</jar>
		<!-- Create the JAR file containing the source java files -->
		<jar destfile="JMapViewer_src.jar" filesetmanifest="mergewithoutmain">
			<fileset dir="src" includes="**/jmapviewer/**" />
		</jar>
	</target>

	<target name="create_run_jar" description="Create a JAR file that can be used to excute the JMapViewer demo app. Requires JMapViewer.jar to be present.">
		<delete file="JMapViewer_Demo.jar" />
		<jar destfile="JMapViewer_Demo.jar" filesetmanifest="mergewithoutmain">
			<manifest>
				<attribute name="Main-Class" value="org.openstreetmap.gui.jmapviewer.Demo" />
				<attribute name="Class-Path" value="JMapViewer.jar" />
			</manifest>
		</jar>
	</target>

	<target name="create_release_zip" description="Create a release zip file containing the binary and source jar files as well as the demo starter">
		<delete file="JMapViewer.zip" />
		<zip basedir="." destfile="JMapViewer.zip">
			<include name="JMapViewer*.jar" />
			<include name="Readme.txt" />
			<include name="Gpl.txt" />
		</zip>
	</target>

</project>
