blob: 97e2411ae052ef68536d33ba560b8efd89ea93bd [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.qvtd.doc" default="build-doc" basedir=".">
<!--
Global vars
-->
<property name="document.name" value="qvtd"/>
<property name="document.stylesheet" value="styles/html.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"/>
<!--
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/mylyn/snapshots/nightly/docs/wikitext-standalone-latest.zip"/>
<property name="wikitext.url" value="http://download.eclipse.org/mylyn/drops/3.10.0/v20131025-2037/mylyn-3.10.0.v20131025-2037.zip"/>
-->
<property name="wikitext.dir" value="${download.dir}${file.separator}wikitext"/>
<!-- adolfosbh: We expect to receive a target.location to provide some jars to the xslt ant tasks
in the said target.location is not provided, we try to use the tipical ${eclipse.home} variable -->
<condition property="target.location" value="${eclipse.home}">
<not>
<isset property="target.location"/>
</not>
</condition>
<echo>Target Location: "${target.location}" </echo>
<echo>download.dir "${download.dir}" </echo>
<path id="xslt.classpath">
<pathelement path="${java.class.path}"/>
<pathelement path="${target.location}/plugins/org.apache.xalan_2.7.1.v201005080400.jar"/>
<pathelement path="${target.location}/plugins/org.apache.xml.serializer_2.7.1.v201005080400.jar"/>
<!--pathelement path="${target.location}/plugins/com.google.guava_10.0.1.v201203051515.jar"/-->
</path>
<target name="install-wikitext">
<echo>Find wikitext tasks</echo>
<!--echo>echoproperties to "${user.dir}${file.separator}install-wikitext.properties"</echo>
<echoproperties destfile="${user.dir}${file.separator}install-wikitext.properties"/-->
<taskdef resource="org/eclipse/mylyn/wikitext/ant/tasks.properties">
<classpath>
<fileset dir="${target.location}${file.separator}plugins">
<include name="com.google.guava*.jar"/>
<!--include name="org.eclipse.mylyn.wikitext.core*.jar"/-->
<include name="org.eclipse.mylyn.wikitext.ant*.jar"/>
<include name="org.eclipse.mylyn.wikitext.textile*.jar"/>
<include name="org.eclipse.mylyn.wikitext*.jar"/>
</fileset>
</classpath>
</taskdef>
</target>
<target name="assemble">
<echo>Assembling contributions to "${build.dir}${file.separator}${document.name}.textile"</echo>
<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}.textile" append="false" fixlastline="yes">
<filelist dir="doc" files="${inputfiles}"/>
</concat>
</target>
<target name="wikitext2docbook" depends="assemble" description="Generate DocBook from Textile">
<wikitext-to-docbook markupLanguage="org.eclipse.mylyn.wikitext.textile.TextileLanguage"
booktitle="QVT Declarative Documentation"
validate="true">
<fileset dir="${build.dir}">
<include name="${document.name}.textile"/>
</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://downloads.sourceforge.net/project/docbook/docbook-xsl/1.75.1/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="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="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="docbook2eclipsehelp"/>
</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}" usetimestamp="true" retries="5"/>
<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}" usetimestamp="true" retries="5"/>
<unzip src="${download.dir}${file.separator}fop.zip" dest="${download.dir}"/>
</target>
<target name="docbook2html">
<echo>Converting article to HTML...</echo>
<echo>XML Catalog "docbook.xsl" => "${docbook.dir}${file.separator}html${file.separator}docbook.xsl"</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 classpathref="xslt.classpath" 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 "manual${file.separator}${document.name}.pdf"</echo>
<echo>XML Catalog "docbook.xsl" => "${docbook.dir}${file.separator}fo${file.separator}docbook.xsl"</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 classpathref="xslt.classpath" in="${build.dir}${file.separator}${document.name}.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="generate.toc" expression="book toc" />
<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" />
<delete dir="${basedir}/images" />
</target>
<target name="wikitext2eclipsehelp" depends="assemble" description="Generate Eclipse Help from textile">
<wikitext-to-eclipse-help markupLanguage="org.eclipse.mylyn.wikitext.textile.core.TextileLanguage"
multipleOutputFiles="true"
navigationImages="false"
formatoutput="true"
helpPrefix="help">
<fileset dir="${build.dir}">
<include name="${document.name}.textile"/>
</fileset>
<stylesheet url="book.css"/>
<stylesheet file="${basedir}/help/styles/main.css"/>
</wikitext-to-eclipse-help>
</target>
<target name="docbook2eclipsehelp">
<echo>Converting article to Eclipse 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 classpathref="xslt.classpath" basedir="${build.dir}" destdir="${basedir}" style="${document.eclipse.stylesheet}">
<param name="chunk.quietly" expression="1"/>
<include name="qvtd.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}/qvtd.html" />
</target>
</project>