<?xml version="1.0" encoding="UTF-8"?>
<project name="GNUBoatWebApp" default="dist">

	<property name="builddir" value="../../build/webapp" override="true" />

	<target name="prepare">
		<echo msg="Making directory ${builddir}" />
		<mkdir dir="${builddir}"/>
	</target>
	<target name="buildwebclient" depends="prepare">
		<echo msg="Copying files to build directory"/>
		<fileset dir="./webclient" id="filesWebclient">
			<!-- <exclude name=""/> -->
		</fileset>
		<fileset dir="../icon/" id="filesGnuboatIcons">
			<include name="gnuboat-256-256-transparent.png"/>
		</fileset>

		<copy todir="${builddir}/webclient">
			<fileset refid="filesWebclient"/>
		</copy>
		<copy todir="${builddir}/webclient/resources">
			<fileset refid="filesGnuboatIcons"/>
		</copy>
	</target>
	<target name="buildwebservice" depends="prepare">
		<fileset dir="./webservice" id="filesWebservice">
			<exclude name="mbtiles/**"/>
			<exclude name="tests/**"/>
		</fileset>
		<fileset dir="./webservice/mbtiles" id="filesWebserviceMaps">
			<!-- <exclude name=""/> -->
		</fileset>
		
		<copy todir="${builddir}/webservice">
			<fileset refid="filesWebservice"/>
		</copy>
		<copy todir="${builddir}/webservice/maps">
			<fileset refid="filesWebserviceMaps"/>
		</copy>
	</target>

	<fileset dir="${builddir}" id="filesWebApp"/>


	<target name="dist" depends="buildwebservice,buildwebclient,test">
		<echo msg="Creating archive"/>
	<!--	<tar destfile="${builddir}/..//gnuboat-webapp.tar.gz" compression="gzip">
			<fileset refid="filesWebApp"/>
		</tar>-->
		<echo msg="Files copied and compressed in build directory weblcient.tar.gz OK!" />
	</target>
	<target name="testdist" depends="buildwebservice,buildwebclient">
		<echo msg="Install project into ${user.home}/public_html/gnuboat"/>
		<copy todir="${user.home}/public_html/gnuboat">
			<fileset refid="filesWebApp"/>
		</copy>
	</target>

	<target name="test">
		<phpunit bootstrap="webservice/inc/autoloader.php" pharlocation="phpunit-4.8.9.phar" haltonfailure="true" haltonerror="true" printsummary="true">
			<formatter type="plain" usefile="false"/>
			<batchtest>
				<fileset dir="webservice">
					<include name="tests/*Test.php"/>
				</fileset>
			</batchtest>
		</phpunit>
	</target>
</project>
