<!-- 
  The first target is "build_daily". It ends with  manual step.
  The result can then be uploaded to the "/update" folder with "upload_site".
  If the daily build is tested and OK, the target "publish_daily_to_stable_and_main" copies
  it to the current main version field and the default update site folder and then triggers "upload_site".
  
  If the stable site as been updated, the zero installation download can be update via "Check for Updates".
  After the update, the old plugin version should be deleted from the "C:\jac\wudsn\Tools\IDE\Eclipse\4.x.x-win32-x86_64\eclipse\plugins" folder.
  Then the new zero installation download can be created and updated with the "build_and_upload_zero_installation_download" target.
 -->
<project name="Site" basedir="." default="build_daily">


	<target name="_clean_folder">
		<echo message="Cleaning ${folder}" />
		<delete dir="${folder}/features" />
		<delete dir="${folder}/plugins" />
		<delete file="${folder}/artifacts.jar" />
		<delete file="${folder}/content.jar" />
	</target>

	<target name="_copy_folder">
		<antcall target="_clean_folder">
			<param name="folder" value="${target}" />
		</antcall>
		<echo message="Copying ${source} to ${target}" />
		<copy todir="${target}" preservelastmodified="true">
			<fileset file="${source}/artifacts.jar" />
			<fileset file="${source}/content.jar" />
			<fileset file="${source}/site.xml" />
		</copy>
		<copy todir="${target}/features" preservelastmodified="true">
			<fileset file="${source}/features/**" />
		</copy>
		<copy todir="${target}/plugins" preservelastmodified="true">
			<fileset file="${source}/plugins/**" />
		</copy>

	</target>
	
	<!-- This refreshes bundle versions in the source projects-->
	<target name="check_bundle_versions" >
		  <exec dir="." executable="cmd.exe">
		        <arg line="/c check-bundle-versions"/>
		    </exec>
	</target>
		
	<!-- This refreshes the daily build for testing -->
	<target name="build_daily" >
		<antcall target="_clean_folder">
			<param name="folder" value="daily" />
		</antcall>
		<copy tofile="daily\site.xml" preservelastmodified="true" overwrite="true">
			<fileset file="daily/site-template.xml" />
		</copy>
		<echo>Open daily/site.xml and press "Build All". Then run the target "upload_site" to upload the daily version.</echo>
	</target>

	<!-- This publishes the daily build when testing it was successful -->
	<target name="publish_daily_to_stable_and_main">
		<echo>Copying daily to stable and main.</echo>
		<antcall target="_copy_folder">
			<param name="source" value="daily" />
			<param name="target" value="1.7.2" />
		</antcall>
		<antcall target="_copy_folder">
			<param name="source" value="daily" />
			<param name="target" value="." />
		</antcall>
		<antcall target="upload_site" />
		<echo>Done.</echo>
	</target>
	
	<target name="upload_site">
		<echo>Uploading builds from ${basedir}.</echo>
		<exec executable="C:\jac\system\Windows\Tools\NET\WinSCP\WinSCP.com" failonerror="true">
			<arg value="/script=site.scp"/>
		</exec>
		<echo>Upload completed.</echo>
	</target>

	
	<target name="build_and_upload_zero_installation_download">
		<exec executable="C:\jac\wudsn\Tools\WWW\build.bat" failonerror="true">
		</exec>	
	</target>
	
</project>