<project name="evo-app-compile-common" > 
	
	<import file="evo-app-load-properties.xml" />
	
	<!-- BUILD -->
	
	<target name="app-post-build" />
	
	<target name="app-pre-build" />
	
	<target name="app-build" />
	
	<target name="app-prepare" depends="load-properties">
		<echo message="Dealing with package-info.java files (ant compilation problem workaround)" />
		<delete failonerror="false">
			<fileset dir="${app.build.dir}" includes="**/package-info.java"/>
		</delete>
		<!--touch>
			<fileset dir="${app.src.dir}" includes="**/package-info.java"/>
		</touch-->
		<echo message="Copying non-java files to build directory" />
		<copy failonerror="false" overwrite="true" verbose="true" todir="${app.build.dir}" file="${app.version.file}"/>
		<copy verbose="true" failonerror="true" overwrite="true" todir="${app.build.dir}">
			<fileset dir="${app.src.dir}">
				<exclude name="**/*.java" />
				<exclude name="*.java" />
			</fileset>
			<fileset dir="${properties.dir}">
				<include name="app.properties" />
				<include name="**/*" />
			</fileset>
		</copy>
	</target>

	<target name="app-clean" description="Removes all generated files" depends="load-static-properties">
		<delete verbose="true" failonerror="false">
			<fileset dir="${app.build.dir}">
				<include name="**/*" />
			</fileset>
		</delete>
		<delete dir="${app.build.dir}" verbose="true" failonerror="true" />
		<delete dir="${app.dist.dir}" verbose="true" failonerror="true" />
		<delete dir="${app.deploy.dist.dir}" verbose="true" failonerror="true" />
	</target>

	<target name="app-run" description="Runs the application" depends="app-build">
		<java jvmversion="${app.java.version}" classname="${app.main}" maxmemory="${app.max.mem}" classpathref="app.build.classpath" fork="true" dir="${app.build.dir}">
			<jvmarg value="-XX:-UseGCOverheadLimit" />
			<arg value="${app.run.args}"/>
		</java>
	</target>
		
	<!-- JAR -->
	<target name="app-deploy-create-jar" depends="app-clean, app-build" >
		<mkdir dir="${app.deploy.dist.dir}" />
		<jar destfile="${app.deploy.dist.dir}/${app.jar.name}" >
			<fileset dir="${app.build.dir}">
				<include name="**/*" />
			</fileset>
		</jar>
		<copy todir="${app.deploy.dist.lib.dir}">
			<fileset dir="${app.lib.dir}">
				<include name="**/*" />
			</fileset>
		</copy>
	</target>
	
	<target name="app-create-jar" description="Make application Jar" depends="app-clean, app-build"  >
		<pathconvert property="jar.classpath.converted" refid="app.jar.classpath" pathsep=" ">
			<map from="${app.dir}/" to="" />
			<map from="${basedir}/" to="" />
		</pathconvert>
		<mkdir dir="${app.dist.dir}" />
		<jar destfile="${app.dist.dir}/${app.jar.name}">
			<fileset dir="${app.build.dir}">
				<include name="**/*" />
			</fileset>
			<manifest>
				<attribute name="Main-Class" value="${app.main}" />
				<attribute name="Class-Path" value="${jar.classpath.converted}" />
			</manifest>
		</jar>
		<copy todir="${app.dist.lib.dir}">
			<fileset dir="${app.lib.dir}">
				<include name="**/*" />
			</fileset>
		</copy>
	</target>
	
</project>