<!--
	~  build.xml Copyright (C) 2019 Daniel H. Huson
	~
	~  (Some files contain contributions from other authors, who are then mentioned separately.)
	~
	~  This program is free software: you can redistribute it and/or modify
	~  it under the terms of the GNU General Public License as published by
	~  the Free Software Foundation, either version 3 of the License, or
	~  (at your option) any later version.
	~
	~  This program is distributed in the hope that it will be useful,
	~  but WITHOUT ANY WARRANTY; without even the implied warranty of
	~  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	~  GNU General Public License for more details.
	~
	~  You should have received a copy of the GNU General Public License
	~  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
	<project name="MEGAN" default="jar" basedir=".">

		<property name="ant.build.javac.source" value="13"/>
		<property name="ant.build.javac.target" value="13"/>

		<property name="jfxDir" value="../../javafx/lib"/>
		<property name="jlodaAntDir" value="../../jloda/antbuild"/>
		<property name="buildSrcDir" value="../antbuild/src"/>
		<property name="buildModulesDir" value="../antbuild/modules"/>

		<path id="build.classpath">
			<fileset dir="../../megan-ce/jars"  includes="*.jar"/>
			<fileset dir="${jlodaAntDir}"  includes="jloda.jar"/>
		</path>

		<path id="build.modulepath">
			<fileset dir="../../jloda/jars"  includes="*.jar"/>
			<fileset dir="../../megan-ce/jars"  includes="*.jar"/>
			<fileset dir="${jfxDir}"  includes="*.jar"/>
			<fileset dir="../antbuild"  includes="jloda.jar"/>
		</path>

		<path id="run.modulepath">
			<fileset dir="../../jloda/jars"  includes="*.jar"/>
			<fileset dir="../../megan-ce/jars"  includes="*.jar"/>
			<fileset dir="${jfxDir}"  includes="*.jar"/>
			<fileset dir="../antbuild"  includes="jloda.jar"/>
			<fileset dir="../antbuild"  includes="megan.jar"/>
		</path>

		<target name="init">
			<mkdir dir="${buildSrcDir}/megan"/>
			<mkdir dir="${buildModulesDir}/megan"/>
		</target>

		<target name="jloda" depends="init">
			<ant antfile="${jlodaAntDir}/build.xml" target="jar"/>
		</target>

		<target name="copy_sources" depends="jloda">
			<copy todir="${buildSrcDir}/megan">
				<fileset dir="../../megan-ce/src"/>
			</copy>
		</target>

		<target name="copy_resources" depends="copy_sources">
			<copy todir="${buildModulesDir}/megan">
				<fileset dir="../../megan-ce/src"
				includes="**/*.html **/*.fxml **/*.png **/*.gif **/*.css **/*.txt **/*.map **/*.info **/*.tre **/*.lvl"/>
			</copy>
		</target>

		<target name="compile" depends="copy_resources">
			<javac  includeantruntime="false"
				srcdir="../antbuild/src/megan"
				destdir="${buildModulesDir}/megan"
				debug="on"
				modulepathref="build.modulepath"
				>
			</javac>
		</target>

		<target name="jar" depends="compile">
			<jar jarfile="megan.jar" basedir="${buildModulesDir}/megan"/>
		</target>

		<target name="run" depends="jar">
			<java classname="megan.main.Megan6" fork="true"
				modulepathref="run.modulepath">
				<jvmarg value="-Xshare:off"/>
				<jvmarg value="-Dapple.laf.useScreenMenuBar=true"/>
				<jvmarg value="-server"/>
				<jvmarg value="-Xmx4G"/>
				<jvmarg value="-Duser.language=en"/>
				<jvmarg value="-Duser.region=US"/>
				<jvmarg value="--add-modules=jloda,megan"/>
				<arg value="+w"/>
			</java>
		</target>

		<target name="clean">
			<delete dir="${buildModulesDir}" includeEmptyDirs="true"/>
			<delete dir="${buildSrcDir}" includeEmptyDirs="true"/>
			<delete file="megan.jar"/>
			<delete file="jloda.jar"/>
		</target>

	</project>

