<?xml version="1.0" encoding="UTF-8"?>
<project name="jModelTest" default="jar" basedir=".">

	<property name="src.dir" location="src/main/java" />
	<property name="build.base.dir" location="build" />
  <property name="build.dir" location="${build.base.dir}/classes" />
	<property name="lib.dir" location="lib" />
	<property name="dist.dir" location="dist" />
  <property name="exe.dir" location="${dist.dir}/exe/phyml" />
	<property name="log.dir" location="${dist.dir}/log" />
	<property name="manual.dir" location="manual" />
	<property name="src.resources.dir" location="src/main/resources" />
	<property name="html.template.dir" location="${src.resources.dir}/resources" />

	<property name="jarfile" location="${dist.dir}/${ant.project.name}.jar" />
	<property name="compile.debug" value="false" />

	<fileset id="lib.jars" dir="${lib.dir}">
		<include name="**/*.jar" />
	</fileset>

	<path id="lib.path">
		<fileset refid="lib.jars" />
	</path>

	<!-- Stub install target.  Install should depend on the 'jar' target,
         and copy the built objects to the 'dist' directory. -->
	<target name="install" description="Install jar" depends="jar">
	</target>

	<target name="compile" description="Compile code">
		<mkdir dir="${build.dir}" />
		<mkdir dir="${lib.dir}" />
		<property environment="env" />
		<property name="java6.boot.classpath" value="${env.JAVA6_BOOTCLASSES}" />
		<javac srcdir="${src.dir}" destdir="${build.dir}" includeAntRuntime="no" 
			target="1.6" source="1.6" bootclasspath="${java5.boot.classpath}"
			classpathref="lib.path" debug="${compile.debug}">
			<compilerarg value="-Xlint:all"/>
		</javac>
	</target>

	<target name="jar" depends="compile" description="Build jar">
		<mkdir dir="${dist.dir}" />
		<jar jarfile="${jarfile}" basedir="${build.dir}" manifest="Manifest">
			<fileset dir="${src.dir}" includes="**/*.xml,**/*.properties,**/*.gif,**/*.ico" />
			<!-- Merge library jars into final jar file
      <zipgroupfileset refid="lib.jars"/>-->
		</jar>
		<mkdir dir="${dist.dir}/lib" />
		<copy todir="${dist.dir}/lib">
			<fileset id="lib.jars" dir="${lib.dir}">
				<include name="**/*.jar" />
			</fileset>
		</copy>
		<copy todir="${dist.dir}">
			<fileset dir="${src.resources.dir}">
				<include name="**/*" />
			</fileset>
		</copy>
		<mkdir dir="${log.dir}" />
		<chmod perm="755" dir="${dist.dir}" includes="*.sh *.bat" />
    <chmod perm="644" dir="${exe.dir}" includes="*" />
	</target>

	<target name="run" depends="jar" description="Run jar file">
		<java jar="${jarfile}" fork="yes" failonerror="true" />
	</target>

	<target name="clean" description="Remove build and dist directories">
		<delete dir="${build.base.dir}" />
		<delete dir="${dist.dir}" />
		<delete dir="${manual.dir}" includes="*.aux *.bbl *.out *.toc *.log *.blg *.dvi" />
	</target>
</project>
