<?xml version="1.0" encoding="UTF-8"?>
<!--
	ANT
 
  	Copyright 2012-2022 MicroEJ Corp. All rights reserved.
	This library is provided in source code for use, modification and test, subject to license terms.
	Any modification of the source code will break MicroEJ Corp. warranties on the whole library.
-->
<project name="extension.init">

	<!-- Libraries initialization extension point -->
	<extension-point name="init/workbench" description="Initializes some properties before anything else (acts in place of the workbench)." />
	<extension-point name="init/context" depends="init/workbench" description="Initializes some context such as Class availability etc." />
	<extension-point name="init/execution" depends="init/context, mkdirs/application" description="Initializes launch according to context and application."/>
	<extension-point name="init/finalization" description="Computes final values of the 'overall.*' properties given to tools (S3, SOAR, etc.)"/>
	
	<extension-point name="dyninit/workbench" description="Same as init/workbench for dynamic download launches."/>
	<extension-point name="dyninit/context" depends="dyninit/workbench" description="Same as init/context for dynamic download launches."/>
	<extension-point name="dyninit/execution" depends="dyninit/context, mkdirs/application" description="Same as init/execution for dynamic download launches."/>
	<extension-point name="dyninit/finalization" description="Same as init/finalization for dynamic download launches."/>
	
	<!-- Creates output directories -->
	<extension-point name="launch/mkdirs" depends="mkdirs/application"/> <!-- application directory is the base for all others -->

	<!-- Extension point to clean intermediate files generated in output dir -->
	<extension-point name="launch/clean" if="clean.extrafiles"/>
	
	<target name="mkdirs/application">
		<fail unless="output.dir" message="Please define the 'output.dir' property"/>
		<property name="application.output.dir" location="${output.dir}/${application.main.class}"/>
		<delete dir="${application.output.dir}" includes="**/*"/>
		<mkdir dir="${application.output.dir}"/>
		
		<property name="externalResources.output.dir" location="${application.output.dir}/externalResources"/>
		<mkdir dir="${externalResources.output.dir}"/>
	</target>
		
</project>