Skip to main content
summaryrefslogtreecommitdiffstats
blob: 9fcad8cbffde4f5ba8bd17ffcbb42e1598072d0b (plain) (blame)
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
<!-- 
  Copyright (c) 2014 BREDEX GmbH.
  All rights reserved. This program and the accompanying materials
  are made available under the terms of the Eclipse Public License v1.0
  which accompanies this distribution, and is available at
  http://www.eclipse.org/legal/epl-v10.html
-->

<project name="buildHelp" default="buildDocumentation">
    <property name="client.ua.help.path" value="../org.eclipse.jubula.client.ua.help/"/>
    <property name="html.path" value="content/html/${dir}"/>
    <property name="output" value="onlinehelp"/>
    <property name="build.path" value="${dir}/en/build/${output}"/>
    <property name="manual.name" value="${name}"/>
    <property name="buildRoot" value="${basedir}" />
    
    <macrodef name="xsltproc">
        <attribute name="chunk.section.depth"/>
        <attribute name="generate.section.toc.level"/>
        <sequential>
            <exec executable="xsltproc" failonerror="true">
                <arg value="--xinclude"/>
                <arg value="--stringparam"/>
                    <arg value="base.dir"/>
                    <arg value="${html.path}"/>
                <arg value="--stringparam"/>
                    <arg value="html.stylesheet"/>
                    <arg value="../css/style.css"/>
                <arg value="--stringparam"/>
                    <arg value="docbook.css.source"/>
                    <arg value=""/>
                <arg value="--stringparam"/>
                    <arg value="section.autolabel"/>
                    <arg value="1"/>
                <arg value="--stringparam"/>
                    <arg value="section.label.includes.component.label"/>
                    <arg value="1"/>
                <arg value="--stringparam"/>
                    <arg value="make.clean.html"/>
                    <arg value="1"/>
                <arg value="--stringparam"/>
                    <arg value="use.id.as.filename"/>
                    <arg value="0"/>
                <arg value="--stringparam"/>
                    <arg value="generate.toc"/>
                    <arg value="chapter toc
                                section toc
                                book    toc,title"/>
                <arg value="--stringparam"/>
                    <arg value="formal.title.placement"/>
                    <arg value="figure    after
                                example   after
                                equation  after
                                table     after
                                procedure after"/>
                <arg value="--stringparam"/>
                    <arg value="toc.section.depth"/>
                    <arg value="3"/>
                <arg value="--stringparam"/>
                    <arg value="generate.section.toc.level"/>
                    <arg value="@{generate.section.toc.level}"/>
                <arg value="--stringparam"/>
                    <arg value="collect.xref.targets"/>
                    <arg value="yes"/>
                <arg value="--stringparam"/>
                    <arg value="current.docid"/>
                    <arg value="${manual.name}"/>
                <arg value="--stringparam"/>
                    <arg value="target.database.document"/>
                    <arg value="../../olinkdb.xml"/>
                <arg value="--stringparam"/>
                    <arg value="chunker.output.indent"/>
                    <arg value="yes"/>
                <arg value="--stringparam"/>
                    <arg value="chunk.first.sections"/>
                    <arg value="1"/>
                <arg value="--stringparam"/>
                    <arg value="chunk.section.depth"/>
                    <arg value="@{chunk.section.depth}"/>
                <arg value="../org.eclipse.jubula.documentation.xsl/custom/jubulatemplates.xsl"/>
                <arg value="${dir}/en/docbook/book.xml"/>
                <redirector output="output.log"/>
            </exec>
        </sequential>
    </macrodef>
    
    <macrodef name="xsltprochtml">
        <attribute name="section.autolabel"/>
        <attribute name="section.label.includes.component.label"/>
        <attribute name="generate.toc.book"/>
        <attribute name="chapter.autolabel"/>
        <attribute name="toc.section.depth"/>
        <sequential>
            <exec executable="xsltproc" failonerror="true" output="output.log">
                <arg value="--xinclude"/>
                <arg value="--stringparam"/>
                    <arg value="base.dir"/>
                    <arg value="${html.path}"/>
                <arg value="--stringparam"/>
                    <arg value="html.stylesheet"/>
                    <arg value="../css/style.css"/>
                <arg value="--stringparam"/>
                    <arg value="docbook.css.source"/>
                    <arg value=""/>
                <arg value="--stringparam"/>
                    <arg value="section.autolabel"/>
                    <arg value="@{section.autolabel}"/>
                <arg value="--stringparam"/>
                    <arg value="section.label.includes.component.label"/>
                    <arg value="@{section.label.includes.component.label}"/>
                <arg value="--stringparam"/>
                    <arg value="make.clean.html"/>
                    <arg value="1"/>
                <arg value="--stringparam"/>
                    <arg value="generate.toc"/>
                    <arg value="chapter nop
                                book    @{generate.toc.book}"/>
                <arg value="--stringparam"/>
                    <arg value="chapter.autolabel"/>
                    <arg value="@{chapter.autolabel}"/>
                <arg value="--stringparam"/>
                    <arg value="formal.title.placement"/>
                    <arg value="figure    after
                                example   after
                                equation  after
                                table     after
                                procedure after"/>
                <arg value="--stringparam"/>
                    <arg value="toc.section.depth"/>
                    <arg value="@{toc.section.depth}"/>
                <arg value="--stringparam"/>
                    <arg value="current.docid"/>
                    <arg value="${manual.name}"/>
                <arg value="-o"/>
                    <arg value="${build.path}/index.html"/>
                <arg value="../org.eclipse.jubula.documentation.xsl/custom/jubulatemplates_html.xsl"/>
                <arg value="${dir}/en/docbook/book.xml"/>
            </exec>
        </sequential>
    </macrodef>
    
    <target name="buildDocumentation" depends="validateEnv,
                                               echoEnvInfo,
                                               buildInstallationManual,
                                               buildUserManual,
                                               buildReferenceManual,
                                               buildDeveloperManual,
                                               buildReleaseNotes">
    </target>

    <target name="validateDocumentation">
        <ant antfile="resources/validation/validation.xml" target="validateManuals"/>
    </target>
    
    <target name="echoEnvInfo" if="${notSuited}">
        <echo>WARNING: Can't build / generate documentation - therefore skipping this step!</echo>
    </target>
    
    <target name="buildInstallationManual" unless="${notSuited}">
        <ant antfile="buildScript.xml" target="buildHTML" inheritall="false">
            <property name="name" value="InstallationManual"/>
            <property name="dir" value="install"/>
            <property name="output" value="html"/>
        </ant>
    </target>
    
    <target name="buildUserManual" unless="${notSuited}">
        <ant antfile="buildScript.xml" target="buildOnlineHelp" inheritall="false">
            <property name="name" value="UserManual"/>
            <property name="dir" value="userManual"/>
            <property name="chunk.depth" value="2"/>
            <property name="toc.level" value="1"/>
        </ant>
    </target>
    
    <target name="buildDeveloperManual" unless="${notSuited}">
        <ant antfile="buildScript.xml" target="buildOnlineHelp" inheritall="false">
            <property name="name" value="DeveloperManual"/>
            <property name="dir" value="developerManual"/>
            <property name="chunk.depth" value="2"/>
            <property name="toc.level" value="1"/>
        </ant>
    </target>
    
    <target name="buildReleaseNotes" unless="${notSuited}">
        <ant antfile="buildScript.xml" target="buildReleaseNotesHTML" inheritall="false">
            <property name="name" value="ReleaseNotes"/>
            <property name="dir" value="releasenotes"/>
            <property name="output" value="html"/>
        </ant>
    </target>
    
    <target name="buildReferenceManual" unless="${notSuited}">
        <ant antfile="buildScript.xml" target="buildOnlineHelp" inheritall="false">
            <property name="name" value="ReferenceManual"/>
            <property name="dir" value="reference"/>
            <property name="chunk.depth" value="5"/>
            <property name="toc.level" value="3"/>
        </ant>
    </target>
    
    <target name="checkParam">
        <fail unless="name" message="Please provide a value for the parameter 'name'!"/>
        <fail unless="dir" message="Please provide a value for the parameter 'dir'!"/>
        
        <condition property="standalone">
            <equals arg1="${output}" arg2="html"/>
        </condition>
        
        <condition property="releaseNotes">
            <equals arg1="${dir}" arg2="releasenotes"/>
        </condition>
    </target>
    
    <target name="clean" depends="checkParam">
        <delete dir="${build.path}"/>
        <delete dir="${client.ua.help.path}/${html.path}"/>
        <delete dir="html"/>
    </target>
    
    <target name="makeDir" depends="clean, checkParam">
        <mkdir dir="${build.path}"/>
        <mkdir dir="${html.path}"/>
        <mkdir dir="${html.path}/images"/>
    </target>
    
    <target name="buildHtmlImageLister" depends="checkParam">
        <delete file="HtmlImageLister.jar"/>
        
        <exec executable="javac" dir="lib/HtmlImageLister" failonerror="true">
            <arg value="-cp"/>
            <arg value="lib/org.jsoup.jar"/>
            <arg value="HtmlImageLister.java"/>
        </exec>
        
        <jar destfile="HtmlImageLister.jar">
            <zipfileset src="lib/HtmlImageLister/lib/org.jsoup.jar">
                <exclude name="**/*.SF"/>
            </zipfileset>
            
            <fileset dir="lib/HtmlImageLister" excludes="**/*.java, **/.* **/lib/**"/>
            
            <manifest>
                <attribute name="Main-Class" value="HtmlImageLister"/>
                <attribute name="Class-Path" value="lib"/>
            </manifest>
        </jar>
    </target>
    
    <target name="buildOnlineHelp" unless="standalone" depends="checkParam, buildHtmlImageLister">
        <antcall target="makeDir"/>
        
        <copy todir="${html.path}/images">
            <fileset dir="${dir}/en/docbook/images">
                <include name="**/*.jpg" />
                <include name="**/*.png" />
            </fileset>
        </copy>
        
        <xsltproc chunk.section.depth="${chunk.depth}" generate.section.toc.level="${toc.level}"/>
        
        <loadfile property="output.log.msg" srcFile="output.log"/>
        <echo message="${output.log.msg}"/>
        
        <antcall target="checkForErrors"/>
        
        <delete file="${html.path}/index.xml"/>
        <delete file="plugin.xml"/>
        <delete file="target.db"/>
        <delete dir="${html.path}/en"/>
        
        <antcall target="moveGeneratedFiles"/>
        <antcall target="checkImages"/>
    </target>

    <target name="buildHTML" if="standalone" unless="releaseNotes" depends="checkParam, buildHtmlImageLister">
        <antcall target="clean"/>
        
        <copy todir="${build.path}/images">
            <fileset dir="${dir}/en/docbook/images">
                <include name="*.jpg" />
                <include name="*.png" />
            </fileset>
        </copy>
        
        <copy todir="${build.path}/css">
            <fileset dir="${dir}/en/docbook/css">
                <include name="*.css" />
            </fileset>
        </copy>
        
        <xsltprochtml chapter.autolabel="1"
                      generate.toc.book="toc,title"
                      section.autolabel="1"
                      section.label.includes.component.label="1"
                      toc.section.depth="3"/>
        
        <antcall target="checkForErrors"/>
        <antcall target="checkImages"/>
        
        <antcall target="moveGeneratedFilesStandalone"/>
    </target>
    
    <target name="buildReleaseNotesHTML" if="releaseNotes" depends="checkParam, buildHtmlImageLister">
        <copy todir="${build.path}/images">
            <fileset dir="${dir}/en/docbook/images">
                <include name="*.jpg" />
                <include name="*.png" />
            </fileset>
        </copy>
        
        <copy todir="${build.path}/css">
            <fileset dir="${dir}/en/docbook/css">
                <include name="*.css" />
            </fileset>
        </copy>
        
        <xsltprochtml chapter.autolabel="0"
                      generate.toc.book="nop"
                      section.autolabel="0"
                      section.label.includes.component.label="0"
                      toc.section.depth="0"/>
        
        <antcall target="checkForErrors"/>
        <antcall target="checkImages"/>
        
        <antcall target="moveGeneratedFilesStandalone"/>
    </target>
    
    <target name="buildReferenceManualHTML" depends="checkParam">
        <copy todir="${build.path}/images">
            <fileset dir="${dir}/en/docbook/images">
                <include name="*.jpg" />
                <include name="*.png" />
            </fileset>
        </copy>
        
        <copy todir="${build.path}/css">
            <fileset dir="${dir}/en/docbook/css">
                <include name="*.css" />
            </fileset>
        </copy>
        
        <xsltprochtml chapter.autolabel="1"
                      generate.toc.book="toc,title"
                      section.autolabel="1"
                      section.label.includes.component.label="1"
                      toc.section.depth="3"/>
        
        <antcall target="checkForErrors"/>
    </target>
    
    <target name="checkForErrors">
        <loadfile property="errorlines" srcfile="output.log">
            <filterchain>
                <linecontainsregexp>
                    <regexp pattern="(ERROR:|[Ee]rror:|WARNING:|[Ww]arning:)"/>
                </linecontainsregexp>
            </filterchain>
        </loadfile>
        
        <property name="errorlines" value=""/>
        
        <condition property="error">
            <length string="${errorlines}" when="greater" length="0"/>
        </condition>
        
        <fail if="${error}">
            ${errorlines}
        </fail>
        
        <delete file="output.log"/>
    </target>
    
    <target name="validateEnv">
        <condition property="notSuited">
           <os family="windows" />
        </condition>
    </target>
    
    <target name="checkImages">
        <java jar="HtmlImageLister.jar" outputProperty="imageListOld" failonerror="true" fork="true">
            <arg value="${basedir}/${dir}/en/build/${output}"/>
        </java>
        <loadfile property="imageList"
              srcFile="imageList.txt"/>
        <filelist id="files" dir="./${dir}/en/docbook" files="${imageList}" />
        
        <restrict id="missing.files">
            <filelist refid="files"/>
            <not>
                <exists/>
            </not>
        </restrict>
            
        <property name="missingFiles" refid="missing.files" />
            
        <condition property="filesExist" value="true">
            <length string="${missingFiles}" length="0" />
        </condition>
        
        <concat destFile="imagesMissing.log">${missingFiles}
            <filterchain>
                <linecontainsregexp>
                    <regexp pattern='.*'/>
                </linecontainsregexp>
                <tokenfilter>
                    <replaceregex pattern=":" replace="${line.separator}" flags="g"/>
                </tokenfilter>
            </filterchain>
        </concat>
            
        <loadfile property="missingFilesFormatted" srcfile="imagesMissing.log"/>
            
        <fail unless="${filesExist}">
            Missing Image Files:${line.separator}${missingFilesFormatted}
        </fail>
            
        <delete file="imageList.txt" failonerror="false"></delete>
        <delete file="imagesMissing.log"/>
    </target>
    
    <target name="moveGeneratedFiles">
        <move file="contexts.xml" tofile="context${manual.name}.xml"/>
        <move file="toc.xml" tofile="toc${manual.name}.xml"/>
        
        <move todir="${build.path}">
            <fileset file="toc${manual.name}.xml"/>
            <fileset file="context${manual.name}.xml"/>
        </move>
        
        <move todir="${build.path}/content/html" >
            <fileset dir="content/html"/>
        </move>
        
        <copy todir="${client.ua.help.path}/content">
            <fileset file="${build.path}/toc${manual.name}.xml"/>
            <fileset file="${build.path}/context${manual.name}.xml"/>
        </copy>
        
        <copy todir="${client.ua.help.path}/${html.path}">
            <fileset dir="${build.path}/${html.path}"/>
        </copy>
    </target>
    
    <target name="moveGeneratedFilesStandalone">
        <copy todir="${client.ua.help.path}/${html.path}">
            <fileset dir="${build.path}" excludes="css/"/>
        </copy>
    </target>
</project>

Back to the top