blob: ae859030b9e10df65c93f93343cea6174956a6fd [file] [log] [blame]
<!--
Some of the code below is
(c) Chris Aniszczyk <caniszczyk@gmail.com>
(c) Lawrence Mandel <lmandel@ca.ibm.com>
(c) Peter Friese <peter.friese@itemis.com>
(c) Patrick Schönbach <patrick.schoenbach@itemis.de>
-->
<project name="org.eclipse.xpand.doc" default="build-doc" basedir=".">
<!--
Global vars
-->
<property name="document.name" value="xpand_reference" />
<property name="src.dir" value="${basedir}/src/5.0/structure" />
<property name="images.dir" value="${basedir}/src/5.0/content/images" />
<property name="styles.dir" value="src/styles" />
<property name="xslt.dir" value="${styles.dir}/xslt" />
<property name="css.dir" value="${styles.dir}/css" />
<property name="document.stylesheet" value="${xslt.dir}/article.xsl" />
<property name="document.pdf.stylesheet" value="${xslt.dir}/xmpp.xsl" />
<property name="document.eclipse.stylesheet"
value="${xslt.dir}/eclipsehelp.xsl" />
<property name="html-css.file" value="${css.dir}/book.css" />
<property name="eclipsehelp-css.file" value="${html-css.file}" />
<property name="build.dir" value="build" />
<property name="download.dir"
value="${java.io.tmpdir}${file.separator}downloads" />
<!--
DocBook Toolchain
-->
<property name="docbook.version" value="1.75.1" />
<property name="docbook.dir"
value="${download.dir}${file.separator}docbook-xsl-${docbook.version}" />
<property name="docbookxsl.url"
value="http://downloads.sourceforge.net/project/docbook/docbook-xsl/${docbook.version}/docbook-xsl-${docbook.version}.zip" />
<property name="fop.dir" value="${download.dir}${file.separator}fop-0.95" />
<property name="fop.url"
value="http://archive.apache.org/dist/xmlgraphics/fop/binaries/fop-0.95-bin.zip" />
<property name="xom.dir" value="${download.dir}${file.separator}XOM" />
<property name="xom.url"
value="http://www.cafeconleche.org/XOM/xom-1.2.1.zip" />
<property name="xcluder.url"
value="http://central.maven.org/maven2/gr/abiss/xcluder/xcluder/0.9.2/xcluder-0.9.2.jar" />
<property name="xcluder.jar"
value="${download.dir}${file.separator}xcluder.jar" />
<property name="xalan.url"
value="http://central.maven.org/maven2/xalan/xalan/2.7.2/xalan-2.7.2.jar" />
<property name="xalan.jar"
value="${download.dir}${file.separator}xalan.jar" />
<property name="xalan-serializer.url"
value="http://central.maven.org/maven2/xalan/serializer/2.7.2/serializer-2.7.2.jar" />
<property name="xalan-serializer.jar"
value="${download.dir}${file.separator}serializer.jar" />
<property name="jai.dir" value="ENTER_JAI_DIRECTORY" />
<macrodef name="docbook2pdf">
<attribute name="source" />
<attribute name="target" />
<sequential>
<taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
<classpath>
<pathelement location="${fop.dir}${file.separator}build${file.separator}fop.jar" />
<pathelement location="${fop.dir}${file.separator}lib${file.separator}avalon-framework-4.2.0.jar" />
<pathelement location="${fop.dir}${file.separator}lib${file.separator}commons-logging-1.0.4.jar" />
<pathelement location="${fop.dir}${file.separator}lib${file.separator}commons-io-1.3.1.jar" />
<pathelement location="${fop.dir}${file.separator}lib${file.separator}batik-all-1.7.jar" />
<pathelement location="${fop.dir}${file.separator}lib${file.separator}xmlgraphics-commons-1.3.1.jar" />
<pathelement location="${jai.dir}${file.separator}lib${file.separator}jai_core.jar" />
<pathelement location="${jai.dir}${file.separator}lib${file.separator}jai_codec.jar" />
</classpath>
</taskdef>
<fop format="application/pdf"
fofile="@{source}"
outfile="@{target}"
messagelevel="info" />
</sequential>
</macrodef>
<target name="init">
<mkdir dir="${download.dir}" />
<mkdir dir="${build.dir}" />
<delete file="${build.dir}/${document.name}.xml"/>
</target>
<target name="build-doc" depends="init, get-docbook-xsl, get-fop, get-xalan">
<echo>Building Output...</echo>
<antcall target="docbook2eclipsehelp" />
<antcall target="docbook2html" />
<antcall target="docbook2pdf" />
<antcall target="clean-artifacts" />
</target>
<target name="check-docbook">
<condition property="hasDocbook">
<and>
<available file="${download.dir}${file.separator}docbook.zip"
property="hasDocbookZip" />
<available file="${docbook.dir}"
type="dir"
property="hasDocbookDir" />
</and>
</condition>
</target>
<target name="check-fop">
<condition property="hasFOP">
<and>
<available file="${download.dir}${file.separator}fop.zip"
property="hasFOPZip" />
<available file="${fop.dir}" type="dir" property="hasFOPDir" />
</and>
</condition>
</target>
<target name="check-xom">
<condition property="hasXOM">
<and>
<available file="${download.dir}${file.separator}xom.zip"
property="hasXOMZip" />
<available file="${xom.dir}" type="dir" property="hasXOMDir" />
</and>
</condition>
</target>
<target name="check-xcluder">
<condition property="hasXcluder">
<available file="${xcluder.jar}" property="hasXcluderJar" />
</condition>
</target>
<target name="get-docbook-xsl"
description="Downloads docbook xsl"
depends="check-docbook"
unless="hasDocbook">
<echo>Downloading DocBook XSL...</echo>
<get dest="${download.dir}${file.separator}docbook.zip"
src="${docbookxsl.url}" />
<unzip src="${download.dir}${file.separator}docbook.zip"
dest="${download.dir}" />
</target>
<target name="get-fop"
description="Downloads FOP"
depends="check-fop"
unless="hasFOP">
<echo>Downloading FOP...</echo>
<get dest="${download.dir}${file.separator}fop.zip" src="${fop.url}" />
<unzip src="${download.dir}${file.separator}fop.zip"
dest="${download.dir}" />
</target>
<target name="get-xom"
description="Downloads XOM"
depends="check-xom"
unless="hasXOM">
<echo>Downloading XOM...</echo>
<get dest="${download.dir}${file.separator}xom.zip" src="${xom.url}" />
<unzip src="${download.dir}${file.separator}xom.zip"
dest="${download.dir}" />
</target>
<target name="get-xcluder"
description="Downloads Xcluder Task"
depends="get-xom, check-xcluder"
unless="hasXcluder">
<echo>Downloading Xcluder Task...</echo>
<get dest="${xcluder.jar}" src="${xcluder.url}" />
</target>
<target name="get-xalan"
description="Downloads Xalan"
depends=""
unless="hasXalan">
<echo>Downloading Xalan...</echo>
<get dest="${xalan.jar}" src="${xalan.url}" />
<get dest="${xalan-serializer.jar}" src="${xalan-serializer.url}" />
<path id="xalan">
<pathelement location="${xalan.jar}"/>
<pathelement location="${xalan-serializer.jar}"/>
</path>
</target>
<target name="check-merge">
<available file="${build.dir}/${document.name}.xml"
property="isMerged" />
</target>
<target name="merge" depends="check-merge,get-xcluder" unless="isMerged">
<echo>Merging article parts...</echo>
<sequential>
<taskdef name="xinclude" classname="gr.abiss.xcluder.XOMXcluder">
<classpath>
<pathelement location="${xcluder.jar}" />
<pathelement location="${xom.dir}${file.separator}xom-1.2.1.jar" />
</classpath>
</taskdef>
<xinclude
in="${src.dir}/${document.name}.xml"
out="${build.dir}/${document.name}.xml"
encoding="UTF-8"/>
</sequential>
</target>
<target name="docbook2html" depends="get-fop,get-docbook-xsl,get-xalan,merge">
<echo>Converting article to HTML...</echo>
<delete dir="${basedir}/html"
failonerror="false"
excludes="CVS"
includeemptydirs="true" />
<copy todir="${basedir}/html/images">
<fileset dir="${images.dir}/">
<include name="*/**" />
</fileset>
</copy>
<copy file="${html-css.file}" todir="${basedir}/html" />
<xslt in="${build.dir}${file.separator}${document.name}.xml"
extension="xml"
out="${basedir}/html${file.separator}${document.name}.html"
style="${document.stylesheet}">
<classpath refid="xalan"/>
<factory name="org.apache.xalan.processor.TransformerFactoryImpl">
<attribute name="http://xml.apache.org/xalan/features/optimize"
value="true" />
</factory>
<xmlcatalog>
<entity publicId="docbook.xsl"
location="${docbook.dir}${file.separator}html${file.separator}docbook.xsl" />
</xmlcatalog>
<param name="header.rule" expression="1" />
<param name="admon.graphics.extension" expression=".gif" />
<param name="admon.textlabel" expression="0" />
<param name="ulink.target" expression="_new" />
</xslt>
</target>
<target name="docbook2pdf" depends="get-fop,get-docbook-xsl,get-xalan,merge">
<echo>Converting article to PDF...</echo>
<delete file="manual${file.separator}${document.name}.pdf"
failonerror="false" />
<delete file="${build.dir}${file.separator}${document.name}.fo" />
<mkdir dir="manual" />
<xslt in="${build.dir}${file.separator}${document.name}.xml"
extension="xml"
out="${build.dir}${file.separator}${document.name}.fo"
style="${document.pdf.stylesheet}">
<classpath refid="xalan"/>
<factory name="org.apache.xalan.processor.TransformerFactoryImpl">
<attribute name="http://xml.apache.org/xalan/features/optimize"
value="true" />
</factory>
<xmlcatalog>
<entity publicId="docbook.xsl"
location="${docbook.dir}${file.separator}fo${file.separator}docbook.xsl" />
</xmlcatalog>
<param name="generate.toc" expression="book toc" />
<param name="show.comments" expression="0" />
<param name="header.rule" expression="1" />
<param name="admon.graphics.extension" expression=".gif" />
<param name="admon.textlabel" expression="0" />
<param name="admon.graphics" expression="1" />
</xslt>
<docbook2pdf source="${build.dir}${file.separator}${document.name}.fo"
target="manual${file.separator}${document.name}.pdf" />
<!-- Remove the resulting formatting object. This object isn't necessary in the
result of this build. -->
<delete file="${build.dir}${file.separator}${document.name}.fo" />
</target>
<target name="docbook2eclipsehelp" depends="get-fop,get-docbook-xsl,get-xalan,merge">
<echo>Converting article to Eclipse Help...</echo>
<delete dir="${basedir}/help"
failonerror="false"
excludes="CVS"
includeemptydirs="true" />
<copy todir="${basedir}/help/images">
<fileset dir="${images.dir}">
<include name="**/*" />
</fileset>
</copy>
<copy file="${eclipsehelp-css.file}" todir="${basedir}/help" />
<xslt basedir="${build.dir}"
destdir="${basedir}"
style="${document.eclipse.stylesheet}">
<classpath refid="xalan"/>
<param name="chunk.quietly" expression="1" />
<include name="${document.name}.xml" />
<factory name="org.apache.xalan.processor.TransformerFactoryImpl">
<attribute name="http://xml.apache.org/xalan/features/optimize"
value="true" />
</factory>
<xmlcatalog>
<entity publicId="chunk.xsl"
location="${docbook.dir}${file.separator}html${file.separator}chunk.xsl" />
</xmlcatalog>
<param name="header.rule" expression="1" />
</xslt>
</target>
<target name="clean">
<delete dir="build" />
<delete dir="manual" />
<delete dir="help" />
<delete dir="html" />
</target>
<target name="clean-artifacts">
<delete>
<fileset dir="${build.dir}">
<include name="*.fo" />
<include name="*.xml" />
</fileset>
</delete>
<delete file="${basedir}/${document.name}.html"/>
</target>
<target name="develop-documentation" depends="clean, clean-artifacts">
</target>
</project>