<!--
// This file is part of MicropolisJ.
// Copyright (C) 2013 Jason Long
// Portions Copyright (C) 1989-2007 Electronic Arts Inc.
//
// MicropolisJ is free software; you can redistribute it and/or modify
// it under the terms of the GNU GPLv3, with additional terms.
// See the README file, included in this distribution, for details.
-->
<project name="micropolisj" default="all">

<property name="package-version" value="1.4" />

<property name="srcdir" location="src" />
<property name="builddir" location="build" />
<property name="distfile" value="${ant.project.name}.jar" />
<property name="zipfile" value="${ant.project.name}-${package-version}.zip" />

<path id="build-classpath">
  <fileset dir="extlib">
    <include name="*.jar" />
  </fileset>
</path>

<target name="init-builddir">
<mkdir dir="${builddir}" />
<mkdir dir="extlib" />
</target>

<target name="copy-resources" depends="init-builddir">
<copy todir="${builddir}">
	<fileset dir="resources"
		excludes="**/*.xcf **/Thumbs.db"
		/>
</copy>
<native2ascii encoding="UTF-8" ext=".properties"
	src="strings"
	includes="**/*.utf8"
	dest="${builddir}/micropolisj"
	/>

<copy todir="${builddir}/micropolisj">
	<fileset dir="strings" excludes="**/*.utf8" />
</copy>
</target>

<target name="compile" depends="init-builddir">
<javac srcdir="${srcdir}"
       destdir="${builddir}"
       classpathref="build-classpath"
	includeantruntime="false"
	debug="true" debuglevel="lines,vars,source"
	source="1.6" target="1.6"
       >
	<compilerarg value="-Xlint:unchecked" />
	<compilerarg value="-Xlint:deprecation" />
</javac>
</target>

<target name="build" depends="copy-resources,compile">
<pathconvert property="runtime-classpath" pathsep=" " refid="build-classpath">
<map from="${basedir}" to="." />
</pathconvert>

<jar destfile="${distfile}" basedir="${builddir}">
	<manifest>
		<attribute name="Main-Class" value="micropolisj.Main" />
		<attribute name="Class-Path" value="${runtime-classpath}" />
		<attribute name="Implementation-Version" value="${package-version}" />
	</manifest>
</jar>
</target>

<target name="all" depends="build">
</target>

<target name="clean">
<delete dir="${builddir}" />
<delete file="${distfile}" />
<delete>
	<fileset dir="." includes="${ant.project.name}*.zip" />
</delete>
</target>

<target name="dist" depends="build">
<zip destfile="${zipfile}">
	<fileset dir="." includes="${distfile}, ${ant.project.name}.ico, README, COPYING" />
</zip>
</target>

<target name="javadoc">
<mkdir dir="docs/api" />
<javadoc sourcepath="src" destdir="docs/api"
	classpathref="build-classpath"
	Private="true"
	>
	<link href="http://docs.oracle.com/javase/7/docs/api" />
	<link href="http://docs.oracle.com/cd/E17802_01/j2se/javase/technologies/desktop/java3d/forDevelopers/J3D_1_3_API/j3dapi" />
</javadoc>
</target>

</project>
