<project default="main">
    <property file="build.properties"/>
    <target name="main">
    	<available property="haveBaseLocation" file="${baseLocation}"/>
        <fail unless="haveBaseLocation" message="Please set the base location for the eclipse installation." />
    	
    	<available property="haveBuildDirectory" file="${buildDirectory}"/>
        <fail unless="haveBuildDirectory" message="Please set the build location." />
    	
        <!-- Check that we have a deltapack -->
        <available property="haveDeltaPack" file="${deltapack}"/>
        <fail unless="haveDeltaPack" message="The deltapack is required to build this product.  Please set the &quot;deltapack&quot; property." />

        <property name="builder" value="${basedir}" />
        <property name="buildDirectory" value="${basedir}/buildDirectory"/>
        <property name="pluginPath" value="${basedir}/..${path.separator}${deltapack}" />
        <property name="buildTempFolder" value="${buildDirectory}" />

        <!-- clear previous builds -->
        <delete quiet="true">
			<fileset dir="${updatesDir}"/>
        </delete>
        <delete quiet="true">
			<fileset dir="${binariesDir}/${buildLabel}"/>
        </delete>

        <ant antfile="${eclipse.pdebuild.scripts}/productBuild/productBuild.xml" />

        <move todir="${binariesDir}/${buildLabel}">
            <fileset dir="${buildDirectory}/${buildLabel}" includes="*.zip"/>
        </move>

    	<move todir="${updatesDir}">
    	     <fileset dir="${buildDirectory}/repository"/>
        </move>

		<signjar alias="wesnoth" keystore="keystore" storepass="${storePass}" keypass="${keyPass}">
		  <path>
			<fileset dir="${updatesDir}" includes="**/org.wesnoth*.jar" />
		  </path>
		</signjar>

        <!-- remove non-wesnoth plugins -->
        <delete>
            <fileset dir="${updatesDir}/plugins">
            	<exclude name="org.wesnoth*"/>
        	</fileset>
        </delete>
    </target>
</project>
