blob: cdb813d34ff76ffdb290ffe73e4192665fcd83fd [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>
-->
<project name="org.eclipse.amp.doc" default="build-doc" basedir=".">
<!--
Global vars
-->
<property name="fs" value="${file.separator}" />
<property name="document.name" value="amp" />
<property name="document.stylesheet" value="styles/html.xsl" />
<property name="dbpdf.stylesheet" value="styles/dbpdfdb.xsl" />
<property name="document.pdf.stylesheet" value="styles/xmpp.xsl" />
<property name="document.eclipse.stylesheet" value="styles/eclipsehelp.xsl" />
<property name="eclipsehelp-css.file" value="styles/book.css" />
<property name="html-css.file" value="styles/book.css" />
<property name="build.dir" value="build" />
<property name="download.dir" value="${java.io.tmpdir}${fs}downloads" />
<!-- Changed from XText version to write directly to the web dir..saves on cvs thrashing.. -->
<property name="website.dir" value="../../../amp" />
<property name="website.doc.dir" value="${website.dir}${fs}documentation" />
<property name="website.content.dir" value="${website.doc.dir}${fs}contents" />
<property name="wikitext.url" value="http://download.eclipse.org/tools/mylyn/update/weekly/mylyn-wikitext-standalone-latest.zip" />
<property name="wikitext.dir" value="${download.dir}${fs}wikitext" />
<target name="check-wikitext">
<condition property="hasWikiText">
<and>
<available file="${download.dir}${fs}wikitext.zip" property="hasWikiTextZIP" />
<available file="${wikitext.dir}" property="hasWikiTextDir" />
</and>
</condition>
</target>
<target name="get-wikitext" description="Downloads WikiText" depends="check-wikitext" unless="hasWikiText">
<echo>Downloading WikiText...</echo>
<get dest="${download.dir}${fs}wikitext.zip" src="${wikitext.url}" />
<unzip src="${download.dir}${fs}wikitext.zip" dest="${wikitext.dir}">
<patternset includes="**/*.jar" />
<mapper type="flatten" />
</unzip>
</target>
<target name="install-wikitext" depends="get-wikitext">
<taskdef resource="org/eclipse/mylyn/wikitext/core/util/anttask/tasks.properties">
<classpath>
<fileset dir="${wikitext.dir}">
<include name="org.eclipse.mylyn.wikitext.*core*.jar" />
</fileset>
</classpath>
</taskdef>
</target>
<target name="assemble">
<loadfile srcfile="doc/${document.name}-index.txt" property="inputfiles">
<filterchain>
<tokenfilter>
<replacestring from="\n" to="," />
</tokenfilter>
</filterchain>
</loadfile>
<concat destfile="${build.dir}${fs}${document.name}.mediawiki" append="false" fixlastline="yes">
<filelist dir="doc" files="${inputfiles}" />
</concat>
</target>
<target name="wikitext2docbook" depends="assemble" description="Generate DocBook from MediaWIki">
<wikitext-to-docbook markupLanguage="MediaWiki" booktitle="Agent Modeling Guide" validate="true">
<fileset dir="${build.dir}">
<include name="${document.name}.mediawiki" />
</fileset>
</wikitext-to-docbook>
</target>
<!--
DocBook Toolchain
-->
<!-- <property name="docbook.version" value="1.73.2" /> -->
<property name="docbook.version" value="1.75.1" />
<property name="docbook.dir" value="${download.dir}${fs}docbook-xsl-${docbook.version}" />
<property name="docbookxsl.url" value="http://internap.dl.sourceforge.net/sourceforge/docbook/docbook-xsl-${docbook.version}.zip" />
<property name="fop.dir" value="${download.dir}${fs}fop-0.95" />
<property name="fop.url" value="http://mirrorspace.org/apache/xmlgraphics/fop/binaries/fop-0.95-bin.zip" />
<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}${fs}build${fs}fop.jar" />
<pathelement location="${fop.dir}${fs}lib${fs}avalon-framework-4.2.0.jar" />
<pathelement location="${fop.dir}${fs}lib${fs}commons-logging-1.0.4.jar" />
<pathelement location="${fop.dir}${fs}lib${fs}commons-io-1.3.1.jar" />
<pathelement location="${fop.dir}${fs}lib${fs}batik-all-1.7.jar" />
<pathelement location="${fop.dir}${fs}lib${fs}xmlgraphics-commons-1.3.1.jar" />
<pathelement location="${jai.dir}${fs}lib${fs}jai_core.jar" />
<pathelement location="${jai.dir}${fs}lib${fs}jai_codec.jar" />
<pathelement location="lib/serializer.jar" />
<pathelement location="lib/xalan.jar" />
<pathelement location="lib/xercesImpl.jar" />
<pathelement location="lib/xml-apis.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}" />
</target>
<target name="build-doc" depends="init, install-wikitext, get-docbook-xsl, get-fop">
<echo>Building Output...</echo>
<antcall target="wikitext2docbook" />
<antcall target="docbook2pdf" />
<antcall target="docbook2html" />
<!--
<antcall target="wikitext2eclipsehelp"/>
-->
<antcall target="docbook2eclipsehelp" />
</target>
<target name="check-docbook">
<condition property="hasDocbook">
<and>
<available file="${download.dir}${fs}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}${fs}fop.zip" property="hasFOPZip" />
<available file="${fop.dir}" type="dir" property="hasFOPDir" />
</and>
</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}${fs}docbook.zip" src="${docbookxsl.url}" />
<unzip src="${download.dir}${fs}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}${fs}fop.zip" src="${fop.url}" />
<unzip src="${download.dir}${fs}fop.zip" dest="${download.dir}" />
</target>
<target name="docbook2html">
<echo>Converting article to HTML...</echo>
<delete dir="${basedir}/html" failonerror="false" excludes="CVS" includeemptydirs="true" />
<copy todir="${website.content.dir}">
<fileset dir="doc/">
<include name="images/**" />
</fileset>
</copy>
<copy file="${html-css.file}" todir="${website.content.dir}" />
<xslt in="${build.dir}${fs}${document.name}.xml" extension="xml" out="${website.content.dir}${fs}${document.name}.html" style="${document.stylesheet}">
<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}${fs}html${fs}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" />
<param name="ignore.image.scaling" expression="1" />
</xslt>
</target>
<target name="docbook2pdf">
<echo>Converting article to PDF...</echo>
<delete file="${website.doc.dir}${fs}${document.name}.pdf" failonerror="false" />
<delete file="${build.dir}${fs}${document.name}.fo" />
<!-- HACK! images should rather be copied to build/images -->
<copy todir="${basedir}">
<fileset dir="doc/">
<include name="images/**" />
</fileset>
</copy>
<xslt in="${build.dir}${fs}${document.name}.xml" extension="xml" out="${build.dir}${fs}${document.name}PDF.xml" style="${dbpdf.stylesheet}">
<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}${fs}fo${fs}docbook.xsl" />
</xmlcatalog>
</xslt>
<xslt in="${build.dir}${fs}${document.name}PDF.xml" extension="xml" out="${build.dir}${fs}${document.name}.fo" style="${document.pdf.stylesheet}">
<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}${fs}fo${fs}docbook.xsl" />
</xmlcatalog>
<param name="graphicsize.extension" expression="1" />
<param name="use.extensions" expression="1" />
<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" />
<param name="scale" expression="10" />
</xslt>
<echo>${build.dir}${fs}${document.name}.fo
${website.doc.dir}${fs}${document.name}.pdf</echo>
<docbook2pdf source="${build.dir}${fs}${document.name}.fo" target="${website.doc.dir}${fs}${document.name}.pdf" />
<!-- Remove the resulting formatting object. This object isn't necessary in the
result of this build. -->
<delete file="${build.dir}${fs}${document.name}.fo" />
<delete dir="${basedir}/images" />
</target>
<target name="wikitext2eclipsehelp" depends="assemble" description="Generate Eclipse Help from MediaWiki">
<wikitext-to-eclipse-help markupLanguage="MediaWiki" multipleOutputFiles="true" navigationImages="false" formatoutput="true" helpPrefix="help">
<fileset dir="${build.dir}">
<include name="${document.name}.mediawiki" />
</fileset>
<stylesheet url="book.css" />
<stylesheet file="${basedir}/help/styles/main.css" />
</wikitext-to-eclipse-help>
</target>
<target name="docbook2eclipsehelp">
<echo>Converting article to Eclipe Help...</echo>
<delete dir="${basedir}/help" failonerror="false" excludes="CVS" includeemptydirs="true" />
<copy todir="${basedir}/help/images">
<fileset dir="doc/images">
<include name="**/*" />
</fileset>
</copy>
<copy file="${eclipsehelp-css.file}" todir="${basedir}/help" />
<xslt basedir="${build.dir}" destdir="${basedir}" style="${document.eclipse.stylesheet}">
<param name="chunk.quietly" expression="1" />
<include name="amp.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}${fs}html${fs}chunk.xsl" />
</xmlcatalog>
<param name="header.rule" expression="1" />
<param name="ignore.image.scaling" expression="1" />
</xslt>
<delete file="${basedir}/amp.html" />
</target>
</project>