<?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/**"/>
			<exclude name="config/**"/>
		</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,test">
		<echo msg="Install project into ${user.home}/public_html/gnuboat"/>
		<fileset id="filesConfig" dir="./webservice/config">
			<include name="config.php"/>
		</fileset>
		<fileset id="filesLogs" dir="./webservice/tests/logs">
			<include name="*.log"/>
		</fileset>
	
		<copy todir="${user.home}/public_html/gnuboat">
			<fileset refid="filesWebApp"/>
		</copy>
		<copy todir="${user.home}/public_html/gnuboat/webservice/tests/logs">
			<fileset refid="filesLogs"/>
		</copy>
		<copy todir="${user.home}/public_html/gnuboat/webservice/config">
			<fileset refid="filesConfig"/>
		</copy>
	</target>

	<target name="test">
		<exec command="php phpunit-4.8.9.phar" passthru="true" checkreturn="true"/>
		<!--<phpunit pharlocation="phpunit-4.8.9.phar" configuration="phpunit.xml" haltonfailure="true" haltonerror="true" printsummary="true" codecoverage="false">
			<formatter type="plain" usefile="false"/> -->
			<!--<formatter type="JUnit" usefile="true"/>-->
<!--			<batchtest>
				<fileset dir="webservice">
					<include name="tests/*Test.php"/>
				</fileset>
			</batchtest>
		</phpunit>-->
	</target>
</project>
