<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (c) 2005, 2008 IBM Corporation and others.
    All rights reserved. This program and the accompanying materials
    are made available under the terms of the Eclipse Public License v1.0
    which accompanies this distribution, and is available at
    http://www.eclipse.org/legal/epl-v10.html
   
    Contributors:
        IBM Corporation - initial API and implementation
 -->

<project name="org.eclipse.draw2d.doc.isv" default="build.jars" basedir=".">
	
	<property name="p2.build.repo" value="file:${buildDirectory}/buildRepo"/>

	<condition property="p2.publish.parts" value="true">
	  <istrue value="${p2.gathering}"/>
	</condition>
	
	
	<path id="path_bootclasspath">
		<fileset dir="${java.home}/lib">
			<include name="*.jar" />
		</fileset>
	</path>
	<property name="bootclasspath" refid="path_bootclasspath" />

	<target name="init">
		<property name="plugin" value="org.eclipse.draw2d.doc.isv" />
		<property name="version.suffix" value="3.2.0" />
		<property name="full.name" value="${plugin}_${version.suffix}" />
		<property name="temp.folder" value="${basedir}/temp.folder" />
		<property name="plugin.destination" value="${basedir}" />
		<property name="build.result.folder" value="${basedir}" />
	</target>

	<target name="build.update.jar" depends="init">
		<delete dir="${temp.folder}" />
		<mkdir dir="${temp.folder}" />
		<antcall target="build.jars" />
		<antcall target="gather.bin.parts">
			<param name="destination.temp.folder" value="${temp.folder}/" />
		</antcall>
		<zip zipfile="${plugin.destination}/${full.name}.jar" basedir="${temp.folder}/${full.name}" filesonly="false" />
		<delete dir="${temp.folder}" />
	</target>
	
	<target name="publish.bin.parts" depends="init" if="p2.publish.parts" unless="compilation.problem.marker.exists">
		<mkdir dir="${destination.temp.folder}/${full.name}"/>
		<copy todir="${destination.temp.folder}" failonerror="true" overwrite="true">
			<fileset dir="${basedir}" includes="about.html,*.properties,*.xml,META-INF/**,index.html,guide.html,notices.html,reference.html,book.css,guide/**,examples/**,reference/**" excludes="build.properties,build*.xml" />
		</copy>
		<eclipse.versionReplacer path="${destination.temp.folder}" version="${version.suffix}"/>
		<!--
		<antcall target="apitools.generation">
			<param name="target.folder" value="${destination.temp.folder}"/>
			<param name="projectLocation" value="${basedir}"/>
			<param name="binary.folders" value="${destination.temp.folder}/@dot"/>
			<param name="projectName" value="${full.name}"/>
		</antcall>
		-->
		<eclipse.gatherBundle 
		   metadataRepository="${p2.build.repo}"
		   artifactRepository="${p2.build.repo}"
		   buildResultFolder="${destination.temp.folder}"
		   unpack="false"
		   baseDirectory="${basedir}"
		/>
	</target>

	<target name="gather.bin.parts" depends="init" if="destination.temp.folder">
		<ant antfile="buildDoc.xml" />
		<mkdir dir="${destination.temp.folder}/${full.name}" />
		<copy todir="${destination.temp.folder}/${full.name}">
			<fileset dir="${basedir}" includes="about.html,*.properties,*.xml,META-INF/**,book.css,reference/**,guide/**," excludes="build.properties,build*.xml" />
		</copy>
		<eclipse.versionReplacer path="${destination.temp.folder}/${full.name}" version="${version.suffix}" />
	</target>

	<target name="build.jars" depends="init">
	</target>

	<target name="gather.sources" depends="init" if="destination.temp.folder">
	</target>

	<target name="build.sources" depends="init">
	</target>

	<target name="gather.logs" depends="init" if="destination.temp.folder">
		<mkdir dir="${destination.temp.folder}/${full.name}" />
		<copy file="${plugin.destination}/doc.bin.log" todir="${destination.temp.folder}/${full.name}" overwrite="true" failonerror="false" flatten="true" />
	</target>

	<target name="clean" depends="init">
		<delete file="${plugin.destination}/${full.name}.jar" />
		<delete file="${plugin.destination}/${full.name}.zip" />
		<delete dir="${temp.folder}" />
	</target>

	<target name="refresh" depends="init" if="eclipse.running">
		<eclipse.refreshLocal resource="${plugin}" depth="infinite" />
	</target>

	<target name="zip.plugin" depends="init">
		<delete dir="${temp.folder}" />
		<mkdir dir="${temp.folder}" />
		<antcall target="build.jars" />
		<antcall target="build.sources" />
		<antcall target="gather.bin.parts">
			<param name="destination.temp.folder" value="${temp.folder}/" />
		</antcall>
		<antcall target="gather.sources">
			<param name="destination.temp.folder" value="${temp.folder}/" />
		</antcall>
		<delete>
			<fileset dir="${temp.folder}" includes="**/*.bin.log" />
		</delete>
		<zip zipfile="${plugin.destination}/${full.name}.zip" basedir="${temp.folder}" filesonly="true" />
		<delete dir="${temp.folder}" />
	</target>

</project>