forked from liferay/liferay-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-common.xml
407 lines (364 loc) · 18.9 KB
/
build-common.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
<?xml version="1.0"?>
<!--
This ant script was created for converting the separate markdown chapter files of our documents into complete markdown, html, odt, and epub files.
Remember to use the script in the root directory of the document to be converted, NOT THIS ONE.
For example, use the "ant markdown-to-all" command from the documentation/trunk/userGuide directory to convert the userGuide into complete English markdown, html, odt, and epub documents.
-->
<project name="Markdown Document Conversion" default="echo-props" basedir=".">
<property environment="env" />
<property file="../build.${USERNAME}.properties" />
<property file="../build.${user.name}.properties" />
<property file="../build.${env.COMPUTERNAME}.properties" />
<property file="../build.${env.HOST}.properties" />
<property file="../build.${env.HOSTNAME}.properties" />
<property file="../build.properties" />
<!-- property "doc.dir" will be specified in the build.xml of the document root directory. -->
<property name="lang" value="en"/>
<property name="build.dir" value="./build"/>
<property name="dist.dir" value="./dist"/>
<property name="pandoc.app" location="/home/${user.name}/.cabal/bin/pandoc"/>
<target name="display-pandoc-version">
<exec executable="${pandoc.app}">
<arg value="-v" />
</exec>
</target>
<target name="echo-props">
<echo message="pandoc.app -> ${pandoc.app}"/>
</target>
<target name="clean-all" description="deletes residual directories">
<echo message="... deleting build directory"/>
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<target name="clean-dist" description="deletes dist directory">
<echo message="... deleting dist directory"/>
<delete dir="${dist.dir}"/>
</target>
<target name="clean-lang" description="deletes build/${lang} directory">
<echo message="... deleting language specific residual directories"/>
<delete dir="${build.dir}/${lang}"/>
<delete dir="${dist.dir}/${lang}"/>
</target>
<target name="prepare" description="creates build/${lang} directory">
<echo message="... creating build/${lang} directory"/>
<mkdir dir="${build.dir}/${lang}"/>
<copy todir="${build.dir}/images">
<fileset dir="./${lang}/images"/>
</copy>
</target>
<target name="prepare-dist" description="creates dist directory copying images and overriding with language specific images">
<echo message="... creating ${dist.dir}/${lang} directory"/>
<mkdir dir="${dist.dir}/${lang}"/>
<copy todir="${dist.dir}/${lang}/images">
<fileset dir="images" includes="*.*"/>
</copy>
<copy overwrite="true" todir="${dist.dir}/${lang}/images">
<fileset dir="${lang}/images" includes="*.*"/>
</copy>
</target>
<target name="dist" depends="clean-lang, prepare-dist, concat-markdown-files" description="prepares document zip file for asset import">
<copy todir="${dist.dir}/${lang}">
<fileset dir="${build.dir}/${lang}">
<include name="${lang}-${doc.dir}.markdown"/>
</fileset>
</copy>
<zip destfile="${dist.dir}/${lang}/${lang}-${doc.dir}.zip">
<fileset dir="${dist.dir}/${lang}" includes="images/*.*"/>
<fileset dir="${dist.dir}/${lang}" includes="${lang}-${doc.dir}.markdown"/>
</zip>
</target>
<target name="dist-win" depends="clean-lang, prepare-dist, concat-markdown-files-win" description="prepares document zip file for asset import on windows">
<copy todir="${dist.dir}/${lang}">
<fileset dir="${build.dir}/${lang}">
<include name="${lang}-${doc.dir}.markdown"/>
</fileset>
</copy>
<zip destfile="${dist.dir}/${lang}/${lang}-${doc.dir}.zip">
<fileset dir="${dist.dir}/${lang}" includes="images/*.*"/>
<fileset dir="${dist.dir}/${lang}" includes="${lang}-${doc.dir}.markdown"/>
</zip>
</target>
<target name="concat-markdown-files" depends="prepare" description="concatinates multiple markdown files into a single one">
<echo message="... concatinating markdown files for ${doc.dir} (${lang})"/>
<concat destfile="./${build.dir}/${lang}/${lang}-${doc.dir}.markdown">
<fileset dir="./${lang}" casesensitive="yes">
<include name="**/*.markdown"/>
</fileset>
</concat>
</target>
<target name="concat-markdown-files-win" depends="prepare"
description="concatinates multiple markdown files into a single one">
<echo message="... concatinating markdown files for ${doc.dir} (${lang}) on Windows"/>
<exec executable="cmd">
<arg value="/C" />
<arg value="for"/>
<arg value="%f"/>
<arg value="in"/>
<arg value="(.\\${lang}\\chapters\\*.markdown)"/>
<arg value="do"/>
<arg value="type"/>
<arg value=""%f""/>
<arg value=">>"/>
<arg value="${build.dir}/${lang}/${lang}-${doc.dir}.markdown"/>
</exec>
</target>
<target name="markdown-to-html" depends="add-markdown-metadata" description="converts markdown file to an html file">
<echo message="... converting ${doc.dir} (${lang}) to html"/>
<!-- pandoc -f markdown -t html -o test-guide.html test-guide.markdown -->
<exec executable="${pandoc.app}">
<arg value="-f" />
<arg value="markdown"/>
<arg value="-t"/>
<arg value="html"/>
<!--<arg value="+RTS"/>
<arg value="-K64m"/>
<arg value="-RTS"/>
<arg value="-smart"/>-->
<arg value="-o"/>
<arg value="${build.dir}/${lang}/${lang}-${doc.dir}.html"/>
<arg value="${build.dir}/${lang}/${lang}-${doc.dir}.markdown"/>
</exec>
</target>
<target name="markdown-to-html-win" depends="concat-markdown-files-win" description="converts markdown file to an html file on windows">
<echo message="... converting ${doc.dir} (${lang}) to html"/>
<!-- pandoc -f markdown -t html +RTS K64m -RTS -o 01-chapter-02.html 01-chapter-02.markdown -->
<exec executable="cmd">
<arg value="/C" />
<arg value="pandoc"/>
<arg value="-f" />
<arg value="markdown"/>
<arg value="-t"/>
<arg value="html"/>
<arg value="+RTS"/>
<arg value="-K64m"/>
<arg value="-RTS"/>
<arg value="-smart"/>
<arg value="-o"/>
<arg value="${build.dir}/${lang}/${lang}-${doc.dir}.html"/>
<arg value="${build.dir}/${lang}/${lang}-${doc.dir}.markdown"/>
</exec>
</target>
<target name="markdown-to-odt" depends="add-markdown-metadata" description="converts markdown file to an odt file">
<echo message="... converting ${doc.dir} (${lang}) to odt"/>
<!-- pandoc -f markdown -t odt -o test-guide.odt test-guide.markdown -->
<exec executable="${pandoc.app}">
<arg value="-f" />
<arg value="markdown"/>
<arg value="-t"/>
<arg value="odt"/>
<!--<arg value="+RTS"/>
<arg value="-K64m"/>
<arg value="-RTS"/>
<arg value="-smart"/>-->
<arg value="-o"/>
<arg value="${build.dir}/${lang}/${lang}-${doc.dir}.odt"/>
<arg value="${build.dir}/${lang}/${lang}-${doc.dir}.markdown"/>
</exec>
</target>
<target name="markdown-to-odt-win" depends="concat-markdown-files-win" description="converts markdown file to an ODT file on Windows">
<echo message="... converting ${doc.dir} (${lang}) to odt on windows"/>
<!-- pandoc -f markdown -t odt +RTS K64m -RTS -o 01-chapter-02.odt 01-chapter-02.markdown -->
<exec executable="cmd">
<arg value="/C" />
<arg value="pandoc"/>
<arg value="-f" />
<arg value="markdown"/>
<arg value="-t"/>
<arg value="odt"/>
<arg value="+RTS"/>
<arg value="-K64m"/>
<arg value="-RTS"/>
<arg value="-smart"/>
<arg value="-o"/>
<arg value="${build.dir}/${lang}/${lang}-${doc.dir}.odt"/>
<arg value="${build.dir}/${lang}/${lang}-${doc.dir}.markdown"/>
</exec>
</target>
<target name="markdown-to-epub" depends="add-markdown-metadata" description="converts markdown file to an epub file">
<echo message="... converting ${doc.dir} (${lang}) to epub"/>
<!-- pandoc -f markdown -t epub -o test-guide.epub test-guide.markdown -->
<exec executable="${pandoc.app}">
<arg value="-f" />
<arg value="markdown"/>
<arg value="-t"/>
<arg value="epub"/>
<!--<arg value="+RTS"/>
<arg value="-K64m"/>
<arg value="-RTS"/>
<arg value="-smart"/>-->
<arg value="-o"/>
<arg value="${build.dir}/${lang}/${lang}-${doc.dir}.epub"/>
<arg value="${build.dir}/${lang}/${lang}-${doc.dir}.markdown"/>
</exec>
</target>
<target name="markdown-to-epub-win" depends="concat-markdown-files-win" description="converts markdown file to an epub file on windows">
<echo message="... converting ${doc.dir} (${lang}) to epub"/>
<exec executable="cmd">
<arg value="/C" />
<arg value="pandoc"/>
<arg value="-f" />
<arg value="markdown"/>
<arg value="-t"/>
<arg value="epub"/>
<arg value="+RTS"/>
<arg value="-K64m"/>
<arg value="-RTS"/>
<arg value="-o"/>
<arg value="${build.dir}/${lang}/${lang}-${doc.dir}.epub"/>
<arg value="${build.dir}/${lang}/${lang}-${doc.dir}.markdown"/>
</exec>
</target>
<target name="markdown-to-all" depends="markdown-to-html,markdown-to-odt,markdown-to-epub" description="converts markdown file to html, odt, and epub files" />
<target name="markdown-to-all-win" depends="markdown-to-html-win,markdown-to-odt-win,markdown-to-epub-win" description="converts markdown file to html, odt, and epub files on windows" />
<target name="copy-single-chapter" depends="prepare" description="copies chapter to be converted">
<echo message="... copying ${chapter}"/>
<copy file="./en/chapters/${chapter}.markdown" todir="./${build.dir}/${lang}"/>
<move file="./${build.dir}/${lang}/${chapter}.markdown" tofile="./${build.dir}/${lang}/${lang}-${chapter}.markdown" />
</target>
<target name="chapter-to-html" depends="copy-single-chapter" description="converts single markdown chapter to an html file">
<echo message="... converting ${chapter} (${lang}) to html"/>
<!-- pandoc -f markdown -t html -o 01-introduction-to-liferay-ui.html 01-introduction-to-liferay-ui.markdown -->
<exec executable="${pandoc.app}">
<arg value="-f" />
<arg value="markdown"/>
<arg value="-t"/>
<arg value="html"/>
<!--<arg value="+RTS"/>
<arg value="-K64m"/>
<arg value="-RTS"/>
<arg value="-smart"/>-->
<arg value="-o"/>
<arg value="${build.dir}/${lang}/${lang}-${chapter}.html"/>
<arg value="${build.dir}/${lang}/${lang}-${chapter}.markdown"/>
</exec>
</target>
<target name="chapter-to-html-win" depends="copy-single-chapter" description="converts single markdown chapter to an html file on windows">
<echo message="... converting ${chapter} (${lang}) to html"/>
<!-- pandoc -f markdown -t html -o 01-introduction-to-liferay-ui.html 01-introduction-to-liferay-ui.markdown -->
<exec executable="cmd">
<arg value="/C" />
<arg value="pandoc"/>
<arg value="-f" />
<arg value="markdown"/>
<arg value="-t"/>
<arg value="html"/>
<arg value="+RTS"/>
<arg value="-K64m"/>
<arg value="-RTS"/>
<arg value="-smart"/>
<arg value="-o"/>
<arg value="${build.dir}/${lang}/${lang}-${chapter}.html"/>
<arg value="${build.dir}/${lang}/${lang}-${chapter}.markdown"/>
</exec>
</target>
<target name="chapter-to-odt" depends="copy-single-chapter" description="converts single markdown chapter to an odt file">
<echo message="... converting ${chapter} (${lang}) to odt"/>
<!-- pandoc -f markdown -t odt -o 01-introduction-to-liferay-ui.odt 01-introduction-to-liferay-ui.markdown -->
<exec executable="${pandoc.app}">
<arg value="-f" />
<arg value="markdown"/>
<arg value="-t"/>
<arg value="odt"/>
<!--<arg value="+RTS"/>
<arg value="-K64m"/>
<arg value="-RTS"/>
<arg value="-smart"/>-->
<arg value="-o"/>
<arg value="${build.dir}/${lang}/${lang}-${chapter}.odt"/>
<arg value="${build.dir}/${lang}/${lang}-${chapter}.markdown"/>
</exec>
</target>
<target name="chapter-to-odt-win" depends="copy-single-chapter" description="converts single markdown chapter to an odt file on windows">
<echo message="... converting ${chapter} (${lang}) to odt"/>
<!-- pandoc -f markdown -t odt -o 01-introduction-to-liferay-ui.odt 01-introduction-to-liferay-ui.markdown -->
<exec executable="cmd">
<arg value="/C" />
<arg value="pandoc"/>
<arg value="-f" />
<arg value="markdown"/>
<arg value="-t"/>
<arg value="odt"/>
<arg value="+RTS"/>
<arg value="-K64m"/>
<arg value="-RTS"/>
<arg value="-smart"/>
<arg value="-o"/>
<arg value="${build.dir}/${lang}/${lang}-${chapter}.odt"/>
<arg value="${build.dir}/${lang}/${lang}-${chapter}.markdown"/>
</exec>
</target>
<target name="chapter-to-epub" depends="copy-single-chapter" description="converts single markdown chapter to an epub file">
<echo message="... converting ${chapter} (${lang}) to epub"/>
<!-- pandoc -f markdown -t epub -o 01-introduction-to-liferay-ui.odt 01-introduction-to-liferay-ui.markdown -->
<exec executable="${pandoc.app}">
<arg value="-f" />
<arg value="markdown"/>
<arg value="-t"/>
<arg value="epub"/>
<!--<arg value="+RTS"/>
<arg value="-K64m"/>
<arg value="-RTS"/>
<arg value="-smart"/>-->
<arg value="-o"/>
<arg value="${build.dir}/${lang}/${lang}-${chapter}.epub"/>
<arg value="${build.dir}/${lang}/${lang}-${chapter}.markdown"/>
</exec>
</target>
<target name="chapter-to-epub-win" depends="copy-single-chapter" description="converts single markdown chapter to an epub file on windows">
<echo message="... converting ${chapter} (${lang}) to epub"/>
<!-- pandoc -f markdown -t epub -o 01-introduction-to-liferay-ui.odt 01-introduction-to-liferay-ui.markdown -->
<exec executable="cmd">
<arg value="/C" />
<arg value="pandoc"/>
<arg value="-f" />
<arg value="markdown"/>
<arg value="-t"/>
<arg value="epub"/>
<arg value="+RTS"/>
<arg value="-K64m"/>
<arg value="-RTS"/>
<arg value="-smart"/>
<arg value="-o"/>
<arg value="${build.dir}/${lang}/${lang}-${chapter}.epub"/>
<arg value="${build.dir}/${lang}/${lang}-${chapter}.markdown"/>
</exec>
</target>
<target name="chapter-to-all" depends="chapter-to-html,chapter-to-odt,chapter-to-epub" description="converts markdown chapter file to html, odt, and epub files" />
<target name="chapter-to-all-win" depends="chapter-to-html-win,chapter-to-odt-win,chapter-to-epub-win" description="converts markdown chapter file to html, odt, and epub files on windows" />
<target name="reset-images" description="resets the image numbers in a markdown chapter file">
<echo message="... resetting image numbers in ${chapter} (${lang})"/>
<java jar="../lib/liferay-doc-utils.jar" fork="true">
<arg value="ResetImages"/>
<arg value="./${lang}/chapters/${chapter}.markdown"/>
<!-- This is useful if you want to save the output to a new file without overwritting the original <arg value="${build.dir}/${chapter}.markdown"/> -->
</java>
</target>
<!-- Example: From liferay-docs/userGuide, enter the following command: ant number-images -Dchapter=12-administering-liferay-portal. Check liferay-docs/userGuide/build for your new file. The images should be numbered correctly. -->
<target name="number-images" depends="reset-images" description="numbers the images in a markdown chapter file">
<echo message="... numbering images in ${chapter} (${lang})"/>
<java jar="../lib/liferay-doc-utils.jar" fork="true">
<!-- <arg value="${build.dir}/${chapter}.markdown"/> -->
<arg value="NumberImages"/>
<arg value="./${lang}/chapters/${chapter}.markdown" />
<!-- This is useful if you want to save the output to a new file without overwritting the original <arg value="${build.dir}/${chapter}.markdown"/> -->
</java>
</target>
<!-- deprecated on Jan. 6, 2012 -->
<target name="add-markdown-metadata" depends="concat-markdown-files" description="adds metadata to the top of a concatenated markdown file">
<echo message="... adding metadata to ${doc.dir} (${lang})"/>
<java jar="../lib/liferay-doc-utils.jar" fork="true">
<arg value="AddMarkdownMetadata"/>
<arg value="./${build.dir}/${lang}/${lang}-${doc.dir}.markdown"/>
<arg value="${title}"/>
<arg value="${author}"/>
<arg value="${date}"/>
</java>
</target>
<target name="add-markdown-ch-template" description="adds metadata template to the top of a markdown chapter file">
<echo message="... adding metadata template to ${chapter} (${lang})"/>
<java jar="../lib/liferay-doc-utils.jar" fork="true">
<arg value="AddMarkdownChTemplate"/>
<arg value="./${lang}/chapters/${chapter}.markdown"/>
</java>
</target>
</project>