blob: bc001bc23ff7f45b69d1a44251122f961c2840bf [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-and-deploy-doc" basedir=".">
<!--
Global vars
-->
<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}${file.separator}downloads" />
<property name="website.dir" value="../../../amp" />
<!--
WikiText Toolchain
<property name="wikitext.url" value="http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/tools/mylyn/update/weekly/mylyn-wikitext-standalone-latest.zip"/>
-->
<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}${file.separator}wikitext" />
<target name="check-wikitext">
<condition property="hasWikiText">
<and>
<available file="${download.dir}${file.separator}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}${file.separator}wikitext.zip" src="${wikitext.url}" />
<unzip src="${download.dir}${file.separator}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}${file.separator}${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}${file.separator}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}${file.separator}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}${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}" />
</target>
<target name="deploy-doc">
<copy todir="${website.dir}/documentation/contents" overwrite="true">
<fileset dir="html/">
<include name="**" />
</fileset>
</copy>
<copy todir="${website.dir}/documentation" overwrite="true">
<fileset dir="manual/">
<include name="**" />
</fileset>
</copy>
</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="build-and-deploy-doc" depends="build-doc, deploy-doc">
</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="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="docbook2html">
<echo>Converting article to HTML...</echo>
<delete dir="${basedir}/html" failonerror="false" excludes="CVS" includeemptydirs="true" />
<copy todir="${basedir}/html">
<fileset dir="doc/">
<include name="images/**" />
</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}">
<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" />
<param name="ignore.image.scaling" expression="1" />
</xslt>
</target>
<target name="docbook2pdf">
<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" />
<!-- HACK! images should rather be copied to build/images -->
<copy todir="${basedir}">
<fileset dir="doc/">
<include name="images/**" />
</fileset>
</copy>
<xslt in="${build.dir}${file.separator}${document.name}.xml" extension="xml" out="${build.dir}${file.separator}${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}${file.separator}fo${file.separator}docbook.xsl" />
</xmlcatalog>
</xslt>
<xslt in="${build.dir}${file.separator}${document.name}PDF.xml" extension="xml" out="${build.dir}${file.separator}${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}${file.separator}fo${file.separator}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>
<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" />
<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}${file.separator}html${file.separator}chunk.xsl" />
</xmlcatalog>
<param name="header.rule" expression="1" />
<param name="ignore.image.scaling" expression="1" />
</xslt>
<delete file="${basedir}/amp.html" />
</target>
</project>