build.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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. <!-- Runtime properties:
  9. website.local.files: Generates website as local files
  10. -->
  11. <!-- Include platform-specific or machine-specific properties, if any. -->
  12. <property file="local.properties" />
  13. <!-- The documentation source files located beneath this directory.
  14. They may be structured into folders of arbitrary depth. -->
  15. <property name="src.dir" value="src" />
  16. <!-- CSS files are located here. -->
  17. <property name="css.dir" value="css" />
  18. <!-- Root CSS file to be referenced by the generated HTML files. -->
  19. <property name="css.root.file" value="style.css" />
  20. <!-- Image files reside in subdirectories with the following name: -->
  21. <property name="img.dir" value="images" />
  22. <!-- Target directories for various output formats: -->
  23. <property name="help.dir" value="help" />
  24. <property name="website.dir" value="website" />
  25. <property name="pdf.dir" value="pdf" />
  26. <property name="epub.dir" value="epub" />
  27. <!-- Libraries used by various Ant tasks are located here: -->
  28. <property name="lib.dir" location="${basedir}/lib" />
  29. <!-- Aether Ant Tasks configuration -->
  30. <property name="aether.jar.version" value="1.0.0.v20140518" />
  31. <property name="aether.jar.checksum"
  32. value="9008c0c96390eacc0f7fdde542dacbd921f942dcd5c139465e21f8b583942edb995304025bb436cfeeea0b89698ef9dfccf8a027da68cd079669adea8cca381f" />
  33. <property name="aether.jar.src"
  34. value="http://search.maven.org/remotecontent?filepath=org/eclipse/aether/aether-ant-tasks/${aether.jar.version}/aether-ant-tasks-${aether.jar.version}-uber.jar" />
  35. <property name="aether.jar.file" value="${lib.dir}/aether-ant-tasks-uber.jar" />
  36. <!-- Wikitext download configuration -->
  37. <property name="wikitext.zip.version" value="1.0.0.v20140518" />
  38. <property name="wikitext.zip.checksum"
  39. value="00d8bf79a9d7baf20e46d2435dd4b6a9963317a2737c731d11029c96aa86f64e8540639b6eefa6f04b8103860f47ff74e998c71b57445179dc20ad7c2847417c" />
  40. <!--
  41. <property name="wikitext.zip.src"
  42. value="http://www.eclipse.org/downloads/download.php?file=/mylyn/snapshots/nightly/docs/wikitext-standalone-latest.zip" />
  43. -->
  44. <property name="wikitext.zip.src" value="file:///${basedir}/externals/wikitext.zip" />
  45. <property name="wikitext.zip.file" value="${lib.dir}/wikitext.zip" />
  46. <property name="wikitext.basename" value="wikitext-standalone" />
  47. <property name="wikitext.version" value="2.8.0-SNAPSHOT" />
  48. <!-- Remove generated stuff: -->
  49. <target name="clean">
  50. <delete includeemptydirs="true" failonerror="false">
  51. <fileset dir="${basedir}" defaultexcludes="false">
  52. <include name="${help.dir}/**" />
  53. <include name="${website.dir}/**" />
  54. <include name="${pdf.dir}/**" />
  55. <include name="${epub.dir}/**" />
  56. </fileset>
  57. <fileset dir="${src-merged.dir}" />
  58. </delete>
  59. </target>
  60. <!-- Download and unpack the wikitext standalone distribution. Unfortunately it is currently available as a nightly build only. -->
  61. <target name="wikitext.download" description="Download and unpack the wikitext standalone distribution.">
  62. <condition property="wikitext.zip.file.exists">
  63. <and>
  64. <available file="${wikitext.zip.file}" />
  65. <checksum file="${wikitext.zip.file}"
  66. algorithm="SHA-512"
  67. property="${wikitext.zip.checksum}"
  68. verifyproperty="checksum.matches" />
  69. </and>
  70. </condition>
  71. <sequential unless:set="wikitext.zip.file.exists">
  72. <mkdir dir="${lib.dir}" />
  73. <get src="${wikitext.zip.src}"
  74. dest="${wikitext.zip.file}"
  75. skipexisting="false"
  76. usetimestamp="true"
  77. verbose="true" />
  78. <fail message="Checksum mismatch for ${wikitext.zip.file}. Please delete it and rerun ant to redownload.">
  79. <condition>
  80. <not>
  81. <checksum file="${wikitext.zip.file}"
  82. algorithm="SHA-512"
  83. property="${wikitext.zip.checksum}"
  84. verifyproperty="checksum.matches" />
  85. </not>
  86. </condition>
  87. </fail>
  88. <unzip dest="${lib.dir}" src="${wikitext.zip.file}" />
  89. </sequential>
  90. </target>
  91. <!-- Resolves the necessary dependencies: -->
  92. <target name="init.wikitext"
  93. description="Resolves the necessary wikitext dependencies."
  94. depends="wikitext.download">
  95. <property name="wikitext.dir" location="${lib.dir}/${wikitext.basename}-${wikitext.version}" />
  96. <path id="wikitext.classpath">
  97. <fileset dir="${wikitext.dir}">
  98. <include name="*.jar" />
  99. </fileset>
  100. </path>
  101. </target>
  102. <!-- Generates the documentation in all supported formats. -->
  103. <target name="generate.all"
  104. description="Generates the documentation in all supported formats."
  105. depends="generate.eclipsehelp, generate.website" />
  106. <!-- Generates the documentation as Eclipse help. -->
  107. <target name="generate.eclipsehelp"
  108. description="Generates the documentation as separate Eclipse help (HTML) files from their respective textile (wikitext) sources."
  109. depends="init.wikitext">
  110. <sequential>
  111. <taskdef classpathref="wikitext.classpath"
  112. resource="org/eclipse/mylyn/wikitext/core/ant/tasks.properties" />
  113. <!-- Textile source files to turn into HTML: -->
  114. <fileset id="fileset.eclipsehelp" dir="${src.dir}">
  115. <include name="installation/installation.textile" />
  116. <include name="tutorials/tutorials.textile" />
  117. <include name="user-guide/overview.textile" />
  118. <include name="user-guide/editing_statecharts.textile" />
  119. <include name="user-guide/simulating_statecharts.textile" />
  120. <include name="user-guide/advanced_simulation.textile" />
  121. <include name="user-guide/c-domain.textile" />
  122. <include name="user-guide/statechart_language.textile" />
  123. <include name="user-guide/generating_code.textile" />
  124. <include name="user-guide/generating_code_headless.textile" />
  125. <include name="user-guide/sctunit.textile" />
  126. </fileset>
  127. <!-- Check whether we have all the expected textile source files – no more, no less: -->
  128. <fail message="Number of textile source file(s) doesn't match.">
  129. <condition>
  130. <resourcecount refid="fileset.eclipsehelp" when="ne" count="11" />
  131. </condition>
  132. </fail>
  133. <!-- Convert textile source files to HTML: -->
  134. <wikitext-to-eclipse-help markupLanguage="Textile"
  135. multipleOutputFiles="false"
  136. navigationImages="true"
  137. formatoutput="true"
  138. validate="true"
  139. failOnValidationError="true"
  140. failOnValidationWarning="true"
  141. sourceEncoding="UTF-8"
  142. title="YAKINDU Statechart Tools"
  143. helpPrefix="${help.dir}">
  144. <fileset refid="fileset.eclipsehelp" />
  145. <stylesheet url="../${css.dir}/${css.root.file}" />
  146. </wikitext-to-eclipse-help>
  147. <!-- Files have been generated in the source directory, which is bad practice. Move them to the destination
  148. directory: -->
  149. <move todir="${help.dir}" flatten="no" verbose="no">
  150. <fileset dir="${src.dir}">
  151. <include name="**/*.html" />
  152. <include name="**/*-toc.xml" />
  153. </fileset>
  154. </move>
  155. <!-- Add HTML META element for Internet Explorer :-( -->
  156. <replaceregexp byline="false"
  157. match='(\s*)(&lt;title&gt;)'
  158. replace='\1&lt;meta http-equiv="X-UA-Compatible" content="IE=edge"/&gt;\1\2'>
  159. <fileset dir="${help.dir}">
  160. <include name="**/*.html" />
  161. </fileset>
  162. </replaceregexp>
  163. <!-- Add HTML META element to support viewport scaling -->
  164. <replaceregexp byline="false"
  165. match='(\s*)(&lt;title&gt;)'
  166. replace='\1&lt;meta name="viewport" content="width=device-width, initial-scale=1.0"/&gt;\1\2'>
  167. <fileset dir="${help.dir}">
  168. <include name="**/*.html" />
  169. </fileset>
  170. </replaceregexp>
  171. <!-- Add CSS classes "eclipsehelp" and "body-container" to BODY element and
  172. nest a DIV child with CSS class "primary" into the BODY element. -->
  173. <replaceregexp byline="true" match='&lt;body&gt;' replace='&lt;body class="eclipsehelp body-container"&gt;&lt;div class="primary"&gt;'>
  174. <fileset dir="${help.dir}">
  175. <include name="**/*.html" />
  176. </fileset>
  177. </replaceregexp>
  178. <replaceregexp byline="true" match='&lt;/body&gt;' replace='&lt;/div&gt;&lt;/body&gt;'>
  179. <fileset dir="${help.dir}">
  180. <include name="**/*.html" />
  181. </fileset>
  182. </replaceregexp>
  183. <!-- Fix DIV elements -->
  184. <replaceregexp byline="false"
  185. flags="g"
  186. match='&lt;p&gt;&lt;div(.*)&gt;&lt;/p&gt;'
  187. replace='&lt;div\1&gt;'>
  188. <fileset dir="${help.dir}">
  189. <include name="**/*.html" />
  190. </fileset>
  191. </replaceregexp>
  192. <replaceregexp byline="false" flags="g" match='&lt;p&gt;&lt;/div&gt;&lt;/p&gt;' replace='&lt;/div&gt;'>
  193. <fileset dir="${help.dir}">
  194. <include name="**/*.html" />
  195. </fileset>
  196. </replaceregexp>
  197. <!-- Validate the generated and modified HTML: -->
  198. <xmlvalidate failonerror="yes" lenient="yes" warn="no">
  199. <fileset dir="${help.dir}" includes="**/*.html" />
  200. <attribute name="http://xml.org/sax/features/validation" value="false" />
  201. <attribute name="http://apache.org/xml/features/validation/schema" value="false" />
  202. <attribute name="http://apache.org/xml/features/validation/schema-full-checking" value="false" />
  203. <attribute name="http://apache.org/xml/features/validation/warn-on-undeclared-elemdef" value="false" />
  204. <attribute name="http://apache.org/xml/features/validation/dynamic" value="false" />
  205. <attribute name="http://apache.org/xml/features/nonvalidating/load-dtd-grammar" value="false" />
  206. <attribute name="http://apache.org/xml/features/nonvalidating/load-external-dtd" value="false" />
  207. <attribute name="http://xml.org/sax/features/namespaces" value="false" />
  208. <attribute name="http://xml.org/sax/features/external-general-entities" value="false" />
  209. <attribute name="http://xml.org/sax/features/external-parameter-entities" value="false" />
  210. <attribute name="http://xml.org/sax/features/resolve-dtd-uris" value="false" />
  211. <attribute name="http://xml.org/sax/features/use-entity-resolver2" value="false" />
  212. <attribute name="http://xml.org/sax/features/namespace-prefixes" value="false" />
  213. <attribute name="http://xml.org/sax/features/namespaces" value="false" />
  214. </xmlvalidate>
  215. <!-- Copy the CSS files to the destination directory: -->
  216. <copy todir="${help.dir}/${css.dir}">
  217. <fileset dir="${css.dir}">
  218. <include name="*" />
  219. </fileset>
  220. </copy>
  221. <!-- Copy the image files to the destination directory: -->
  222. <copy todir="${help.dir}">
  223. <fileset dir="src">
  224. <include name="**/${img.dir}/*" />
  225. <exclude name="**/${img.dir}/*.xcf" />
  226. </fileset>
  227. </copy>
  228. </sequential>
  229. </target>
  230. <!-- Generates the documentation as various HTML files, each being composed of selected sections. Each part has a
  231. name and a title, and consists of a set of source files. The generated documentation structure looks like this:
  232. website
  233. YCST-installation.html
  234. YCST-user-guide.html
  235. YCST-tutorials.html
  236. css/yakindu.css
  237. css/ysct.css
  238. images/…
  239. -->
  240. <target name="generate.website"
  241. description="Generates the documentation as various HTML files for the website, each being composed of selected sections. Use -Dwebsite.local.files=true to generate the website as local files for preview."
  242. depends="init.wikitext">
  243. <sequential>
  244. <taskdef classpathref="wikitext.classpath"
  245. resource="org/eclipse/mylyn/wikitext/core/ant/tasks.properties" />
  246. <!-- Installation Guide -->
  247. <create-website-part name="YSCT-installation" title="YAKINDU Statechart Tools Installation Guide">
  248. <textile-files>
  249. <filelist dir="${src.dir}">
  250. <file name="installation/installation.textile" />
  251. </filelist>
  252. </textile-files>
  253. <image-files>
  254. <fileset dir="${src.dir}">
  255. <include name="installation/images/**/*" />
  256. </fileset>
  257. </image-files>
  258. </create-website-part>
  259. <!-- Tutorials -->
  260. <create-website-part name="YSCT-tutorials" title="YAKINDU Statechart Tools Tutorials">
  261. <textile-files>
  262. <filelist dir="${src.dir}">
  263. <file name="tutorials/tutorials.textile" />
  264. </filelist>
  265. </textile-files>
  266. <image-files>
  267. <fileset dir="${src.dir}">
  268. <include name="tutorials/images/**/*" />
  269. </fileset>
  270. </image-files>
  271. </create-website-part>
  272. <!-- User Guide -->
  273. <create-website-part name="YSCT-user-guide" title="YAKINDU Statechart Tools User Guide">
  274. <textile-files>
  275. <filelist dir="${src.dir}">
  276. <file name="user-guide/overview.textile" />
  277. <file name="user-guide/editing_statecharts.textile" />
  278. <file name="user-guide/simulating_statecharts.textile" />
  279. <file name="user-guide/advanced_simulation.textile" />
  280. <file name="user-guide/c-domain.textile" />
  281. <file name="user-guide/statechart_language.textile" />
  282. <file name="user-guide/generating_code.textile" />
  283. <file name="user-guide/generating_code_headless.textile" />
  284. <!-- <file name="user-guide/sctunit.textile" /> -->
  285. </filelist>
  286. </textile-files>
  287. <image-files>
  288. <fileset dir="${src.dir}">
  289. <include name="user-guide/images/**/*" />
  290. </fileset>
  291. </image-files>
  292. </create-website-part>
  293. </sequential>
  294. </target>
  295. <!-- Creates a certain part of the HTML documentation for the website. -->
  296. <macrodef name="create-website-part"
  297. description="Creates a certain part of the HTML documentation for the website.">
  298. <attribute name="name" />
  299. <attribute name="title" />
  300. <element name="textile-files" />
  301. <element name="image-files" />
  302. <sequential>
  303. <!-- The directory for this particular part of the HTML documentation: -->
  304. <local name="work.dir" />
  305. <property name="work.dir" location="${website.dir}" />
  306. <!-- The names of the concatenated documentation files: -->
  307. <local name="index.textile" />
  308. <property name="index.textile" value="@{name}.textile" />
  309. <local name="index.html" />
  310. <property name="index.html" value="@{name}.html" />
  311. <!-- Append those source files that make up the particular piece of documentation: -->
  312. <mkdir dir="${work.dir}" />
  313. <concat destfile="${work.dir}/${index.textile}"
  314. append="false"
  315. overwrite="true"
  316. encoding="UTF-8"
  317. outputencoding="UTF-8"
  318. fixlastline="true"
  319. binary="false"
  320. ignoreempty="true">
  321. <textile-files />
  322. </concat>
  323. <!-- Convert textile source files to HTML: -->
  324. <wikitext-to-html markupLanguage="Textile"
  325. multipleOutputFiles="false"
  326. navigationImages="true"
  327. formatoutput="true"
  328. validate="true"
  329. xhtmlStrict="true"
  330. overwrite="true"
  331. failOnValidationError="true"
  332. failOnValidationWarning="false"
  333. sourceEncoding="UTF-8"
  334. title="@{title}">
  335. <fileset dir="${work.dir}">
  336. <include name="${index.textile}" />
  337. </fileset>
  338. <stylesheet url="${css.dir}/${css.root.file}" />
  339. </wikitext-to-html>
  340. <!-- Load website fragments: -->
  341. <sequential unless:set="website.local.files">
  342. <loadfile property="website.header" srcFile="${src.dir}/website/header.htmlf" encoding="UTF-8" />
  343. <loadfile property="website.footer" srcFile="${src.dir}/website/footer.htmlf" encoding="UTF-8" />
  344. <loadfile property="website.calltoaction.download"
  345. srcFile="${src.dir}/website/calltoaction.download.htmlf"
  346. encoding="UTF-8" />
  347. </sequential>
  348. <!-- Load fragments for generating local files which should look simular to the website: -->
  349. <sequential if:set="website.local.files">
  350. <loadfile property="website.header"
  351. srcFile="${src.dir}/website/header.local.files.htmlf"
  352. encoding="UTF-8" />
  353. <loadfile property="website.footer"
  354. srcFile="${src.dir}/website/footer.local.files.htmlf"
  355. encoding="UTF-8" />
  356. <loadfile property="website.calltoaction.download"
  357. srcFile="${src.dir}/website/calltoaction.download.local.files.htmlf"
  358. encoding="UTF-8" />
  359. </sequential>
  360. <!-- Replace "<pre><code>" durch "<pre class="prettyprint"><code>": -->
  361. <replaceregexp byline="false"
  362. flags="g"
  363. match='&lt;pre&gt;&lt;code&gt;'
  364. replace='&lt;pre class="prettyprint"&gt;&lt;code&gt;'>
  365. <fileset dir="${work.dir}">
  366. <include name="${index.html}" />
  367. </fileset>
  368. </replaceregexp>
  369. <!-- Replace relative image links by absolute ones for the website, unless we are generating local files: -->
  370. <replaceregexp byline="false"
  371. flags="g"
  372. match='src="images/'
  373. replace='src="http://info.itemis.com/hubfs/Yakindu/Statechart_Tools/Documentation/images/'
  374. unless:set="website.local.files">
  375. <fileset dir="${work.dir}">
  376. <include name="${index.html}" />
  377. </fileset>
  378. </replaceregexp>
  379. <!-- Replace everything up to and including "<body>" by website-specific header: -->
  380. <replaceregexp byline="false" flags="s" replace="${website.header}">
  381. <regexp pattern="^(.*)&lt;body&gt;" />
  382. <fileset dir="${work.dir}">
  383. <include name="${index.html}" />
  384. </fileset>
  385. </replaceregexp>
  386. <!-- Replace everything from and including "</body>" by website-specific footer: -->
  387. <replaceregexp byline="false" flags="s" replace="${website.footer}">
  388. <regexp pattern="&lt;/body&gt;(.*)$" />
  389. <fileset dir="${work.dir}">
  390. <include name="${index.html}" />
  391. </fileset>
  392. </replaceregexp>
  393. <!-- If the generated code contains a table with the ID "updaterepositories", replace it by a
  394. "call-to-action" button on the website: -->
  395. <replaceregexp byline="false" flags="s" replace="${website.calltoaction.download}">
  396. <regexp pattern='&lt;table id="updaterepositories"&gt;.*&lt;/table&gt;' />
  397. <fileset dir="${work.dir}">
  398. <include name="${index.html}" />
  399. </fileset>
  400. </replaceregexp>
  401. <!-- Fix links: -->
  402. <adjust-website-document-links document.dir.name="tutorials"
  403. work.dir="${work.dir}"
  404. html.file="${index.html}" />
  405. <adjust-website-document-links document.dir.name="user-guide"
  406. work.dir="${work.dir}"
  407. html.file="${index.html}" />
  408. <adjust-website-document-links document.dir.name="installation"
  409. work.dir="${work.dir}"
  410. html.file="${index.html}" />
  411. <!-- Fix "pro-feature" elements -->
  412. <replaceregexp byline="false"
  413. flags="g"
  414. match='&lt;p&gt;&lt;div class="pro-feature"&gt;&lt;/p&gt;'
  415. replace='&lt;div class="pro-feature"&gt;'>
  416. <fileset dir="${work.dir}">
  417. <include name="${index.html}" />
  418. </fileset>
  419. </replaceregexp>
  420. <replaceregexp byline="false" flags="g" match='&lt;p&gt;&lt;/div&gt;&lt;/p&gt;' replace='&lt;/div&gt;'>
  421. <fileset dir="${work.dir}">
  422. <include name="${index.html}" />
  423. </fileset>
  424. </replaceregexp>
  425. <!-- Copy the CSS files to the destination directory: -->
  426. <copy todir="${work.dir}/${css.dir}">
  427. <fileset dir="${css.dir}">
  428. <include name="*" />
  429. </fileset>
  430. </copy>
  431. <!-- Copy the image files to the destination directory: -->
  432. <copy todir="${work.dir}/${img.dir}" flatten="yes">
  433. <image-files />
  434. </copy>
  435. <!-- The textile source file is no longer needed in the website directory. Remove it: -->
  436. <delete includeemptydirs="true" failonerror="false">
  437. <fileset dir="${website.dir}" defaultexcludes="false">
  438. <include name="${index.textile}" />
  439. </fileset>
  440. </delete>
  441. </sequential>
  442. </macrodef>
  443. <!-- Adjusts links in the generated HTML document for either the website or a local equivalent. -->
  444. <macrodef name="adjust-website-document-links"
  445. description="Adjusts links in the generated HTML document for either the website or a local equivalent.">
  446. <attribute name="work.dir" />
  447. <attribute name="html.file" />
  448. <attribute name="document.dir.name" />
  449. <sequential>
  450. <replaceregexp byline="false"
  451. flags="g"
  452. match='&lt;a href="(\.\./@{document.dir.name})/.+\.html(.*)"&gt;'
  453. replace='&lt;a href="\1/\2"&gt;'
  454. unless:set="website.local.files">
  455. <fileset dir="@{work.dir}">
  456. <include name="@{html.file}" />
  457. </fileset>
  458. </replaceregexp>
  459. <replaceregexp byline="false"
  460. flags="g"
  461. match='&lt;a href="\.\.(/@{document.dir.name})/.+\.html(.*)"&gt;'
  462. replace='&lt;a href="YSCT-@{document.dir.name}.html\2"&gt;'
  463. if:set="website.local.files">
  464. <fileset dir="@{work.dir}">
  465. <include name="@{html.file}" />
  466. </fileset>
  467. </replaceregexp>
  468. </sequential>
  469. </macrodef>
  470. </project>