forked from liferay/liferay-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-site-common.xml
226 lines (187 loc) · 8.7 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
<?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"/>
<!-- taskdefs -->
<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-images-site" 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}"/>
</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-images-site" description="Verifies all images referenced in a single Markdown article or a document's Markdown articles.">
<checkimgssite docdir="${doc.dir}" chapter="${article}">
</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="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 that are not referenced in any of the markdown files in any subdirectory of ${doc.dir}/articles">
<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" depends="prepare-dist" description="Zips up the document's articles and images for importing.">
<property file="${project.dir}/release-site.properties" />
<zip destfile="${dist.dir}/${product.abbrev}-${product.version}-${purpose.dir}-${doc.dir}.zip">
<fileset dir="./" includes="articles/" />
<fileset dir="./" includes="images/" />
<fileset dir="./" includes="home.markdown" />
<fileset dir="./" includes="${metadata.filename}" />
</zip>
</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}"/>
</java>
</target>
<target name="number-images-site" description="numbers the images in a markdown chapter file">
<numberimgssite docdir="${doc.dir}">
</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, check-intros, clean-dist, number-headers, number-images-site, check-headers, create-metadata-file" description="Prepares the document for distribution.">
<echo message="... creating ${dist.dir} directory"/>
<mkdir dir="${dist.dir}"/>
</target>
</project>