forked from vicnate5/liferay-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-site-common.xml
414 lines (351 loc) · 15.8 KB
/
build-site-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
<?xml version="1.0"?>
<project name="Dev Site Documentation Management" 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 name="build.dir" value="./build"/>
<property name="dist.dir" value="./dist"/>
<property name="metadata.filename" value=".METADATA"/>
<property name="temp.dir" value="temp"/>
<!-- taskdefs -->
<taskdef name="checkarticleimgssite" classname="com.liferay.documentation.util.CheckArticleImagesTaskDevSite">
<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="checkimgssite" classname="com.liferay.documentation.util.CheckImagesTaskDevSite">
<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="checkintros" classname="com.liferay.documentation.util.CheckIntrosTask">
<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="distdiff" classname="com.liferay.documentation.util.DistDiffTask">
<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="numberimgssite" classname="com.liferay.documentation.util.NumberImagesTaskDevSite">
<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="article-to-html" depends="prepare, check-article-images" description="Converts a single Markdown article to an HTML file.">
<echo message="... converting ${article} to html file ${build.dir}/${article}.html"/>
<java
classname="com.liferay.documentation.util.MarkdownToHtmlMain"
classpathref="project.classpath"
failonerror="true"
fork="true"
>
<arg value="${article}"/>
<arg value="${build.dir}/${article}.html"/>
</java>
</target>
<target name="check-headers" description="Check the headers of Markdown articles found in ${doc.dir}/articles">
<java
classname="com.liferay.documentation.util.CheckHeadersTask"
classpathref="project.classpath"
fork="true"
failonerror="true"
>
<arg value="${doc.dir}"/>
<arg value="ce"/>
</java>
</target>
<target name="check-headers-dist" description="Check the headers of Markdown articles found in ${doc.dir}/articles and ${doc.dir}/articles-dxp">
<java
classname="com.liferay.documentation.util.CheckHeadersTask"
classpathref="project.classpath"
fork="true"
failonerror="true"
>
<arg value="${doc.dir}/${temp.dir}"/>
<arg value="dist"/>
</java>
</target>
<target name="check-headers-dxp" description="Check the headers of Markdown articles found in ${doc.dir}/articles">
<java
classname="com.liferay.documentation.util.CheckHeadersTask"
classpathref="project.classpath"
fork="true"
failonerror="true"
>
<arg value="${doc.dir}"/>
<arg value="dxp"/>
</java>
</target>
<target name="concat-markdown" description="Concatenates the Markdown files in a specific folder for preparation to convert to other formats.">
<concatmarkdown docdir="${doc.dir}">
</concatmarkdown>
<move file="./book.markdown" tofile="${dist.dir}/book/text/${doc.dir}.markdown" />
<copy todir="${dist.dir}/images">
<fileset dir="images" includes="*.*"/>
</copy>
</target>
<target name="check" depends="check-images-site, check-intros, number-headers, number-images-site, check-headers" description="Checks for necessary requirements before CE distribution.">
</target>
<target name="check-dxp" depends="check-images-site-dxp, check-intros-dxp, number-headers-dxp, number-images-site-dxp, check-headers-dxp" description="Checks for necessary requirements before DXP distribution.">
</target>
<target name="check-article-images" description="Verifies all images referenced in a single Markdown article.">
<checkarticleimgssite docdir="${doc.dir}" article="${article}">
</checkarticleimgssite>
</target>
<target name="check-images-site" description="Verifies all images referenced in a project's Markdown articles found in ${doc.dir}/articles.">
<checkimgssite docdir="${doc.dir}" producttype="ce">
</checkimgssite>
</target>
<target name="check-images-site-dist" description="Verifies all images referenced in a project's Markdown articles.">
<checkimgssite docdir="${doc.dir}/${temp.dir}" producttype="dist">
</checkimgssite>
</target>
<target name="check-images-site-dxp" description="Verifies all images referenced in a project's Markdown articles found in ${doc.dir}/articles.">
<checkimgssite docdir="${doc.dir}" producttype="dxp">
</checkimgssite>
</target>
<target name="check-intros" description="Verifies all Learning Path article folders are accompanied with an introduction Markdown article.">
<checkintros docdir="${doc.dir}">
</checkintros>
</target>
<target name="check-intros-dist" description="Verifies all Learning Path article folders are accompanied with an introduction Markdown article.">
<checkintros docdir="${doc.dir}/${temp.dir}">
</checkintros>
</target>
<target name="check-intros-dxp" description="Verifies all Learning Path article folders are accompanied with an introduction Markdown article.">
<property name="base.filepath" value="${doc.dir}" />
<mkdir dir="${temp.dir}"/>
<copy todir="${temp.dir}">
<fileset dir="${project.dir}/${purpose.dir}/${base.filepath}">
<include name="articles/**/*.markdown"/>
<include name="articles-dxp/**/*.markdown"/>
</fileset>
</copy>
<move todir="${temp.dir}/articles" failonerror="false">
<fileset dir="${temp.dir}/articles-dxp"/>
</move>
<checkintros docdir="${doc.dir}/${temp.dir}">
</checkintros>
<delete dir="${temp.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="Deletes images from ${doc.dir}/images and ${doc.dir}/images-dxp that are not referenced in any of the markdown files in any subdirectory of ${doc.dir}/articles and ${doc.dir}/articles-dxp">
<java
classname="com.liferay.documentation.util.CleanImagesSiteMain"
classpathref="project.classpath"
failonerror="true"
fork="true"
>
<arg value="${doc.dir}"/>
</java>
</target>
<target name="compare-with-older-branch" description="Compares your current branch with an older branch, specified by -Dolder.branch=someOlderBranch.">
<java
classname="com.liferay.documentation.util.GitCompare"
classpathref="project.classpath"
failonerror="true"
fork="true"
>
<arg value="${doc.dir}"/>
<arg value="${purpose.dir}"/>
<arg value="${older.branch}"/>
</java>
</target>
<target name="create-metadata-file" description="Builds a metadata file.">
<!-- Use base.filepath property to distinguish between tutorials and learning-paths directories. The build.xml file
in the learning-paths directory overwrites this value with "learning-paths/${doc.dir}" -->
<property name="base.filepath" value="${doc.dir}" />
<property name="metadata.file" value="${project.dir}/${purpose.dir}/${base.filepath}/${metadata.filename}"/>
<delete file="${metadata.file}" failonerror="false"/>
<concat destfile="${metadata.file}">base.source.url=https://github.com/${repo.owner}/${repo.name}/blob/${repo.branch}/${purpose.dir}/${base.filepath}</concat>
</target>
<target name="dist-ce" depends="dist-ce-temp, prepare-dist" description="Zips up the folder's CE articles and images for importing.">
<zip destfile="${dist.dir}/${product.abbrev}-${product.community}-${product.version}-${purpose.dir}-${doc.dir}.zip">
<fileset dir="${temp.dir}" includes="articles/" />
<fileset dir="${temp.dir}" includes="images/" />
<fileset dir="./" includes="${metadata.filename}" />
</zip>
<delete dir="${temp.dir}"/>
</target>
<target name="dist-ce-temp" description="Zips up the folder's CE articles and images for importing.">
<property file="${project.dir}/release-site.properties" />
<property name="base.filepath" value="${doc.dir}" />
<mkdir dir="${temp.dir}"/>
<copy todir="${temp.dir}">
<fileset dir="${project.dir}/${purpose.dir}/${base.filepath}">
<include name="articles/**/*.markdown"/>
</fileset>
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
<param type="token" name="${product.token}" value="${product.name}"/>
</filterreader>
</filterchain>
</copy>
<copy todir="${temp.dir}">
<fileset dir="${project.dir}/${purpose.dir}/${base.filepath}">
<include name="images/**/*.png"/>
<include name="images/**/*.jpg"/>
</fileset>
</copy>
</target>
<target name="dist-dxp" depends="dist-dxp-temp, prepare-dist" description="Zips up the folder's CE and DXP articles and images for importing.">
<zip destfile="${dist.dir}/${product.abbrev}-${product.enterprise}-${product.version}-${purpose.dir}-${doc.dir}.zip">
<fileset dir="${temp.dir}" includes="articles/" />
<fileset dir="${temp.dir}" includes="images/" />
<fileset dir="./" includes="${metadata.filename}" />
</zip>
<delete dir="${temp.dir}"/>
</target>
<target name="dist-dxp-temp" description="Zips up the folder's CE and DXP articles and images for importing.">
<property file="${project.dir}/release-site.properties" />
<property name="base.filepath" value="${doc.dir}" />
<mkdir dir="${temp.dir}"/>
<copy todir="${temp.dir}">
<fileset dir="${project.dir}/${purpose.dir}/${base.filepath}">
<include name="articles/**/*.markdown"/>
<include name="articles-dxp/**/*.markdown"/>
</fileset>
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
<param type="token" name="${product.token}" value="${product.name.enterprise}"/>
</filterreader>
</filterchain>
</copy>
<!-- Cannot use filtering for images (due to corruption), so must copy separately -->
<copy todir="${temp.dir}">
<fileset dir="${project.dir}/${purpose.dir}/${base.filepath}">
<include name="images/**/*.png"/>
<include name="images-dxp/**/*.png"/>
<include name="images/**/*.jpg"/>
<include name="images-dxp/**/*.jpg"/>
</fileset>
</copy>
<move todir="${temp.dir}/articles" failonerror="false">
<fileset dir="${temp.dir}/articles-dxp"/>
</move>
<move todir="${temp.dir}/images" failonerror="false">
<fileset dir="${temp.dir}/images-dxp"/>
</move>
</target>
<target name="dist-diffs" depends="prepare-dist" description="Zips up the document's articles and images that are new or modified, as specified in the git-modified-list.txt file.">
<mkdir dir="${dist.dir}"/>
<distdiff docdir="${doc.dir}" purposedir="${purpose.dir}">
</distdiff>
<!-- Until the Markdown converter no longer requires intro files that need to be added manually to the diffs.zip, include ALL images in the ZIP. -->
<zip destfile="${dist.dir}/diffs.zip" update="true">
<fileset dir="./" includes="images/" />
<fileset dir="./" includes="${metadata.filename}" />
</zip>
</target>
<target name="number-headers" description="Numbers the headers of Markdown articles found in ${doc.dir}/articles">
<property file="${project.dir}/release-site.properties" />
<java
classname="com.liferay.documentation.util.NumberHeadersSiteMain"
classpathref="project.classpath"
failonerror="true"
fork="true"
>
<arg value="${doc.dir}"/>
<arg value="ce"/>
<arg value="${product.token}"/>
</java>
</target>
<target name="number-headers-dist" description="Numbers the headers of Markdown articles.">
<property file="${project.dir}/release-site.properties" />
<java
classname="com.liferay.documentation.util.NumberHeadersSiteMain"
classpathref="project.classpath"
failonerror="true"
fork="true"
>
<arg value="${doc.dir}/${temp.dir}"/>
<arg value="dist"/>
<arg value="${product.token}"/>
</java>
</target>
<target name="number-headers-dxp" description="Numbers the headers of Markdown articles.">
<property file="${project.dir}/release-site.properties" />
<java
classname="com.liferay.documentation.util.NumberHeadersSiteMain"
classpathref="project.classpath"
failonerror="true"
fork="true"
>
<arg value="${doc.dir}"/>
<arg value="dxp"/>
<arg value="${product.token}"/>
</java>
</target>
<target name="number-images-site" description="numbers the images in a markdown chapter file">
<numberimgssite docdir="${doc.dir}" producttype="ce">
</numberimgssite>
</target>
<target name="number-images-site-dist" description="Numbers the images of Markdown articles found in ${doc.dir}/articles and ${doc.dir}/articles-dxp.">
<numberimgssite docdir="${doc.dir}/${temp.dir}" producttype="dist">
</numberimgssite>
</target>
<target name="number-images-site-dxp" description="Numbers the images of Markdown articles found in ${doc.dir}/articles and ${doc.dir}/articles-dxp.">
<numberimgssite docdir="${doc.dir}" producttype="dxp">
</numberimgssite>
</target>
<target name="prepare" description="Creates build directory.">
<!-- Use base.filepath property to distinguish between tutorials and learning-paths directories. The build.xml file
in the learning-paths directory overwrites this value with "learning-paths/${doc.dir}" -->
<property name="base.filepath" value="${doc.dir}" />
<echo message="... creating build directory"/>
<mkdir dir="${project.dir}/${purpose.dir}/${base.filepath}/${build.dir}"/>
<touch file="${project.dir}/${purpose.dir}/${base.filepath}/${build.dir}/${article}.html" mkdirs="true"/>
<mkdir dir="${build.dir}/images"/>
<copy todir="${build.dir}/images" overwrite="true">
<fileset dir="./images"/>
</copy>
</target>
<target name="prepare-dist" depends="check-images-site-dist, check-intros-dist, clean-dist, number-headers-dist, number-images-site-dist, check-headers-dist, create-metadata-file" description="Prepares the document for distribution.">
<echo message="... creating ${dist.dir} directory"/>
<mkdir dir="${dist.dir}"/>
</target>
</project>