<?xml version="1.0" encoding="UTF-8"?>
<project name="documentation-common" xmlns:ivy="antlib:org.apache.ivy.ant">

	<import file="common.xml"/>

<!-- Main targets -->
	<target name="doc-html" depends="docbook.init"
			description="Creates both the single and multi-page HTML versions of the reference documentation.">
		<delete quiet="true" dir="${doc.output.dir}/html"/>
		<delete quiet="true" dir="${doc.output.dir}/htmlsingle"/>
		<mkdir dir="${doc.output.dir}"/>

		<ant antfile="${docbook.dir}/build-docbook.xml" inheritAll="false">
			<property name="dbf.basedir" value="${docbook.dir}"/>
			<property name="docbook.dir" value=""/>
			<property name="docbook.file" value="${ant.project.name}"/>
			<property name="docbook.src.dir" value="${doc.src.dir}"/>
			<property name="images.src.dir" value="${doc.images.dir}"/>
			<property name="src.dir" value="${doc.dir}"/>
			<property name="target.dir" value="${docbook.target.dir}"/>
			<target name="html"/>
			<target name="htmlsingle"/>
		</ant>
		<move file="${docbook.target.dir}/html" todir="${doc.output.dir}"/>
		<move file="${docbook.target.dir}/htmlsingle" todir="${doc.output.dir}"/>

		<delete quiet="true" dir="${docbook.target.dir}"/>
	</target>

	<target name="doc-pdf" depends="docbook.init"
			description="Creates the PDF version of the reference documentation.">
		<delete quiet="true" dir="${doc.output.dir}/pdf"/>
		<mkdir dir="${doc.output.dir}"/>

		<ant antfile="${docbook.dir}/build-docbook.xml" inheritAll="false">
			<property name="dbf.basedir" value="${docbook.dir}"/>
			<property name="docbook.dir" value=""/>
			<property name="docbook.file" value="${ant.project.name}"/>
			<property name="docbook.src.dir" value="${doc.src.dir}"/>
			<property name="images.src.dir" value="${doc.images.dir}"/>
			<property name="src.dir" value="${doc.dir}"/>
			<property name="target.dir" value="${docbook.target.dir}"/>
			<target name="pdf"/>
		</ant>
		<move file="${docbook.target.dir}/pdf" todir="${doc.output.dir}"/>

		<delete quiet="true" dir="${docbook.target.dir}"/>
	</target>

	<target name="doc" depends="docbook.init"
			description="Creates both the single and multi-page HTML versions and the PDF version of the reference documentation.">
		<delete quiet="true" dir="${doc.output.dir}/html"/>
		<delete quiet="true" dir="${doc.output.dir}/htmlsingle"/>
		<delete quiet="true" dir="${doc.output.dir}/pdf"/>
		<mkdir dir="${doc.output.dir}"/>

		<ant antfile="${docbook.dir}/build-docbook.xml" inheritAll="false">
			<property name="dbf.basedir" value="${docbook.dir}"/>
			<property name="docbook.dir" value=""/>
			<property name="docbook.file" value="${ant.project.name}"/>
			<property name="docbook.src.dir" value="${doc.src.dir}"/>
			<property name="images.src.dir" value="${doc.images.dir}"/>
			<property name="src.dir" value="${doc.dir}"/>
			<property name="target.dir" value="${docbook.target.dir}"/>
			<target name="html"/>
			<target name="htmlsingle"/>
			<target name="pdf"/>
		</ant>
		<move file="${docbook.target.dir}/html" todir="${doc.output.dir}"/>
		<move file="${docbook.target.dir}/htmlsingle" todir="${doc.output.dir}"/>
		<move file="${docbook.target.dir}/pdf" todir="${doc.output.dir}"/>

		<delete quiet="true" dir="${docbook.target.dir}"/>
	</target>

<!-- Other targets -->
	<target name="docbook.init" depends="ivy.init">
		<ivy:cachepath resolveId="docbook.framework" pathid="docbook.framework" organisation="org.apache.velocity"
				module="org.apache.velocity.docbookframework.dist"
				revision="${org.apache.velocity.docbookframework.dist.version}" conf="runtime" type="zip" inline="true"
				log="download-only"/>
		<unzip dest="${docbook.dir}">
			<path refid="docbook.framework"/>
			<globmapper from="DocBook-Framework-${org.apache.velocity.docbookframework.dist.version}/*" to="*"/>
		</unzip>
		<ivy:retrieve resolveId="xslthl" pattern="${docbook.dir}/lib/[artifact]-[revision].[ext]"
				organisation="net.sourceforge.xslthl" module="com.springsource.net.sf.xslthl"
				revision="${com.springsource.net.sf.xslthl.version}" conf="runtime" type="jar" inline="true"
				log="download-only"/>
		<ivy:retrieve resolveId="xerces" pattern="${docbook.dir}/lib/[artifact]-[revision].[ext]"
				organisation="org.apache.xerces" module="com.springsource.org.apache.xerces"
				revision="${com.springsource.org.apache.xerces.version}" conf="runtime" type="jar" inline="true"
				log="download-only"/>
	</target>

</project>