<!-- ===================================================================== -->
<!-- Custom targets called from a project's generated build.xml            -->
<!-- Set customBuildCallbacks=<path/to/this/file> in your build.properties.-->
<!-- ===================================================================== -->
<project name="Build specific targets and properties" default="noDefault">

	<!-- ===================================================================== -->
	<!-- Default target                                                        -->
	<!-- ===================================================================== -->
	<target name="noDefault">
		<echo message="This file must be called with explicit targets" />
	</target>
	
	<!-- ===================================================================== -->
	<!-- Steps to do before the target build.jars                              -->
	<!-- Available parameters :                                                -->
	<!--   build.result.folder - folder to contain the build results           -->
	<!-- ===================================================================== -->
	<target name="pre.build.jars">
	</target>

	<!-- ===================================================================== -->
	<!-- Steps to do after the target build.jars                               -->
	<!-- Available parameters :                                                -->
	<!--   build.result.folder - folder to contain the build results           -->
	<!-- ===================================================================== -->
	<target name="post.build.jars">	
	</target>
	
	<!-- ===================================================================== -->
	<!-- Steps to do before the target build.sources                           -->
	<!-- Available parameters :                                                -->
	<!--   build.result.folder - folder to contain the build results           -->
	<!-- ===================================================================== -->
	<target name="pre.build.sources">
	</target>

	<!-- ===================================================================== -->
	<!-- Steps to do after the target build.sources                            -->
	<!-- Available parameters :                                                -->
	<!--   build.result.folder - folder to contain the build results           -->
	<!-- ===================================================================== -->
	<target name="post.build.sources">
	</target>
	
	<target name="pre.gather.bin.parts" unless="dontFetchBinaries">
		<property file="${basedir}/build.properties" />
		<basename file="${basedir}" property="fragmentName" />
		<available file="/gitroot/equinox/rt.equinox.binaries.git" type="dir" property="gitRepo" value="/gitroot/equinox/rt.equinox.binaries.git" />
		<property name="gitRepo" value="ssh://git.eclipse.org/gitroot/equinox/rt.equinox.binaries.git" />
		
		<echo message="${fragmentName}"/>
		<echo message="${gitRepo}"/>
		<echo message="${binaryTag}"/>
			
		<exec dir="${basedir}" executable="git" output="${basedir}/binary.tar" errorproperty="errorResult" >
			<arg line="archive --format=tar --remote=${gitRepo} ${binaryTag} ${fragmentName}" />
		</exec>
		
		<copy todir="${basedir}">
			<tarfileset includes="${fragmentName}/**" src="${basedir}/binary.tar" />
			<globmapper from="${fragmentName}/*" to="*" />
		</copy>
		
		<delete file="${basedir}/binary.tar" failonerror="false" quiet="true" />
	</target>
	
	<!-- ===================================================================== -->
	<!-- Steps to do after the target gather.bin.parts                         -->
	<!-- Available parameters :                                                -->
	<!--   base.dir - root of the project                                      -->
	<!--   build.result.folder - folder containing the build results           -->
	<!--   target.folder - destination folder                                  -->
	<!-- ===================================================================== -->
	<target name="post.gather.bin.parts">
		<move file="${feature.directory}/target.build.properties" tofile="${feature.directory}/build.properties"/>
		<move file="${feature.directory}/target.build.xml" tofile="${feature.directory}/build.xml"/>
		
		<!-- remove empty directories.  I couldn't get includeEmptyDirs to work -->
		<!-- on the move or delete, so copy, delete and move back               -->
		<copy includeEmptyDirs="false" todir="${feature.directory}/tempBin" >
			<fileset dir="${feature.directory}/bin" />
		</copy>
		<delete dir="${feature.directory}/bin" />
		<move  todir="${feature.directory}/bin" >
			<fileset dir="${feature.directory}/tempBin" />
		</move>
		
		<!-- rename eclipse launchers to "launcher" -->
		<move todir="${feature.directory}/bin" verbose="true">
			<fileset dir="${feature.directory}/bin" />
			<regexpmapper from="^(.*[/\\])eclipse(.exe)?$" to="\1launcher\2"/>
		</move>
		<move todir="${feature.directory}/contributed" verbose="true">
			<fileset dir="${feature.directory}/contributed" />
			<regexpmapper from="^(.*[/\\])eclipse(.exe)?$" to="\1launcher\2"/>
		</move>
	</target>
	
	<!-- ===================================================================== -->
	<!-- Steps to do before the target gather.sources                          -->
	<!-- Available parameters :                                                -->
	<!--   destination.temp.folder - destination folder                        -->
	<!-- ===================================================================== -->
	<target name="pre.gather.sources">
	</target>

	<!-- ===================================================================== -->
	<!-- Steps to do after the target gather.sources                           -->
	<!-- Available parameters :                                                -->
	<!--   destination.temp.folder - destination folder                        -->
	<!-- ===================================================================== -->
	<target name="post.gather.sources">
	</target>

	<!-- ===================================================================== -->
	<!-- Steps to do before the target gather.logs                             -->
	<!-- Available parameters :                                                -->
	<!--   destination.temp.folder - destination folder                        -->
	<!-- ===================================================================== -->
	<target name="pre.gather.logs">        
	</target>

	<!-- ===================================================================== -->
	<!-- Steps to do after the target gather.logs                              -->
	<!-- Available parameters :                                                -->
	<!--   destination.temp.folder - destination folder                        -->
	<!-- ===================================================================== -->
	<target name="post.gather.logs">       
	</target>

	<!-- ===================================================================== -->
	<!-- Steps to do before the target clean                                   -->
	<!-- Available parameters :                                                -->
	<!--   destination.temp.folder - destination folder                        -->
	<!-- ===================================================================== -->
	<target name="pre.clean">              
	</target>

	<!-- ===================================================================== -->
	<!-- Steps to do after the target clean                                    -->
	<!-- Available parameters :                                                -->
	<!--   plugin.destination - final destination of the build                 -->
	<!--   build.result.folder - results of the compilation                    -->
	<!--   temp.folder - temporary folder                                      -->
	<!-- ===================================================================== -->
	<target name="post.clean">             
	</target>
</project>
