<?xml version="1.0" encoding="utf-8" ?>
<project name="rk-init">

  <taskdef name="if" classname="ise.antelope.tasks.IfTask" classpath="${rk.home}/shared/core/lib/AntelopeTasks_3.4.2.jar"/>

	<!-- CHECK PRE-CONDITIONS  -->
	<target name="init">
		<!-- load in static properties from build.properties -->
		<property file="${rk.name}-build.properties" />

		<!-- load environment properties -->
		<property environment="env"/>
		
		<if>
		  <bool><isset property="env.JAVACFLAGS"/></bool>
		  <property name="compile.javac.flags" value="${env.JAVACFLAGS}"/>
		  <else>
		    <property name="compile.javac.flags" value=""/>
		  </else>     
		</if>

		<property name="ext.cli.dir" value="${env.EXT_CLI_DIR}"/>
		<!-- CLASSPATH -->
		<path id="project.classpath">

			<!-- our classes -->
			<fileset dir="${rk.home}/shared/core">
				<include name="ant-tasks/antelope/AntelopeTasks_3.4.2.jar"/>
				<include name="ant-tasks/orangevolt/roxes-win32forjava-1.1.1.jar"/>
				<include name="ant-tasks/orangevolt/orangevolt-ant-tasks-1.3.8.jar"/>
				<include name="ant-tasks/greenstone/anttasks.jar"/>
				<include name="ant-tasks/7z-ant/7z.jar"/>
				<include name="lib/crypt.jar"/>
				<include name="lib/serializer.jar"/>
				<include name="lib/xalan.jar"/>
				<include name="lib/xercesImpl.jar"/>
				<include name="lib/xml-apis.jar"/>
				<include name="ant-installer/lib/ant-installer-ext.jar"/>
				<include name="ant-installer/lib/ant-installer.jar"/>
			</fileset>

		</path>

		<!-- SELF DEFINED TASKS AND TYPES -->
		<taskdef name="if" classname="ise.antelope.tasks.IfTask" classpathref="project.classpath"/>
		<taskdef name="try" classname="ise.antelope.tasks.TryTask" classpathref="project.classpath"/>
		<taskdef name="math" classname="ise.antelope.tasks.MathTask" classpathref="project.classpath"/>
		<taskdef name="sevenzip" classname="org.apache.tools.ant.SevenZip" classpathref="project.classpath"/>
		<taskdef name="installer" classname="org.tp23.antinstaller.taskdefs.Installer" classpathref="project.classpath"/>
		<typedef name="iuv" classname="org.greenstone.anttasks.InsertUniqueValue" classpathref="project.classpath"/>
		<typedef name="rsr" classname="org.greenstone.anttasks.RegexSearchReplace" classpathref="project.classpath"/>
		<typedef name="dcff" classname="org.greenstone.anttasks.DeleteChunkFromFile" classpathref="project.classpath"/>
		<typedef name="pstf" classname="org.greenstone.anttasks.PatternSetToFile" classpathref="project.classpath"/>
		<typedef name="rsplit" classname="org.greenstone.anttasks.SplitResource" classpathref="project.classpath"/>
		<typedef name="get-property-value" classname="org.greenstone.anttasks.GetPropertyValue" classpathref="project.classpath"/>

		<!-- CONSTANTS (overridable in build.properties) -->

		<!-- svn root -->
		<property name="svn.root" value="https://svn.greenstone.org"/>

		<!-- default revision and branch path -->
		<property name="branch.revision" value="HEAD" />
		<property name="branch.path" value="trunk" />

		<!-- where to find gs2-extensions -->
		<property name="svn.gs2.extensions" value="${svn.root}/main/${branch.path}/gs2-extensions"/>
		<!-- where to find gs3-extensions -->
		<property name="svn.gs3.extensions" value="${svn.root}/main/${branch.path}/gs3-extensions"/>
		
		<!-- any global svn args that need to be used in each call - currently we have ones
		     that mean we can ignore the non trusted certificate, which comes up every
		     three months when our SSL certificate is renewed. -->
		<property name="global-svn-args" value="--non-interactive --trust-server-cert"/>
		<!-- the minimum version of java which the installer should be run with (this gets used in search4j) -->
		<property name="java.min.version" value="1.8.0_00"/>

		<!-- create a localised basedir property -->
		<path id="basedir.path"><pathelement location="${basedir}"/></path>
		<property name="basedir.local" refid="basedir.path"/>

		<!-- size of resource chunks (windows wrapper) -->
		<property name="resources.chunksize" value="8388608"/>

		<!-- the extra space for the dmg image in KB (mac wrapper) -->
        	<property name="dmg.overhead" value="24576"/> <!--12288-->

		<!-- current date and time -->
		<tstamp>
			<format property="current.month" pattern="MMM"/>
			<format property="current.year" pattern="yyyy"/>
			<format property="date" pattern="yyyy.MM.dd"/>
		</tstamp>

		<!-- extra features -->
		<property name="version-extra" value="" />
		<property name="post.2.83.version" value="true" />
		<property name="x64" value="false" />

		<if>
		  <bool><equals arg1="${x64}" arg2="true"/></bool>
		  <property name="extension-x64" value="-x64" />
		  <property name="extension_x64" value="_x64" />
		  <else>
		    <property name="extension-x64" value="" />
		    <property name="extension_x64" value="" />
		  </else>
		</if>
		<echo>extension x64 = ${extension_x64}</echo>
		<!-- BUNDLED JAVA INFO -->
		<!-- the bundled javas (JDKs) are kept in shared/mac, shared/linux and shared/windows/wrapper in the repository -->
		<!-- change this info when the bundled version changes -->
		<property name="java.extracted" value="jdk"/> <!-- set this to the name of the top level directory in the above archive -->

		<!-- linux -->
		<property name="linux-java.installer" value="java_bin${extension_x64}"/>
		<property name="bundled.version.linux-java" value="11.0.28"/> <!-- set this to the version number of java in the above archive -->
		<!--<property name="component.bytesize.linux-java" value="62326435"/>--> <!-- set this to the size of the extract archive -->
		<if>
		  <bool><isset property="extension_x64"/></bool>
		  <property name="component.bytesize.linux-java" value="6185607"/> <!-- set this to the size of the extract archive -->
		  <property name="component.bytesize.windows-java" value="23549636"/>
		  <else>
		    <property name="component.bytesize.linux-java" value="62326435"/> <!-- set this to the size of the extract archive -->
		    <property name="component.bytesize.windows-java" value="20843774"/>
		  </else>     
		</if>

		<!-- windows -->
		<property name="windows-java.installer" value="java${extension_x64}.exe"/>
		<property name="bundled.version.windows-java" value="11.0.28"/> <!-- set this to the version number of java in the above archive -->
	<!--	<property name="component.bytesize.windows-java" value="49294486"/> --><!-- set this to the size of the extract archive -->

	<echo>windows java installer = ${windows-java.installer}</echo>
		<!-- mac -->
		<!-- only a java_bin for 64 bit macs -->
		<property name="mac-java.installer" value="java_bin_x64"/>
		<property name="bundled.version.mac-java" value="11.0.28"/> <!-- set this to the version number of java in the above archive -->
		<property name="component.bytesize.mac-java" value="56999802"/> <!-- set this to the size of the archive, NOT the extracted archive, since we'll extract it into the /tmp folder -->

		<!-- version numbers of other bundled things -->
		<property name="bundled.version.imagemagick" value="6.4.3"/>
		<property name="bundled.version.ghostscript" value="8.63"/>
		<property name="bundled.version.tomcat" value="9.0.108"/>
	
		  	
		<!-- DATES IN DIFFERENT LANGUAGES -->
		<get-property-value propertiesFile="${rk.home}/shared/core/lib/dates.properties" propertyName="ar.Dates.${current.month}" outputProperty="month.ar"/>
		<get-property-value propertiesFile="${rk.home}/shared/core/lib/dates.properties" propertyName="ca.Dates.${current.month}" outputProperty="month.ca"/>
		<get-property-value propertiesFile="${rk.home}/shared/core/lib/dates.properties" propertyName="el.Dates.${current.month}" outputProperty="month.el"/>
		<get-property-value propertiesFile="${rk.home}/shared/core/lib/dates.properties" propertyName="es.Dates.${current.month}" outputProperty="month.es"/>
		<get-property-value propertiesFile="${rk.home}/shared/core/lib/dates.properties" propertyName="fr.Dates.${current.month}" outputProperty="month.fr"/>
		<get-property-value propertiesFile="${rk.home}/shared/core/lib/dates.properties" propertyName="lv.Dates.${current.month}" outputProperty="month.lv"/>
		<get-property-value propertiesFile="${rk.home}/shared/core/lib/dates.properties" propertyName="mr.Dates.${current.month}" outputProperty="month.mr"/>
		<get-property-value propertiesFile="${rk.home}/shared/core/lib/dates.properties" propertyName="ro.Dates.${current.month}" outputProperty="month.ro"/>
		<get-property-value propertiesFile="${rk.home}/shared/core/lib/dates.properties" propertyName="ru.Dates.${current.month}" outputProperty="month.ru"/>
		<get-property-value propertiesFile="${rk.home}/shared/core/lib/dates.properties" propertyName="vi.Dates.${current.month}" outputProperty="month.vi"/>
		<get-property-value propertiesFile="${rk.home}/shared/core/lib/dates.properties" propertyName="zh.Dates.${current.month}" outputProperty="month.zh"/>
		<get-property-value propertiesFile="${rk.home}/shared/core/lib/dates.properties" propertyName="default.Dates.${current.month}" outputProperty="month.default"/>


		<!-- version number -->
		<if><bool><not><isset property="version"/></not></bool>
			<fail>Version number not set. Check that the file '${rk.name}-build.properties' exists and defines property 'version'.</fail>
		</if>
		<property name="app.version" value="${version}"/>

		<!-- work out rk.os -->
		<if>
			<bool>
				<or>
					<equals arg1="${rk.os}" arg2="linux"/>
					<equals arg1="${rk.os}" arg2="mac"/>
					<equals arg1="${rk.os}" arg2="windows"/>
				</or>
			</bool>
			<echo>Using user-specified value for rk.os: '${rk.os}'</echo>

		<else><if>
			<bool><equals arg1="${os.name}" arg2="Linux"/></bool>
			<property name="rk.os" value="linux"/>

		<else><if>
			<bool><equals arg1="${os.name}" arg2="Mac OS X"/></bool>
			<property name="rk.os" value="mac"/>

		<else><!--<if>
			<bool>
				<or>
					<equals arg1="${os.name}" arg2="Windows 95"/>
					<equals arg1="${os.name}" arg2="Windows 98"/>
					<equals arg1="${os.name}" arg2="Windows 2000"/>
					<equals arg1="${os.name}" arg2="Windows XP"/>
					<equals arg1="${os.name}" arg2="Windows NT"/>
					<equals arg1="${os.name}" arg2="Windows ME"/>
					<equals arg1="${os.name}" arg2="Windows Vista"/>
					<equals arg1="${os.name}" arg2="Windows 7"/>
				</or>
			</bool>
			<property name="rk.os" value="windows"/>-->
			<if>
				<bool><os family="windows"/></bool>
				<property name="rk.os" value="windows"/>	
			<else>
			<fail>Can't work out what to set rk.os to. Please report this to greenstone_team@cs.waikato.ac.nz . In the mean time, manually set rk.os to 'windows', 'mac', or 'linux' by reinvoking the release kit with, for example, '-Drk.os=windows'</fail>

		</else></if></else></if></else></if></else></if>

		<!-- set os.suffix and os.shell -->
		<if><bool><equals arg1="${rk.os}" arg2="mac"/></bool>
			<exec executable="uname" outputproperty="mac.arch">
				<arg line="-p"/>
			</exec>
			
			<if><bool><equals arg1="${mac.arch}" arg2="powerpc"/></bool>
				<property name="os.suffix" value="MacOS-ppc"/>
				<property name="arch" value="-ppc"/>
			<else>
				<property name="os.suffix" value="MacOS-intel"/>
				<property name="arch" value="-intel"/>
			</else>
			</if>

			<property name="os.shell" value="darwin"/>
		</if>
		<property name="arch" value=""/>

		<property name="os.suffix" value="${rk.os}"/>
		<property name="os.shell" value="${rk.os}"/>

		<!-- set os.script.format -->
		<if><bool><or><equals arg1="${rk.os}" arg2="linux"/><equals arg1="${rk.os}" arg2="mac"/></or></bool>
			<property name="os.script.format" value="sh"/>
		<else><if><bool><equals arg1="${rk.os}" arg2="windows"/></bool>
			<property name="os.script.format" value="bat"/>
		</if></else></if>

		<!-- show important properties -->
		<echo level="info">Version (version): ${version}${version-extra}</echo>
		<echo level="info">Major Version (version.major): ${version.major}</echo>
		<echo level="info">Branch Path (branch.path): ${branch.path}</echo>
		<echo level="info">Date (date): ${date}</echo>
		<echo level="info">Current Month (current.month): ${current.month}</echo>
		<echo level="info">Current Year (current.year): ${current.year}</echo>
		<echo level="info">Operating System (rk.os): ${rk.os}</echo>
		<echo level="info">Operating System Suffix (os.suffix): ${os.suffix}</echo>
		<echo level="info">Operating System Script format (os.script.format): ${os.script.format}</echo>
		<echo level="info">Operating System Shell (os.shell): ${os.shell}</echo>
		<!--
		<echo level="info">Current Date</echo>
		<echo level="info">ar: ${month.ar} ${current.year}</echo>
		<echo level="info">ca: ${month.el} ${current.year}</echo>
		<echo level="info">el: ${month.el} ${current.year}</echo>
		<echo level="info">es: ${month.es} ${current.year}</echo>
		<echo level="info">fr: ${month.fr} ${current.year}</echo>
		<echo level="info">lv: ${month.lv} ${current.year}</echo>
		<echo level="info">mr: ${month.mr} ${current.year}</echo>
		<echo level="info">ro: ${month.ro} ${current.year}</echo>
		<echo level="info">ru: ${month.ru} ${current.year}</echo>
		<echo level="info">vi: ${month.vi} ${current.year}</echo>
		<echo level="info">zh: ${month.zh} ${current.year}</echo>
		<echo level="info">default: (${month.default} ${current.year})</echo>
		-->
	</target>

	<!-- show the core properties of all release-kits -->
	<target name="core-properties">
		<echo>version             (required)  the version string for the release</echo>
		<echo>branch.path         (optional)  the branch of Greenstone to make a release of. Eg: tags/2.81. Default: trunk.</echo>
		<echo>branch.revision     (optional)  the revision of Greenstone to make a release of. Eg: 18273. Default: HEAD.</echo>
	</target>

	<!-- a target to strip any directory of .svn folders -->
	<target name="strip-svn-dirs" unless="${keep.src}">
		<delete includeemptydirs="true">
			<fileset dir="${dir}" defaultexcludes="false">
				<include name="**/.svn/**" />
				<include name="**/.svn/" />
				<include name=".svn/**" />
				<include name=".svn/" />
			</fileset>
		</delete>
	</target>

	<!-- target to insert the uninstaller into 'compiled' and compile it -->
	<target name="insert-and-compile-uninstaller">

		<!-- create working build directory -->
		<mkdir dir="compiled/uninstaller/build/resources" />
		<mkdir dir="compiled/uninstall"/>
		
		<!-- copile to build -->
		<javac includeantruntime="false"
		       srcdir="${rk.home}/shared/core/uninstaller"
		       destdir="compiled/uninstaller/build" >
		  <compilerarg line="${compile.javac.flags}"/>
		</javac>

		<!-- copy language bundle into place -->
		<!-- The nightly windows build stopped prematurely, logs showed that the target insert-and-compile-uninstaller
		did not produce output after:
			[native2ascii] Converting 15 files from C:\greenstone\gs-release-builder\release-kits\shared\core\language-strings
			to c:\greenstone\gs-release-builder\snapshots\gs3-caveat\from-2025.10.02\compiled\uninstaller\build\resources
		
		I had to manually edit shared.xml, target insert-and-compile-uninstaller, to comment out compile.javac.flags
		and change Uninstall.${os.script.format} to Uninstall.bat. Then after running the toplevel set-env.bat, I could run:
		
			c:\greenstone\gs-release-builder\snapshots\gs3-caveat\from-2025.10.02>rk3  insert-and-compile-uninstaller
		
		To finally see the error on which the target failed:
			BUILD FAILED
			C:\greenstone\gs-release-builder\release-kits\shared\core\ant-scripts\shared.xml:294: Error starting Sun's native2ascii:

		It turns out native2ascii no longer available when switching to from Zulu (Open) JDK 8 to 11. (Not available since JDK 9, it seemed)
		
		When searching for: native2ascii openjdk 11, duckduckgo Search Assist stated:
		"The native2ascii tool has been removed from OpenJDK 11 because the newer versions
		support UTF-8 based properties resource bundles, making the conversion tool
		unnecessary. For projects requiring backward compatibility, it's recommended to keep
		an older JDK version installed."
		
		
		So I've copied out the native2ascii ant elements here and in create-installer.xml
		and added an ant copy element instead.
		-->
		
		<!--
		<native2ascii
		       implementation="default"
		       src="${rk.home}/shared/core/language-strings"
		       dest="compiled/uninstaller/build/resources"/>
		-->
		<copy todir="compiled/uninstaller/build/resources" overwrite="true">
			<fileset dir="${rk.home}/shared/core/language-strings" erroronmissingdir="false"/>
		</copy>
		
		<!-- jar it all up -->
		<jar   destfile="compiled/uninstall/uninst.jar"
		       manifest="${rk.home}/shared/core/uninstaller/manifest.mf"
		       basedir="compiled/uninstaller/build" />

		<!-- clean up build directory -->
		<delete dir="compiled/uninstaller"/>

		<!-- put the associated script in place -->
		<copy file="${rk.home}/shared/core/uninstaller/Uninstall.${os.script.format}" todir="compiled/uninstall"/>

	</target>

	<!-- target to set all the version numbers in a greenstone2 or gs2build directory -->
	<target name="gsdl-set-version-numbers">

		<if><bool><available file="${gsdl.basedir}/common-src/src/lib/gsdlconf.h"/></bool>
			<rsr file="${gsdl.basedir}/common-src/src/lib/gsdlconf.h" pattern="(#define GSDL_VERSION) &quot;.*&quot;" replacement="$1 &quot;${version}${version-extra}&quot;" />
		</if>

		<if><bool><available file="${gsdl.basedir}/etc/VERSION"/></bool>
			<rsr file="${gsdl.basedir}/etc/VERSION" pattern="(gsdl version: ).*" replacement="$1${version}${version-extra}" />
		</if>

		<if><bool><available file="${gsdl.basedir}/lib/java/server.properties"/></bool>
			<rsr file="${gsdl.basedir}/lib/java/server.properties" pattern="^(Server2Control.Version[:=]).*" replacement="$1${version}${version-extra}" />
		</if>

		<if><bool><available file="${gsdl.basedir}/lib/java/log4j.properties.in"/></bool>
			<rsr file="${gsdl.basedir}/lib/java/log4j.properties.in" pattern="^(log4j.category.org.greenstone.server[:=].*)INFO(.*)" replacement="$1WARN$2" />
		</if>

		<antcall target="gsdl-set-dates-in-readmes"><param name="gsdl.basedir" value="${gsdl.basedir}"/></antcall>

	</target>

	<!-- target to set dates in readme files -->
	<target name="gsdl-set-dates-in-readmes">

		<!-- en -->
		<if><bool><available file="${gsdl.basedir}/READMEen.txt"/></bool>
			<rsr file="${gsdl.basedir}/READMEen.txt">
				<job pattern="^(Date\s*)(.*)" replacement="$1${month.default} ${current.year}" />
				<job pattern="^(Version\s*)(.*)" replacement="$1${version}${version-extra}" />
			</rsr>
		</if>

		<!-- ar -->
		<if><bool><available file="${gsdl.basedir}/READMEar.txt"/></bool>
			<rsr file="${gsdl.basedir}/READMEar.txt">
				<job pattern="(التاريخ : \s*)(.*)" replacement="$1${month.ar} ${current.year}"/>
				<job pattern="(النسخه : \s*)(.*)" replacement="$1${version}${version-extra}"/>
			</rsr>
		</if>

		<!-- es -->
		<if><bool><available file="${gsdl.basedir}/READMEes.txt"/></bool>
			<rsr file="${gsdl.basedir}/READMEes.txt">
				<job pattern="^(Fecha\s*)(.*)" replacement="$1${month.es} de ${current.year}"/>
				<job pattern="^(Versi.?n\s*)(.*)" replacement="$1${version}${version-extra}"/>
			</rsr>
		</if>

		<!-- fr -->
		<if><bool><available file="${gsdl.basedir}/READMEfr.txt"/></bool>
			<rsr file="${gsdl.basedir}/READMEfr.txt">
				<job pattern="^(Date\s*)(.*)" replacement="$1${month.fr} ${current.year}"/>
				<job pattern="^(Version\s*)(.*)" replacement="$1${version}${version-extra}"/>
			</rsr>
		</if>

		<!-- ru -->
		<if><bool><available file="${gsdl.basedir}/READMEru.txt"/></bool>
			<rsr file="${gsdl.basedir}/READMEru.txt">
				<job pattern="^(Дата\s*)(.*)" replacement="$1${month.ru} ${current.year}"/>
				<job pattern="^(Версия\s*)(.*)" replacement="$1${version}${version-extra}"/>
			</rsr>
		</if>

	</target>

	<!-- target to set version numbers in gli -->
	<target name="gli-set-version-numbers">
		<if><bool><not><equals arg1="${with.gli.and.gems}" arg2="false"/></not></bool>
			<!-- DICTIOANRY FILES (AboutDialog.Date) -->
			<echo level="info">Changing AboutDialog.Date in all dictionaries</echo>

			<rsr file="${glibasedir}/classes/dictionary_ar.properties" pattern="AboutDialog.Date:.*" replacement="AboutDialog.Date:(${month.ar} ${current.year})" />
			<rsr file="${glibasedir}/classes/dictionary_ca.properties" pattern="AboutDialog.Date:.*" replacement="AboutDialog.Date:(${month.ca} de ${current.year})" />
			<rsr file="${glibasedir}/classes/dictionary_el.properties" pattern="AboutDialog.Date:.*" replacement="AboutDialog.Date:(${month.el} ${current.year})" />
			<rsr file="${glibasedir}/classes/dictionary_es.properties" pattern="AboutDialog.Date:.*" replacement="AboutDialog.Date:(${month.es} ${current.year})" />
			<rsr file="${glibasedir}/classes/dictionary_fr.properties" pattern="AboutDialog.Date:.*" replacement="AboutDialog.Date:(${month.fr} ${current.year})" />
			<rsr file="${glibasedir}/classes/dictionary_lv.properties" pattern="AboutDialog.Date:.*" replacement="AboutDialog.Date:(${month.lv} ${current.year})" />
			<rsr file="${glibasedir}/classes/dictionary_mr.properties" pattern="AboutDialog.Date:.*" replacement="AboutDialog.Date:(${month.mr} ${current.year})" />
			<rsr file="${glibasedir}/classes/dictionary_ro.properties" pattern="AboutDialog.Date:.*" replacement="AboutDialog.Date:(${month.ro} ${current.year})" />
			<rsr file="${glibasedir}/classes/dictionary_ru.properties" pattern="AboutDialog.Date:.*" replacement="AboutDialog.Date:(${month.ru} ${current.year})" />
			<rsr file="${glibasedir}/classes/dictionary_vi.properties" pattern="AboutDialog.Date:.*" replacement="AboutDialog.Date:(${month.vi} ${current.year})" />
			<rsr file="${glibasedir}/classes/dictionary_zh.properties" pattern="AboutDialog.Date:.*" replacement="AboutDialog.Date:(${month.zh} ${current.year})" />
			<rsr file="${glibasedir}/classes/dictionary.properties" pattern="AboutDialog.Date:.*" replacement="AboutDialog.Date:(${month.default} ${current.year})" />

			<!-- GLI GATHERER -->
			<echo level="info">Changing version number in gli Gatherer</echo>
			<rsr file="${glibasedir}/src/org/greenstone/gatherer/Gatherer.java" pattern="^(.*)String\s*PROGRAM_VERSION\s*=\s*&quot;(.*)&quot;" replacement="$1String PROGRAM_VERSION = &quot;${version}${version-extra}&quot;"/>

			<!-- CONFIG XML FILES -->
			<echo level="info">Changing configuration version in classes/xml/config.xml</echo>
			<rsr file="${glibasedir}/classes/xml/config.xml" pattern="^(\s*&lt;Configuration.* version=&quot;)[^&quot;]*(&quot;.*&gt;)" replacement="$1${version}${version-extra}$2"/>

			<echo level="info">Changing configuration version in gli/classes/xml/configRemote.xml</echo>
			<rsr file="${glibasedir}/classes/xml/configRemote.xml" pattern="^(\s*&lt;Configuration.* version=&quot;)[^&quot;]*(&quot;.*&gt;)" replacement="$1${version}${version-extra}$2"/>
		</if>
	</target>

	<!-- target to tidy gli up for distribution -->
	<target name="gli-tidy-for-dist" unless="${keep.src}">
		<!-- delete unneeded things -->
		<delete file="${glibasedir}/.greenstonestore"/>		
		<delete dir="${glibasedir}/classes/META-INF"/>
		<delete dir="${glibasedir}/classes/org"/>
		<delete dir="${glibasedir}/classes/images"/>
		<delete dir="${glibasedir}/jar"/>
	</target>


	<!-- target to archive and compress a given component -->
	<target name="create-component">
		<mkdir dir="components"/>
		
		<!-- the PatternSet To File task takes one or more patternsets and outputs to a file all of the files it includes -->
		<pstf dir="compiled" outfile="compiled/uninstall/${component}.uninstall" toplevelonly="true">
			<patternset refid="greenstone${version.major}.${component}${ext-x64}.component"/>
		</pstf>
	  
		<zip destfile="components/${component}.comp" compress="false">
			<zipfileset dir="compiled">
				<patternset refid="greenstone${version.major}.${component}${ext-x64}.component"/>
			</zipfileset>
		</zip>
	
		<!-- windows -->
		<if><bool><equals arg1="${rk.os}" arg2="windows"/></bool>
	    <exec executable="${rk.home}/shared/windows/7za/7za.exe" dir="components"><arg line="a -t7z -mx=9 ${component}.lzma ${component}.comp"/></exec>
	    
	    <!-- linux, mac -->
	    <else><if><bool><or><equals arg1="${rk.os}" arg2="linux"/><equals arg1="${rk.os}" arg2="mac"/></or></bool>
		<sevenzip task="encode" input="components/${component}.comp" output="components/${component}.lzma" dictionnary="26"/>
		
		<!-- else warn -->
		<else>
		  <fail>this target does not support this os (was a new release-kit os added?)</fail>
		  
	  </else></if></else></if>
	</target>
	
</project>
