-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.xml
521 lines (438 loc) · 19.8 KB
/
build.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
516
517
518
519
520
521
<?xml version="1.0"?>
<project name="XLT" default="all" basedir="." xmlns:xceptance="antlib:com.xceptance.ant" xmlns:resolver="antlib:org.apache.maven.resolver.ant">
<property file="build.properties" />
<property environment="env" />
<!-- compiler properties -->
<property name="build.compiler" value="modern" />
<!-- global properties -->
<property name="build.tools.dir" value="${build.dir}/tools" />
<property name="build.lib.dir" value="${build.dir}/${lib.dir}" />
<property name="build.doc.dir" value="${build.dir}/doc" />
<!-- manifest file properties -->
<property name="manifest.file" value="${classes.dir}/META-INF/MANIFEST.MF" />
<!-- backup properties -->
<property name="backup.dir" value="${basedir}/backup" />
<!-- build files -->
<property name="script.dir" value="${basedir}/ant-scripts" />
<property name="test.build.file" value="${script.dir}/test.xml" />
<property name="doc.build.file" value="${script.dir}/doc.xml" />
<property name="sigtest.build.file" value="${script.dir}/sigtest.xml" />
<property name="timerrecorder.build.file" value="${script.dir}/timerrecorder.xml" />
<property name="timerrecorder.chrome.build.file" value="${script.dir}/timerrecorder_chrome.xml" />
<property name="resultbrowser.build.file" value="${script.dir}/resultbrowser.xml" />
<property name="settings.file" value="/home/hudson/.ant/settings.xml" />
<macrodef name="prefix">
<attribute name="text" />
<attribute name="length" />
<attribute name="property" />
<sequential>
<loadresource property="@{property}">
<string value="@{text}" />
<filterchain>
<tokenfilter>
<replaceregex pattern="^(.{@{length}}).*" replace="\1" />
</tokenfilter>
</filterchain>
</loadresource>
</sequential>
</macrodef>
<target name="init.mvn" unless="init.mvn.run">
<path id="maven-resolver-ant-tasks.classpath" path="${lib-build.dir}/maven-resolver-ant-tasks-1.4.0-uber.jar" />
<typedef resource="org/apache/maven/resolver/ant/antlib.xml" uri="antlib:org.apache.maven.resolver.ant" classpathref="maven-resolver-ant-tasks.classpath" />
<dependset>
<srcfilelist dir="${basedir}">
<file name="pom.xml" />
</srcfilelist>
<targetfileset dir="${build.dir}">
<include name="build-dependencies.xml" />
<include name="lib/**/*.jar" />
</targetfileset>
</dependset>
<resolver:pom id="xlt.pom" file="pom.xml" />
<property name="version" value="${xlt.pom.version}" />
<property name="bin.dist.name" value="${project.name}-${version}" />
<property name="jar.name" value="${project.name}-${version}.jar" />
<property name="sourcejar.name" value="${project.name}-${version}-sources.jar" />
<!-- Determine version number -->
<loadresource property="version.number">
<propertyresource name="version" />
<filterchain>
<tokenfilter>
<replaceregex pattern="^(\d+([.]\d+)*).*" replace="\1" flags="gi" />
</tokenfilter>
</filterchain>
</loadresource>
<!-- Name for the generated API documentation file without the file extension -->
<property name="api.doc.file.name" value="${project.name}-${version}-javadoc" />
<!-- redefine default Maven repo to be used with https -->
<resolver:remoterepos id="resolver.repositories">
<resolver:remoterepo url="https://repo1.maven.org/maven2/" />
</resolver:remoterepos>
<resolver:dependencies id="depsFromPom" pomRef="xlt.pom" />
<resolver:resolve dependenciesref="depsFromPom" remotereposref="resolver.repositories">
<files refid="deps.fileset" scopes="compile,runtime" />
<files refid="provided.fileset" scopes="provided" />
</resolver:resolve>
<condition property="need.copy.deps">
<or>
<not>
<resourceexists>
<file file="${lib.dir}" />
</resourceexists>
</not>
<resourcecount when="equal" count="0">
<fileset dir="${lib.dir}" includes="**/*.jar" />
</resourcecount>
</or>
</condition>
<property name="init.mvn.run" value="true" />
</target>
<target name="init" unless="init.run" depends="init.mvn">
<!-- the global classpath -->
<path id="classpath">
<pathelement path="${classes.dir}" />
<resources refid="deps.fileset" />
<resources refid="provided.fileset" />
<fileset dir="${lib-build.dir}">
<include name="*.jar" />
</fileset>
</path>
<property name="init.run" value="true" />
</target>
<!-- Removes any file generated during build or runtime. This includes backup files as well! -->
<target name="clean" description="Cleans the build.">
<!-- delete build-time files -->
<delete dir="${backup.dir}" />
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
<delete dir="${release.dir}" />
<delete dir="${lib.dir}" />
<ant antfile="${test.build.file}" target="test.clean" inheritall="false" inheritrefs="false">
<propertyset>
<propertyref name="build.doc.dir" />
</propertyset>
</ant>
<!-- delete run-time files -->
<delete includeemptydirs="true" quiet="true">
<fileset dir="${basedir}">
<include name="agent/**/*" />
<include name="log/**/*" />
<include name="reports/**/*" />
<include name="results/**/*" />
<include name="agent*.zip" />
<include name="samples/app-server/logs/**/*" />
</fileset>
</delete>
<delete dir="samples/app-server/data" />
<delete file="samples/app-server/webapps/posters.war" quiet="true" />
<ant target="clean" inheritall="false" inheritrefs="false" dir="samples/testsuite-posters" />
<ant target="clean" inheritall="false" inheritrefs="false" dir="samples/testsuite-showcases" />
</target>
<target name="copy-deps" if="need.copy.deps" unless="deps.copied" depends="init">
<mkdir dir="${lib.dir}" />
<copy todir="${lib.dir}">
<resources refid="deps.fileset" />
<mapper type="flatten" />
</copy>
<property name="deps.copied" value="true" />
</target>
<!--
Compiles the Java sources in ${src.dir} to ${classes.dir}. Any non-Java file in the sources
dir will be copied there, too.
-->
<target name="compile" description="Generates class files." depends="copy-deps">
<mkdir dir="${classes.dir}" />
<javac srcdir="${src.dir}/main/java" destdir="${classes.dir}" debug="on" optimize="off" deprecation="on" encoding="utf8" source="11" target="11">
<classpath refid="classpath" />
<!-- Shorten the default list of modules to avoid issues (for example, jdk.jsobject clashes with HtmlUnit). -->
<compilerarg value="--limit-modules" />
<compilerarg value="java.se,jdk.httpserver,jdk.management,jdk.xml.dom,jdk.unsupported" />
</javac>
<copy todir="${classes.dir}">
<fileset dir="${src.dir}/main/resources">
<include name="**/*" />
</fileset>
<fileset dir="${src.dir}/main/java">
<include name="**/*" />
<exclude name="**/*.java" />
</fileset>
</copy>
<antcall target="build.timerrecorder.xpi" inheritrefs="true" />
<antcall target="build.timerrecorder.crx" inheritrefs="true" />
<antcall target="build.resultbrowser" inheritrefs="true" />
</target>
<!-- Checks for existence of the XLT jar and determine if it is up-to-date. -->
<target name="check.jar">
<!-- Determine if dependencies of jar are up-to-date. -->
<dependset>
<srcfileset dir="${classes.dir}" includes="**/*" />
<targetfilelist dir="${build.dir}" files="${jar.name}" />
</dependset>
<!-- Set property, if jar is present -->
<condition property="jar.present">
<available file="${build.dir}/${jar.name}" type="file" />
</condition>
</target>
<!-- Builds a JAR file from the compiled classes. -->
<target name="jar" depends="compile, check.jar" description="Generates .jar file." unless="jar.present">
<tstamp />
<condition property="revision" value="${env.GIT_COMMIT}" else="????">
<isset property="env.GIT_COMMIT" />
</condition>
<prefix text="${revision}" length="10" property="rev.head" />
<manifest file="${manifest.file}" mode="update">
<attribute name="Implementation-Version" value="${version}" />
<attribute name="X-Implementation-Date" value="${DSTAMP}" />
<attribute name="X-Implementation-Revision" value="${rev.head}" />
</manifest>
<jar jarfile="${build.dir}/${jar.name}" manifest="${manifest.file}">
<zipfileset dir="${classes.dir}" />
<zipfileset file="LICENSE" prefix="META-INF" />
</jar>
</target>
<!-- Builds a JAR file from the sources. -->
<target name="sourcejar" depends="init" description="Generates .jar file from the sources.">
<jar jarfile="${build.dir}/${sourcejar.name}">
<zipfileset dir="${src.dir}/main/java" />
<zipfileset dir="${src.dir}/main/resources" />
</jar>
</target>
<!-- Documentation -->
<target name="apidoc">
<antcall target="doc" inheritrefs="true">
<param name="group" value="api" />
</antcall>
</target>
<target name="javadoc" depends="compile">
<antcall target="doc" inheritrefs="true">
<param name="group" value="java" />
</antcall>
</target>
<target name="check.dist.bin">
<!-- Check if dependencies of apidocs are up-to-date. -->
<dependset>
<srcfileset dir="${build.doc.dir}" includes="apidoc/**" />
<targetfilelist dir="${build.doc.dir}" files="${api.doc.file.name}.zip" />
</dependset>
<!-- Finally, check if dependencies of distribution zip are up-to-date. -->
<dependset>
<srcfilelist dir="${build.doc.dir}">
<file name="${api.doc.file.name}.zip" />
</srcfilelist>
<srcfileset dir="${basedir}">
<include name="bin/**" />
<include name="config/**" />
<include name="doc/3rd-party-licenses/**" />
<include name="etc/**" />
<include name="LICENSE" />
<include name="NOTICE.md" />
</srcfileset>
<srcfileset dir="${lib.dir}" includes="**/*.jar" />
<srcfileset dir="${build.dir}" includes="downloads/**/*" />
<targetfilelist dir="${dist.dir}">
<file name="${bin.dist.name}.zip" />
</targetfilelist>
</dependset>
<!-- Check for existence of distribution zip, which is up-to-date if present. -->
<condition property="dist.bin.present">
<available file="${dist.dir}/${bin.dist.name}.zip" type="file" />
</condition>
</target>
<target name="check.downloads">
<copy todir="target/downloads" flatten="true">
<resources>
<url url="${poster-store.url}" />
<url url="${jenkins-plugin.url}" />
</resources>
</copy>
</target>
<!-- Builds the binary distribution archive. -->
<target name="dist.bin" depends="jar, apidoc, check.dist.bin, check.downloads" unless="dist.bin.present">
<mkdir dir="${dist.dir}" />
<!-- Create some empty directories now as GIT is not able to manage them. -->
<mkdir dir="agent" />
<mkdir dir="log" />
<mkdir dir="reports" />
<mkdir dir="results" />
<mkdir dir="samples/app-server/config/contexts" />
<mkdir dir="samples/app-server/logs" />
<copy todir="${build.lib.dir}">
<fileset dir="${lib.dir}" includes="*.jar" />
<fileset file="${build.dir}/${jar.name}" />
</copy>
<zip zipfile="${build.doc.dir}/${api.doc.file.name}.zip">
<zipfileset dir="${build.doc.dir}">
<include name="apidoc/**" />
</zipfileset>
</zip>
<jar destfile="${build.doc.dir}/${api.doc.file.name}.jar" basedir="${build.doc.dir}/apidoc/" />
<zip zipfile="${dist.dir}/${bin.dist.name}.zip">
<zipfileset dir="${basedir}" prefix="${bin.dist.name}">
<include name="bin/**" />
<exclude name="bin/**/*.sh" />
</zipfileset>
<zipfileset dir="${basedir}" prefix="${bin.dist.name}" filemode="754">
<include name="bin/**/*.sh" />
</zipfileset>
<zipfileset dir="${basedir}" prefix="${bin.dist.name}">
<include name="agent" />
<include name="config/**" />
<include name="doc/3rd-party-licenses/**" />
<include name="etc/**" />
<include name="log" />
<include name="reports" />
<include name="results" />
<include name="LICENSE" />
<include name="NOTICE.md" />
</zipfileset>
<zipfileset dir="${build.dir}" prefix="${bin.dist.name}">
<include name="lib/**" />
</zipfileset>
<zipfileset dir="target/downloads" includes="xlt-jenkins-plugin-*.hpi" fullpath="${bin.dist.name}/tools/xlt-jenkins-plugin-${jenkins-plugin.version}/xlt-jenkins-plugin.hpi" />
</zip>
<checksum file="${dist.dir}/${bin.dist.name}.zip" algorithm="SHA-256" fileext=".sha256" />
</target>
<!-- Builds both the source and the binary distribution archives. -->
<target name="dist" depends="dist.bin">
<!-- just be dependent -->
</target>
<!-- Runs the whole build process. -->
<target name="all" depends="clean, dist" description="Cleans the build and generates the distribution afterwards.">
<!-- just be dependent -->
</target>
<!--
Creates a backup of the current state of development to ${backup.dir}. The backup is stored
to a ZIP file which contains the current date and time in the file name.
-->
<target name="backup" description="Creates a backup of the working copy.">
<mkdir dir="${backup.dir}" />
<tstamp />
<property name="backup.name" value="${project.name}-${DSTAMP}-${TSTAMP}-${version}" />
<zip zipfile="${backup.dir}/${backup.name}.zip">
<zipfileset dir="${basedir}" prefix="${backup.name}">
<include name="**/*" />
<exclude name="results/**" />
<exclude name="reports/**" />
<exclude name="agent/**" />
<exclude name="build" />
<exclude name="classes" />
<exclude name="backup" />
<exclude name="**/.git" />
</zipfileset>
</zip>
</target>
<!-- Builds a new release. -->
<target name="release" description="Builds a new release.">
<property name="build.release" value="true" />
<antcall target="release.task" inheritrefs="true" />
</target>
<target name="release.task" depends="clean, sourcejar, dist, sigtest, fulltest">
<mkdir dir="${release.dir}" />
<copy todir="${release.dir}">
<fileset dir="${basedir}" includes="pom.xml" />
<fileset dir="${dist.dir}" includes="*.zip *.sha256" />
<fileset dir="${build.tools.dir}" includes="*.xpi update.rdf" />
<fileset dir="${build.doc.dir}" includes="${api.doc.file.name}.???" />
<fileset file="${build.dir}/${jar.name}" />
<fileset file="${build.dir}/${sourcejar.name}" />
</copy>
</target>
<!--
==================================
= The section for all the tests. =
==================================
-->
<target name="fulltest">
<antcall target="test" inheritrefs="true">
<param name="action" value="full" />
</antcall>
</target>
<target name="analytics">
<antcall target="test" inheritrefs="true">
<param name="action" value="analytics" />
</antcall>
</target>
<target name="hu-tests">
<antcall target="test">
<param name="action" value="execute-hu" />
</antcall>
</target>
<!--
=====================================
= API signature check and creation. =
=====================================
-->
<target name="sigsetup">
<antcall target="sig" inheritrefs="true">
<param name="sigaction" value="setup" />
</antcall>
</target>
<target name="sigtest">
<antcall target="sig" inheritrefs="true">
<param name="sigaction" value="apicheck" />
</antcall>
</target>
<!--
==================
= Generic tasks. =
==================
-->
<target name="doc" depends="init">
<ant antfile="${doc.build.file}" target="doc.${group}doc" inheritall="false" inheritrefs="false">
<reference refid="classpath" />
<propertyset>
<propertyref name="build.doc.dir" />
<propertyref name="bin.dist.name" />
<propertyref name="version" />
</propertyset>
</ant>
</target>
<target name="test" depends="compile">
<ant antfile="${test.build.file}" target="test.${action}" inheritall="false" inheritrefs="false">
<reference refid="classpath" />
<reference refid="maven-resolver-ant-tasks.classpath" />
<propertyset>
<propertyref name="build.doc.dir" />
</propertyset>
</ant>
</target>
<target name="sig" depends="compile">
<ant antfile="${sigtest.build.file}" target="sigtest.${sigaction}" inheritall="false" inheritrefs="false">
<propertyset>
<propertyref name="build.doc.dir" />
<propertyref name="build.lib.dir" />
<propertyref name="version" />
</propertyset>
</ant>
</target>
<!--
==================================
= Timer-recorder extension. =
==================================
-->
<target name="build.timerrecorder.xpi" depends="init">
<ant antfile="${timerrecorder.build.file}" target="timerrecorder.build" inheritall="false" inheritrefs="false">
<propertyset>
<propertyref name="version" />
<propertyref name="version.number" />
</propertyset>
</ant>
</target>
<target name="build.timerrecorder.crx" depends="init">
<ant antfile="${timerrecorder.chrome.build.file}" target="timerrecorder.build" inheritall="false" inheritrefs="false">
<propertyset>
<propertyref name="build.release" />
<propertyref name="version" />
<propertyref name="version.number" />
</propertyset>
</ant>
</target>
<!--
==================================
= Resultbrowser bundling. =
==================================
-->
<target name="build.resultbrowser" depends="init">
<ant antfile="${resultbrowser.build.file}" target="resultbrowser.build" inheritall="false" inheritrefs="false" />
</target>
</project>