<?xml version="1.0" encoding="UTF-8"?><!--
     Copyright (c) 2009 Thales Corporate Services S.A.S.
     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:
         Thales Corporate Services S.A.S - initial API and implementation
 -->

<project name="EGF  Engine Doc Build" default="all" basedir=".">

	<target name="init">
		<available file="${basedir}/index" property="index.present"/>
	</target>

	<target name="all" depends="init" unless="index.present">
		<antcall target="convertSchemaToHtml"/>
		<antcall target="generateJavadoc"/>
	</target>

	<target name="convertSchemaToHtml" if="eclipse.running">
		<property name="dest" value="html/reference/extension-points"/>

		<record name="${basedir}/platformconvert.txt" action="start"/>
		<pde.convertSchemaToHTML manifest="../org.eclipse.egf.common/plugin.xml" destination="${dest}"/>
		<pde.convertSchemaToHTML manifest="../org.eclipse.egf.model/plugin.xml" destination="${dest}"/>
		<pde.convertSchemaToHTML manifest="../org.eclipse.egf.pde/plugin.xml" destination="${dest}"/>
		<pde.convertSchemaToHTML manifest="../org.eclipse.egf.core/plugin.xml" destination="${dest}"/>
		<pde.convertSchemaToHTML manifest="../org.eclipse.egf.pattern/plugin.xml" destination="${dest}"/>
		<pde.convertSchemaToHTML manifest="../org.eclipse.egf.pattern.ui/plugin.xml" destination="${dest}"/>
		<record name="${basedir}/platformconvert.txt" action="stop"/>
	</target>

	<target name="getJavadocPath">
		<available file="${java.home}/../bin/javadoc.exe" property="javadoc" value="${java.home}/../bin/javadoc.exe"/>
		<available file="${java.home}/../bin/javadoc" property="javadoc" value="${java.home}/../bin/javadoc"/>
	</target>

	<target name="generateJavadoc" depends="getJavadocPath" if="javadoc">

		<property name="optionsFile" value="platformOptions.tmp.txt"/>
		<copy file="platformOptions.txt" tofile="${optionsFile}" overwrite="true"/>
		
		<condition property="argsListDelimiter" value=":">
			<os family="unix"/>
		</condition>
		<condition property="argsListDelimiter" value=";">
			<os family="windows"/>
		</condition>
		
		<replaceregexp file="${basedir}/${optionsFile}" flags="g" match="(\r\n?|\n);" replace="${argsListDelimiter}"/>
		<replace file="${basedir}/${optionsFile}" token="@rt@" value="${bootclasspath}"/>

		<!--scrub isv plugin directories of any preexisting api doc content-->
		<delete dir="html/reference/javadoc"/>
		<mkdir dir="html/reference/javadoc"/>

		<exec dir="." executable="${javadoc}" output="doc.bin.log">
			<arg line="@${basedir}/${optionsFile} -J-Xmx256M"/>
		</exec>
		
		<!--workaround for bug 101048-->
		<replace dir="html/reference/javadoc" token="=&quot;/../misc/api-usage-rules.html" value="=&quot;./../misc/api-usage-rules.html">
			<include name="*htm*"/>
		</replace>

	</target>

	<target name="createDocZip">
		<zip zipfile="${basedir}/doc.zip" basedir="${basedir}" includes="book.css, notices.html, about.html, concepts/**, gettingStarted/**, images/**, reference/**, porting/**, tasks/**,samples/**,guide/**,questions/**"/>
	</target>
</project>