build.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project default="generate.all"
  3. basedir="."
  4. name="org.yakindu.sct.doc.user"
  5. xmlns:if="ant:if"
  6. xmlns:unless="ant:unless"
  7. xmlns:artifact="antlib:org.eclipse.aether.ant">
  8. <property file="build.properties" />
  9. <property file="local.properties" />
  10. <!-- The documentation source files are located here: -->
  11. <property name="src.basename" value="documentation" />
  12. <property name="src.dir.name" value="src" />
  13. <property name="css.dir.name" value="css" />
  14. <property name="img.dir.name" value="images" />
  15. <property name="src.dir" location="${basedir}/${src.dir.name}" />
  16. <property name="css.dir" location="${basedir}/${css.dir.name}" />
  17. <property name="img.dir" location="${src.dir}/${img.dir.name}" />
  18. <!-- Location of source file with XIncludes resolved: -->
  19. <property name="res.basename" value="${src.basename}.resolved" />
  20. <property name="res.dir.name" value="src-gen" />
  21. <!-- Target directory names and directories for various output formats: -->
  22. <property name="help.dir.name" value="help" />
  23. <property name="html.dir.name" value="html" />
  24. <property name="pdf.dir.name" value="pdf" />
  25. <property name="epub.dir.name" value="epub" />
  26. <property name="help.dir" location="${basedir}/${help.dir.name}" />
  27. <property name="html.dir" location="${basedir}/${html.dir.name}" />
  28. <property name="pdf.dir" location="${basedir}/${pdf.dir.name}" />
  29. <property name="epub.dir" location="${basedir}/${epub.dir.name}" />
  30. <!-- Libraries used by Ant tasks: -->
  31. <property name="lib.dir.name" value="lib" />
  32. <property name="lib.dir" location="${basedir}/${lib.dir.name}" />
  33. <!-- Aether Ant Tasks configuration -->
  34. <property name="aether.jar.version" value="1.0.0.v20140518" />
  35. <property name="aether.jar.checksum" value="95dadd03392a75564904da45108cf048abe6e5bb" />
  36. <property name="aether.jar.src"
  37. value="http://search.maven.org/remotecontent?filepath=org/eclipse/aether/aether-ant-tasks/${aether.jar.version}/aether-ant-tasks-${aether.jar.version}-uber.jar" />
  38. <property name="aether.jar.file" value="${lib.dir}/aether-ant-tasks-uber.jar" />
  39. <!-- The DocBook XML distribution ZIP file will be unpacked to this directory: -->
  40. <property name="docbook-xml.distribution.dir" location="${basedir}/docbook-xml.distribution" />
  41. <!-- The DocBook XSL distribution ZIP file will be unpacked to this directory: -->
  42. <property name="docbook-xsl.distribution.dir" location="${basedir}/docbook-xsl.distribution" />
  43. <!-- This directory contains our project-specific DocBook XSL customization layer as templates with to-be-resolved
  44. references to the unpacked DocBook XSL distribution: -->
  45. <property name="docbook-xsl.dir.tmpl.name" value="docbook-xsl.tmpl" />
  46. <property name="docbook-xsl.dir.tmpl" location="${basedir}/${docbook-xsl.dir.tmpl.name}" />
  47. <!-- This directory contains our project-specific DocBook XSL customization layer with references being resolved to
  48. point to the unpacked DocBook XSL distribution: -->
  49. <property name="docbook-xsl.dir" location="${basedir}/docbook-xsl" />
  50. <!-- Remove generated stuff: -->
  51. <target name="clean">
  52. <delete includeemptydirs="true" failonerror="false">
  53. <fileset dir="${res.dir.name}" />
  54. <fileset dir="${docbook-xsl.dir}" />
  55. <fileset dir="${docbook-xsl.distribution.dir}" />
  56. <fileset dir="${docbook-xml.distribution.dir}" />
  57. <fileset dir="${basedir}" defaultexcludes="false">
  58. <include name="${help.dir.name}/**" />
  59. <include name="${html.dir.name}/**" />
  60. <include name="${pdf.dir.name}/**" />
  61. <include name="${epub.dir.name}/**" />
  62. </fileset>
  63. </delete>
  64. </target>
  65. <!-- Initializes the build environment. -->
  66. <target name="init" depends="init.aether, init.dependencies" description="Initializes the build environment." />
  67. <!-- Aether Ant Tasks are used to access Maven dependencies from an Ant build. It is initialized by downloading
  68. the Aether Ant Tasks JAR to the library folder, if needed. The downloaded JAR will not be removed by the
  69. "clean" target. If the JAR is present, a typedef will make Aether Ant Tasks' elements available in the Ant
  70. build file. -->
  71. <target name="init.aether"
  72. description="Initialized Aether Ant Tasks JAR by downloading the JAR and defining a type.">
  73. <condition property="target.exists">
  74. <available file="${aether.jar.file}" />
  75. </condition>
  76. <sequential unless:set="target.exists">
  77. <mkdir dir="${lib.dir}" />
  78. <get src="${aether.jar.src}" dest="${aether.jar.file}" skipexisting="true" usetimestamp="true" />
  79. <fail message="Checksum mismatch for ${aether.jar.file}. Please delete it and rerun ant to redownload.">
  80. <condition>
  81. <not>
  82. <checksum file="${aether.jar.file}"
  83. algorithm="SHA"
  84. property="${aether.jar.checksum}"
  85. verifyproperty="checksum.matches" />
  86. </not>
  87. </condition>
  88. </fail>
  89. </sequential>
  90. <path id="aether-ant-tasks.classpath" path="${aether.jar.file}" />
  91. <typedef resource="org/eclipse/aether/ant/antlib.xml"
  92. uri="antlib:org.eclipse.aether.ant"
  93. classpathref="aether-ant-tasks.classpath" />
  94. </target>
  95. <!-- Resolves the necessary dependencies: -->
  96. <target name="init.dependencies" description="Resolves the necessary dependencies." depends="init.aether">
  97. <!-- Classpath for Xalan, needed to render DocBook documents via XSLT. -->
  98. <artifact:resolve>
  99. <artifact:dependencies>
  100. <dependency groupId="xalan" artifactId="xalan" version="2.7.2" scope="compile" />
  101. </artifact:dependencies>
  102. <path refid="xalan.classpath" />
  103. </artifact:resolve>
  104. <!-- Classpath for Xerces and Xerces samples, needed for XInclude preprocessing. -->
  105. <artifact:resolve>
  106. <artifact:dependencies>
  107. <dependency groupId="xerces" artifactId="xercesImpl" version="2.11.0" scope="compile" />
  108. <dependency groupId="xerces" artifactId="xercesSamples" version="2.8.0" scope="compile" />
  109. </artifact:dependencies>
  110. <path refid="xerces.classpath" />
  111. </artifact:resolve>
  112. <!-- Classpath for FOP, needed to render FOP files (generated by DocBook XSL) into PDF documents. -->
  113. <artifact:resolve>
  114. <artifact:dependencies>
  115. <dependency groupId="org.apache.xmlgraphics" artifactId="fop" version="2.1" scope="compile" />
  116. </artifact:dependencies>
  117. <path refid="fop.classpath" />
  118. </artifact:resolve>
  119. <!-- ZIP file containing the DocBook XSL distribution, needed to convert DocBook documents to anything else: -->
  120. <artifact:resolve>
  121. <artifact:dependencies>
  122. <dependency groupId="net.sf.docbook"
  123. artifactId="docbook-xsl"
  124. version="1.78.1"
  125. type="zip"
  126. classifier="ns-resources"
  127. scope="compile" />
  128. </artifact:dependencies>
  129. <properties prefix="docbook-xsl" />
  130. </artifact:resolve>
  131. <!-- DocBook XML -->
  132. <artifact:resolve>
  133. <artifact:dependencies>
  134. <dependency groupId="net.sf.docbook"
  135. artifactId="docbook-xml"
  136. version="5.0"
  137. type="zip"
  138. classifier="rng-resources"
  139. scope="compile" />
  140. </artifact:dependencies>
  141. <properties prefix="docbook-xml" />
  142. </artifact:resolve>
  143. <!-- Jing (used for Relax-NG validation) -->
  144. <artifact:resolve>
  145. <artifact:dependencies>
  146. <dependency groupId="com.thaiopensource" artifactId="jing" version="20091111" scope="compile" />
  147. </artifact:dependencies>
  148. <path refid="jing.classpath" />
  149. </artifact:resolve>
  150. </target>
  151. <!-- Initializes DocBook XML by unpacking the distribution ZIP file. -->
  152. <target name="init.docbook-xml"
  153. description="Initializes DocBook XML by unpacking the distribution ZIP file."
  154. depends="init.dependencies">
  155. <condition property="docbook-xml.dirstribution.dir.exists">
  156. <available file="${docbook-xml.distribution.dir}" />
  157. </condition>
  158. <unzip dest="${docbook-xml.distribution.dir}"
  159. src="${docbook-xml.net.sf.docbook:docbook-xml:zip:rng-resources}"
  160. overwrite="false"
  161. unless:set="docbook-xml.dirstribution.dir.exists" />
  162. </target>
  163. <!-- Initializes DocBook XSL by unpacking the distribution ZIP file and resolving the references in our
  164. customization layer template files. -->
  165. <target name="init.docbook-xsl"
  166. description="Initializes DocBook XSL by unpacking the distribution ZIP file and resolving the references in our customization layer template files."
  167. depends="init.dependencies">
  168. <condition property="docbook-xsl.distribution.dir.exists">
  169. <available file="${docbook-xsl.distribution.dir}" />
  170. </condition>
  171. <sequential unless:set="docbook-xsl.distribution.dir.exists">
  172. <unzip dest="${docbook-xsl.distribution.dir}"
  173. src="${docbook-xsl.net.sf.docbook:docbook-xsl:zip:ns-resources}"
  174. overwrite="false" />
  175. </sequential>
  176. <mkdir dir="${docbook-xsl.dir}" />
  177. <filter token="docbook-xsl" value="${docbook-xsl.distribution.dir}/docbook" />
  178. <copy todir="${docbook-xsl.dir}" filtering="true">
  179. <fileset dir="${docbook-xsl.dir.tmpl}" />
  180. </copy>
  181. </target>
  182. <!-- Resolves XIncludes. -->
  183. <target name="resolve-xinclude" depends="init">
  184. <mkdir dir="${res.dir.name}" />
  185. <java classname="sax.Writer"
  186. classpathref="xerces.classpath"
  187. output="${res.dir.name}/${res.basename}.xml"
  188. logerror="true"
  189. failonerror="true"
  190. fork="true">
  191. <arg value="-np" />
  192. <arg value="-xi" />
  193. <arg value="${src.dir}/${src.basename}.xml" />
  194. </java>
  195. </target>
  196. <!-- Validates the DocBook source file against the DocBook 5.0 Relax-NG grammar. -->
  197. <target name="validate" depends="init.docbook-xml, resolve-xinclude">
  198. <java classname="com.thaiopensource.relaxng.util.Driver"
  199. classpathref="jing.classpath"
  200. fork="true"
  201. failonerror="true">
  202. <arg value="${docbook-xml.distribution.dir}/xsd/docbook.rng" />
  203. <arg value="${res.dir.name}/${res.basename}.xml" />
  204. </java>
  205. </target>
  206. <!-- Generates the documentation in all supported formats. -->
  207. <target name="generate.all"
  208. description="Generates the documentation in all supported formats."
  209. depends="generate.html, generate.eclipsehelp, generate.pdf" />
  210. <!-- Generates the documentation as HTML. -->
  211. <target name="generate.html"
  212. description="Generates the documentation as HTML."
  213. depends="validate, init.docbook-xsl">
  214. <docbook.conversion src.dir="${res.dir.name}"
  215. src.file.name="${res.basename}.xml"
  216. dst.dir="${html.dir.name}"
  217. dst.file.name="${src.basename}.html"
  218. style="${docbook-xsl.dir}/html.xsl" />
  219. </target>
  220. <!-- Generates the documentation as Eclipse help. This is essentially chunked HTML with a TOC file. -->
  221. <target name="generate.eclipsehelp"
  222. description="Generates the documentation as Eclipse help."
  223. depends="validate, init.docbook-xsl">
  224. <docbook.conversion src.dir="${res.dir.name}"
  225. src.file.name="${res.basename}.xml"
  226. dst.dir="${help.dir.name}"
  227. dst.file.name="${src.basename}.html"
  228. style="${docbook-xsl.dir}/eclipsehelp.xsl" />
  229. </target>
  230. <!-- Generates the documentation as PDF. -->
  231. <target name="generate.pdf" description="Generates the documentation as PDF." depends="validate, init.docbook-xsl">
  232. <docbook.conversion src.dir="${res.dir.name}"
  233. src.file.name="${res.basename}.xml"
  234. dst.dir="${pdf.dir.name}"
  235. dst.file.name="${src.basename}.fo"
  236. style="${docbook-xsl.dir}/pdf.xsl" />
  237. <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop" classpathref="fop.classpath" />
  238. <fop fofile="${pdf.dir}/${src.basename}.fo"
  239. outfile="${pdf.dir}/${src.basename}.pdf"
  240. format="application/pdf"
  241. basedir="${pdf.dir}" />
  242. </target>
  243. <!-- Converts a DocBook document into a target format. -->
  244. <macrodef name="docbook.conversion" description="Converts a DocBook document into a target format.">
  245. <attribute name="src.dir" />
  246. <attribute name="src.file.name" />
  247. <attribute name="dst.dir" />
  248. <attribute name="dst.file.name" />
  249. <attribute name="style" />
  250. <sequential>
  251. <local name="src.file" />
  252. <local name="dst.file" />
  253. <local name="dst.dirname" />
  254. <local name="dst.subdir" />
  255. <local name="subdir.exists" />
  256. <property name="src.file" value="@{src.dir}/@{src.file.name}" />
  257. <property name="dst.file" value="@{dst.dir}/@{dst.file.name}" />
  258. <basename property="dst.dirname" file="@{dst.dir}" />
  259. <!-- Convert DocBook sources to target format: -->
  260. <mkdir dir="@{dst.dir}" />
  261. <java classname="org.apache.xalan.xslt.Process" classpathref="xalan.classpath" fork="true">
  262. <sysproperty key="java.endorsed.dirs" value="${lib.dir}" />
  263. <sysproperty key="org.apache.xerces.xni.parser.XMLParserConfiguration"
  264. value="org.apache.xerces.parsers.XIncludeParserConfiguration" />
  265. <arg value="-out" />
  266. <arg value="${dst.file}" />
  267. <arg value="-in" />
  268. <arg value="${src.file}" />
  269. <arg value="-xsl" />
  270. <arg value="@{style}" />
  271. </java>
  272. <!-- In the special case "eclipsehelp", HTML files have been generated one level too deep, so let's move them up: -->
  273. <sequential>
  274. <property name="dst.subdir" value="@{dst.dir}/${dst.dirname}" />
  275. <condition property="subdir.exists">
  276. <available file="${dst.subdir}" />
  277. </condition>
  278. <sequential if:set="subdir.exists">
  279. <mkdir dir="${dst.subdir}" />
  280. <move todir="@{dst.dir}">
  281. <fileset dir="${dst.subdir}">
  282. <include name="*" />
  283. </fileset>
  284. </move>
  285. <delete dir="${dst.subdir}" />
  286. </sequential>
  287. </sequential>
  288. <!-- Copy the CSS files to the destination directory: -->
  289. <copy todir="@{dst.dir}/${css.dir.name}">
  290. <fileset dir="${css.dir}">
  291. <include name="*" />
  292. </fileset>
  293. </copy>
  294. <!-- Copy the image files to the destination directory: -->
  295. <copy todir="@{dst.dir}/${img.dir.name}">
  296. <fileset dir="${img.dir}">
  297. <include name="*" />
  298. </fileset>
  299. </copy>
  300. </sequential>
  301. </macrodef>
  302. </project>