<?xml version="1.0" encoding="UTF-8"?>
<!--
	ANT
 
	Copyright 2024-2025 MicroEJ Corp. All rights reserved.
	MicroEJ Corp. PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->
<project name="frontPanelVGInit">

	<dirname file="${ant.file.frontPanelVGInit}" property="frontPanelVGInit.dir"/>

	<import file="${frontPanelVGInit.dir}/../extension-init.xml" />
	<import file="${frontPanelVGInit.dir}/../init-frontpanel/fpinit.xml" />
	
	<!--
		Checks if the Front Panel project fetchs the VG Pack Front Panel (possible since VG Pack 1.6.0)
	-->
	<target name="init/vg/frontpanel/check" depends="init/frontpanel/classpath" if="onS3">
		<property name="vg-frontpanel.name" value="vg-frontpanel"/>

		<pathconvert property="vg-frontpanel.available">
			<first>
				<fileset dir="${fronpanel.mock.dir}" includes="${vg-frontpanel.name}*.jar"/>
			</first>
		</pathconvert>
		<condition property="vg-frontpanel.exclude">
			<not><equals arg1="${vg-frontpanel.available}" arg2=""/></not> 
		</condition>
		
	</target>
	
	<!--
		Checks if we can extract the version of VG Pack Front Panel (possible since VG Pack 1.7.0)
	-->
	<target name="init/vg/frontpanel/version/check/extract" depends="init/vg/frontpanel/check" if="vg-frontpanel.exclude">
		<resourcecount when="greater" count="0" property="vg-frontpanel.version.exists">
			<zipfileset includes="properties/${vg-frontpanel.name}.properties">
				<fileset dir="${fronpanel.mock.dir}" includes="${vg-frontpanel.name}*.jar"/>
			</zipfileset>
		</resourcecount>
		<condition property="vg-frontpanel.version.extract">
			<not><equals arg1="${vg-frontpanel.version.exists}" arg2="0"/></not> 
		</condition>
	</target>
	
	<!--
		Extracts the version of VG Pack Front Panel (possible since VG Pack 1.7.0)
	-->
	<target name="init/vg/frontpanel/version/extract" depends="init/vg/frontpanel/version/check/extract" if="vg-frontpanel.version.extract">
		<extractVersion name="vg-frontpanel" prefix="user" jar="${vg-frontpanel.name}"/>
	</target>
	
	<target name="init/vg/frontpanel" extensionOf="init/context" depends="init/vg/frontpanel/version/extract" if="vg-frontpanel.exclude">
		
		<!-- exclude user ivy dependency "${vg-frontpanel.name}.jar" (already included in microvg-frontpanel.jar) -->
		<excludeJar name="${vg-frontpanel.name}"/>
		
		<!-- retrieve internal and user vg frontpanel version to compare them at runtime -->
		<property name="frontpanel.vg-frontpanel.user.version" value="5.0.0" description="if not already set; only possible value (VG Pack 1.6.x)"/>
		<extractVersion name="vg-frontpanel" prefix="intern" jar="microvg-frontpanel"/>
		
	</target>
	
</project>
