forked from liferay/liferay-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-common.xml
515 lines (453 loc) · 22.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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
<?xml version="1.0"?>
<!--
Use the targets in this script to convert 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 name="project.dir" value=".." />
<path id="lib.classpath">
<fileset dir="${project.dir}/lib" includes="*.jar" />
<fileset dir="${project.dir}/code/liferay-doc-utils/lib" includes="*.jar" />
</path>
<path id="project.classpath">
<path refid="lib.classpath" />
</path>
<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"/>
<!-- taskdefs -->
<taskdef name="checkimgs" classname="com.liferay.documentation.util.CheckImagesTask">
<classpath>
<fileset dir="${project.dir}/lib" includes="*.jar" />
<!-- Use below instead of above fileset when testing changes to classes
<pathelement path="${project.dir}/code/liferay-doc-utils/classes"/>
-->
<fileset dir="${project.dir}/code/liferay-doc-utils/lib" includes="*.jar" />
</classpath>
</taskdef>
<taskdef name="checkdocprops" classname="com.liferay.documentation.util.CheckDocPropsTask">
<classpath>
<fileset dir="${project.dir}/lib" includes="*.jar" />
<!-- Use below instead of above fileset when testing changes to classes
<pathelement path="${project.dir}/code/liferay-doc-utils/classes"/>
-->
<fileset dir="${project.dir}/code/liferay-doc-utils/lib" includes="*.jar" />
</classpath>
</taskdef>
<taskdef name="cleanimgs" classname="com.liferay.documentation.util.CleanImagesTask">
<classpath>
<fileset dir="${project.dir}/lib" includes="*.jar" />
<!-- Use below instead of above fileset when testing changes to classes
<pathelement path="${project.dir}/code/liferay-doc-utils/classes"/>
-->
<fileset dir="${project.dir}/code/liferay-doc-utils/lib" includes="*.jar" />
</classpath>
</taskdef>
<taskdef name="numberimages" classname="com.liferay.documentation.util.NumberImagesTask">
<classpath>
<fileset dir="${project.dir}/lib" includes="*.jar" />
<!-- Use below instead of above fileset when testing changes to classes
<pathelement path="${project.dir}/code/liferay-doc-utils/classes"/>
-->
<fileset dir="${project.dir}/code/liferay-doc-utils/lib" includes="*.jar" />
</classpath>
</taskdef>
<taskdef name="stripheaderids" classname="com.liferay.documentation.util.StripHeaderIdsTask">
<classpath>
<fileset dir="${project.dir}/lib" includes="*.jar" />
<!-- Use below instead of above fileset when testing changes to classes
<pathelement path="${project.dir}/code/liferay-doc-utils/classes"/>
-->
<fileset dir="${project.dir}/code/liferay-doc-utils/lib" includes="*.jar" />
</classpath>
</taskdef>
<taskdef name="concatmarkdown" classname="com.liferay.documentation.util.ConcatMarkdown">
<classpath>
<fileset dir="${project.dir}/lib" includes="*.jar" />
<fileset dir="${project.dir}/code/liferay-doc-utils/lib" includes="*.jar" />
</classpath>
</taskdef>
<!-- targets -->
<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="check-images" description="verifies all images referenced in markdown files for a document or chapter">
<checkimgs docdir="${doc.dir}" lang="${lang}" chapter="${chapter}">
</checkimgs>
</target>
<target name="check-doc-props" description="checks that all document dirs have a valid doc.properties file">
<checkdocprops lang="${lang}" basedir="${project.dir}">
</checkdocprops>
</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-images" description="removes unused images for a document">
<cleanimgs docdir="${doc.dir}" lang="${lang}">
</cleanimgs>
</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" depends="check-images, number-headers, number-images-dir" description="numbers the headers and images in the files, creates dist directory, copies 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">
<property file="./doc.properties" />
<copy todir="${dist.dir}/${lang}">
<fileset dir="${build.dir}/${lang}">
<include name="${lang}-${product.abbrev}-${product.version}-${doc.dir}.markdown"/>
</fileset>
</copy>
<zip destfile="${dist.dir}/${lang}/${lang}-${product.abbrev}-${product.version}-${doc.dir}.zip">
<fileset dir="${dist.dir}/${lang}" includes="images/*.*"/>
<fileset dir="${dist.dir}/${lang}" includes="${lang}-${product.abbrev}-${product.version}-${doc.dir}.markdown"/>
</zip>
</target>
<target name="concat-markdown-files" depends="prepare" description="concatenates multiple markdown files into a single one">
<property file="./doc.properties" />
<echo message="... concatenating markdown files for ${product.name} ${product.version}-${doc.name} (${lang})"/>
<concat destfile="./${build.dir}/${lang}/${lang}-${product.abbrev}-${product.version}-${doc.dir}.markdown" fixlastline = "yes">
<fileset dir="./${lang}" casesensitive="yes">
<include name="**/*.markdown"/>
</fileset>
</concat>
</target>
<target name="markdown-to-html" depends="check-images, add-markdown-metadata" description="converts markdown file to an html file">
<echo message="... converting ${product.name} ${product.version}-${doc.name} (${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}-${product.abbrev}-${product.version}-${doc.dir}.html"/>
<arg value="${build.dir}/${lang}/${lang}-${product.abbrev}-${product.version}-${doc.dir}.markdown"/>
</exec>
</target>
<target name="markdown-to-html-win" depends="check-images, concat-markdown-files" description="converts markdown file to an html file on windows">
<echo message="... converting ${product.name} ${product.version}-${doc.name} (${lang}) to html"/>
<!-- pandoc -f markdown -t html +RTS K64m -RTS -o 01-chapter-02.html 01-chapter-02.markdown -->
<exec executable="cmd" dir="${build.dir}/${lang}">
<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="${lang}-${product.abbrev}-${product.version}-${doc.dir}.html"/>
<arg value="${lang}-${product.abbrev}-${product.version}-${doc.dir}.markdown"/>
</exec>
</target>
<target name="markdown-to-odt" depends="check-images, add-markdown-metadata" description="converts markdown file to an odt file">
<echo message="... converting ${product.name} ${product.version}-${doc.name} (${lang}) to odt"/>
<!-- pandoc -f markdown -t odt -o test-guide.odt test-guide.markdown -->
<exec executable="${pandoc.app}" dir="${build.dir}/${lang}">
<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="./${lang}-${product.abbrev}-${product.version}-${doc.dir}.odt"/>
<arg value="./${lang}-${product.abbrev}-${product.version}-${doc.dir}.markdown"/>
</exec>
</target>
<target name="markdown-to-odt-win" depends="check-images, concat-markdown-files" description="converts markdown file to an ODT file on Windows">
<echo message="... converting ${product.name} ${product.version}-${doc.name} (${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" dir="${build.dir}/${lang}">
<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="${lang}-${product.abbrev}-${product.version}-${doc.dir}.odt"/>
<arg value="${lang}-${product.abbrev}-${product.version}-${doc.dir}.markdown"/>
</exec>
</target>
<target name="markdown-to-epub" depends="check-images, add-markdown-metadata" description="converts markdown file to an epub file">
<echo message="... converting ${product.name} ${product.version}-${doc.name} (${lang}) to epub"/>
<!-- pandoc -f markdown -t epub -o test-guide.epub test-guide.markdown -->
<exec executable="${pandoc.app}" dir="${build.dir}/${lang}">
<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="${lang}-${product.abbrev}-${product.version}-${doc.dir}.epub"/>
<arg value="${lang}-${product.abbrev}-${product.version}-${doc.dir}.markdown"/>
</exec>
</target>
<target name="markdown-to-epub-win" depends="check-images, concat-markdown-files" description="converts markdown file to an epub file on windows">
<echo message="... converting ${product.name} ${product.version}-${doc.name} (${lang}) to epub"/>
<exec executable="cmd" dir="${build.dir}/${lang}">
<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="${lang}-${product.abbrev}-${product.version}-${doc.dir}.epub"/>
<arg value="${lang}-${product.abbrev}-${product.version}-${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="number-headers" depends="check-doc-props" description="numbers the headers of markdown files found in ${lang}/chapters/">
<java
classname="com.liferay.documentation.util.NumberHeadersTask"
classpathref="project.classpath"
failonerror="true"
fork="true"
>
<arg value="${doc.dir}"/>
<arg value="${lang}"/>
</java>
</target>
<target name="number-images-dir" description="numbers the images of markdown files found in ${lang}/chapters/">
<numberimages lang="${lang}" docDir="${doc.dir}">
</numberimages>
</target>
<target name="strip-header-ids-dir" description="strips out the header ids of markdown files found in ${lang}/chapters/">
<stripheaderids lang="${lang}" docDir="${doc.dir}">
</stripheaderids>
</target>
<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="check-images, 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}" dir="${build.dir}/${lang}">
<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="${lang}-${chapter}.html"/>
<arg value="${lang}-${chapter}.markdown"/>
</exec>
</target>
<target name="chapter-to-html-win" depends="check-images, 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" dir="${build.dir}/${lang}">
<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="${lang}-${chapter}.html"/>
<arg value="${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}" dir="${build.dir}/${lang}">
<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="./${lang}-${chapter}.odt"/>
<arg value="./${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 overwriting 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 overwriting 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 ${product.name} ${product.version}-${doc.name} (${lang})"/>
<java jar="../lib/liferay-doc-utils.jar" fork="true">
<arg value="AddMarkdownMetadata"/>
<arg value="./${build.dir}/${lang}/${lang}-${product.abbrev}-${product.version}-${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>
<target name="add-index" description="adds an index to the LaTeX source of a document before converting it to PDF">
<echo message="... adding index"/>
<java jar="../lib/liferay-doc-utils.jar" fork="true">
<arg value="AddIndex"/>
<arg value="en/print/en-userGuide.tex"/>
<arg value="userguide.lexicon"/>
<arg value="en/print/indexed-en-userGuide.tex"/>
</java>
<exec executable="xelatex">
<arg value="en/print/indexed-en-userGuide.tex"/>
</exec>
<exec executable="makeindex">
<arg value="en/print/indexed-en-userGuide"/>
</exec>
<exec executable="xelatex">
<arg value="en/print/indexed-en-userGuide.tex"/>
</exec>
</target>
</project>