forked from rabbitmq/rabbitmq-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
511 lines (456 loc) · 17.9 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
<?xml version="1.0"?>
<project name="RabbitMQ Java client" default="build"
xmlns:bundlor="antlib:com.springsource.bundlor.ant">
<property file="build.properties"/>
<property file="config.properties"/>
<path id="javac.classpath">
<!-- cf dist target, infra -->
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</path>
<condition property="codegen.dir" value="${sibling.codegen.dir}" else="codegen">
<available file="${sibling.codegen.dir}" type="dir"/>
</condition>
<path id="test.javac.classpath">
<path refid="javac.classpath"/>
<!-- <pathelement path="${junit.home}/junit.jar"/> -->
</path>
<path id="test.classpath">
<path refid="test.javac.classpath"/>
<pathelement path="${javac.out}"/>
<pathelement path="${test.javac.out}"/>
</path>
<property name="AMQP_SPEC_JSON_PATH" value="${codegen.dir}/amqp-rabbitmq-${spec.version}.json"/>
<target name="amqp-generate-check" description="check if codegen needs to be run">
<uptodate property="amqp.generate.notRequired">
<srcfiles file="codegen.py"/>
<srcfiles dir="${codegen.dir}">
<include name="*" />
</srcfiles>
<compositemapper>
<mapper type="merge" to="${basedir}/${src.generated}/com/rabbitmq/client/impl/AMQImpl.java" />
<mapper type="merge" to="${basedir}/${src.generated}/com/rabbitmq/client/AMQP.java" />
</compositemapper>
</uptodate>
</target>
<target name="amqp-generate" depends="amqp-generate-check"
unless="amqp.generate.notRequired" description="generate AMQP.java and AMQImpl.java from AMQP spec">
<mkdir dir="${src.generated}/com/rabbitmq/client/"/>
<exec dir="." executable="${python.bin}"
errorproperty="amqp.generate.error1"
resultproperty="amqp.generate.result1">
<arg line="codegen.py"/>
<arg line="header"/>
<arg line="${AMQP_SPEC_JSON_PATH}"/>
<arg line="${src.generated}/com/rabbitmq/client/AMQP.java"/>
</exec>
<fail message="Generation of AMQP.java failed with message:${line.separator}${amqp.generate.error1}">
<condition>
<not>
<equals arg1="${amqp.generate.result1}" arg2="0" />
</not>
</condition>
</fail>
<mkdir dir="${src.generated}/com/rabbitmq/client/impl"/>
<exec dir="." executable="${python.bin}"
errorproperty="amqp.generate.error2"
resultproperty="amqp.generate.result2">
<arg line="codegen.py"/>
<arg line="body"/>
<arg line="${AMQP_SPEC_JSON_PATH}"/>
<arg line="${src.generated}/com/rabbitmq/client/impl/AMQImpl.java"/>
</exec>
<fail message="Generation of AMQPImpl.java failed with message:${line.separator}${amqp.generate.error2}">
<condition>
<not>
<equals arg1="${amqp.generate.result2}" arg2="0" />
</not>
</condition>
</fail>
</target>
<target name="build" depends="amqp-generate" description="Build the client library.">
<mkdir dir="${javac.out}"/>
<copy file="src/com/rabbitmq/client/impl/ClientVersion.java.in"
tofile="${src.generated}/com/rabbitmq/client/impl/ClientVersion.java">
<filterset>
<filter token="VERSION" value="${impl.version}"/>
</filterset>
</copy>
<javac destdir="${javac.out}"
classpathref="javac.classpath"
source="${standard.javac.source}"
target="${standard.javac.target}"
debug="${javac.debug}">
<src path="src"/>
<src path="${src.generated}"/>
<compilerarg value="-Xlint:deprecation" />
<compilerarg value="-Xlint:unchecked" />
</javac>
<mkdir dir="build/doc/api"/>
</target>
<target name="javadoc" depends="build">
<javadoc destdir="build/doc/api" classpathref="javac.classpath">
<fileset dir="src">
<include name="**/*.java"/>
</fileset>
<fileset dir="build/gensrc">
<include name="**/*.java"/>
</fileset>
</javadoc>
</target>
<target name="detect-ssl">
<property environment="env"/>
<property name="SSL_CERTS_DIR" value="${env.SSL_CERTS_DIR}"/>
<available property="SSL_AVAILABLE" file="${SSL_CERTS_DIR}/client"/>
<property name="CLIENT_KEYSTORE_PHRASE" value="bunnies"/>
<property environment="env"/>
<property name="SSL_P12_PASSWORD" value="${env.PASSWORD}"/>
</target>
<target name="detect-umbrella">
<available property="UMBRELLA_AVAILABLE" file="../rabbitmq-test"/>
</target>
<target name="detect-tmpdir">
<property environment="env"/>
<condition property="TMPDIR" value="${env.TMPDIR}" else="/tmp">
<available file="${env.TMPDIR}" type="dir"/>
</condition>
</target>
<target name="make-client-keystore" if="SSL_AVAILABLE" depends="detect-ssl, detect-tmpdir">
<exec executable="mktemp" outputproperty="CLIENT_KEYSTORE" failonerror="true" osfamily="unix">
<arg value="-u"/>
<arg value="${TMPDIR}/tmp.XXXXXXXXXX"/>
</exec>
<exec executable="keytool" failonerror="true" osfamily="unix">
<arg line="-import"/>
<arg value="-alias"/>
<arg value="server1"/>
<arg value="-file"/>
<arg value="${SSL_CERTS_DIR}/testca/cacert.pem"/>
<arg value="-keystore"/>
<arg value="${CLIENT_KEYSTORE}"/>
<arg value="-noprompt"/>
<arg value="-storepass"/>
<arg value="${CLIENT_KEYSTORE_PHRASE}"/>
</exec>
<exec executable="mktemp" outputproperty="CLIENT_KEYSTORE_EMPTY" failonerror="true" osfamily="unix">
<arg value="-u"/>
<arg value="${TMPDIR}/tmp.XXXXXXXXXX"/>
</exec>
<!-- can't create an empty keystore, so add cert in and then delete it! -->
<exec executable="keytool" failonerror="true" osfamily="unix">
<arg line="-import"/>
<arg value="-alias"/>
<arg value="server1"/>
<arg value="-file"/>
<arg value="${SSL_CERTS_DIR}/testca/cacert.pem"/>
<arg value="-keystore"/>
<arg value="${CLIENT_KEYSTORE_EMPTY}"/>
<arg value="-noprompt"/>
<arg value="-storepass"/>
<arg value="${CLIENT_KEYSTORE_PHRASE}"/>
</exec>
<exec executable="keytool" failonerror="true" osfamily="unix">
<arg line="-delete"/>
<arg value="-alias"/>
<arg value="server1"/>
<arg value="-keystore"/>
<arg value="${CLIENT_KEYSTORE_EMPTY}"/>
<arg value="-storepass"/>
<arg value="${CLIENT_KEYSTORE_PHRASE}"/>
</exec>
</target>
<target name="remove-client-keystore" if="SSL_AVAILABLE">
<delete file="${CLIENT_KEYSTORE}" failonerror="false"/>
<delete file="${CLIENT_KEYSTORE_EMPTY}" failonerror="false"/>
</target>
<target name="test-prepare">
<property name="haltOnFailureJunit" value="yes" />
<property name="haltOnFailureJava" value="true" />
</target>
<target name="test-build" depends="test-prepare">
<antcall target="test-build-param">
<param name="javac.source" value="${standard.javac.source}"/>
<param name="javac.target" value="${standard.javac.target}"/>
</antcall>
</target>
<target name="test-build-alt" depends="test-prepare">
<antcall target="test-build-param">
<param name="javac.source" value="${alt.javac.source}"/>
<param name="javac.target" value="${alt.javac.target}"/>
</antcall>
</target>
<!-- Used to rebuild the tests every time, ( dependency on clean-tests )
because of the alternate build required for conformance testing: now don't -->
<target name="test-build-param" depends="build">
<mkdir dir="${test.javac.out}"/>
<javac
srcdir="${test.src.home}"
destdir="${test.javac.out}"
debug="true"
source="${javac.source}"
target="${javac.target}">
<compilerarg value="-Xlint:deprecation" />
<compilerarg value="-Xlint:unchecked" />
<classpath>
<path refid="test.javac.classpath"/>
<pathelement path="${javac.out}"/>
</classpath>
</javac>
<copy todir="${test.javac.out}">
<fileset dir="${test.src.home}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="test-main" depends="test-build">
<java fork="true" classname="${test.main}"
failonerror="${haltOnFailureJava}" errorproperty="test.failure">
<jvmarg value="-Xdebug"/>
<arg value="amqp://${broker.hostname}:${broker.port}"/>
<classpath>
<path refid="test.javac.classpath"/>
<pathelement path="${javac.out}"/>
<pathelement path="${test.javac.out}"/>
</classpath>
</java>
</target>
<target name="test-main-silent" depends="test-build">
<java fork="true" classname="${test.main}"
failonerror="${haltOnFailureJava}" errorproperty="test.failure">
<jvmarg value="-Xdebug"/>
<jvmarg value="-Dsilent=true"/>
<arg value="amqp://${broker.hostname}:${broker.port}"/>
<classpath>
<path refid="test.javac.classpath"/>
<pathelement path="${javac.out}"/>
<pathelement path="${test.javac.out}"/>
</classpath>
</java>
</target>
<target name="test-main-silent-alt" depends="test-build-alt">
<java fork="true" classname="${test.main}"
failonerror="${haltOnFailureJava}" errorproperty="test.failure">
<jvmarg value="-Xdebug"/>
<jvmarg value="-Dsilent=true"/>
<arg value="amqp://${broker.hostname}:${broker.port}"/>
<classpath>
<path refid="test.javac.classpath"/>
<pathelement path="${javac.out}"/>
<pathelement path="${test.javac.out}"/>
</classpath>
</java>
</target>
<target name="producer" depends="test-build">
<java fork="true" classname="com.rabbitmq.examples.ProducerMain">
<jvmarg value="-Xdebug"/>
<arg value="amqp://${broker.hostname}:${broker.port}"/>
<arg value="${test.producer.rate-limit}"/>
<arg value="${test.producer.message-count}"/>
<arg value="${test.producer.send-completion}"/>
<arg value="${test.producer.commit-every}"/>
<arg value="true"/>
<classpath>
<path refid="test.javac.classpath"/>
<pathelement path="${javac.out}"/>
<pathelement path="${test.javac.out}"/>
</classpath>
</java>
</target>
<target name="consumer" depends="test-build">
<java fork="true" classname="com.rabbitmq.examples.ConsumerMain">
<jvmarg value="-Xdebug"/>
<arg value="amqp://${broker.hostname}:${broker.port}"/>
<classpath>
<path refid="test.javac.classpath"/>
<pathelement path="${javac.out}"/>
<pathelement path="${test.javac.out}"/>
</classpath>
</java>
</target>
<target name="test-suite-prepare">
<property name="haltOnFailureJunit" value="no" />
<property name="haltOnFailureJava" value="false" />
</target>
<target name="test-suite" depends="test-suite-prepare, test-suite-run" description="Run all test suites.">
<fail message="Errors occured in tests">
<condition>
<not>
<equals arg1="${test.failure}" arg2="" />
</not>
</condition>
</fail>
</target>
<target name="test-suite-run" depends="test-client, test-ssl, test-server, test-functional, test-functional-and-server-with-ha, test-main-silent"/>
<target name="test-client" depends="test-build" description="Run the client test suites.">
<junit printSummary="withOutAndErr"
haltOnFailure="${haltOnFailureJunit}"
failureproperty="test.failure"
fork="yes">
<classpath refid="test.classpath"/>
<formatter type="plain"/>
<formatter type="xml"/>
<test todir="${build.out}" name="com.rabbitmq.client.test.ClientTests"/>
</junit>
</target>
<target name="test-ssl" depends="test-build, make-client-keystore" if="SSL_AVAILABLE">
<junit printSummary="withOutAndErr"
haltOnFailure="${haltOnFailureJunit}"
failureproperty="test.failure"
fork="yes">
<classpath refid="test.classpath"/>
<jvmarg value="-Dkeystore.path=${CLIENT_KEYSTORE}"/>
<jvmarg value="-Dkeystore.empty.path=${CLIENT_KEYSTORE_EMPTY}"/>
<jvmarg value="-Dkeystore.passwd=${CLIENT_KEYSTORE_PHRASE}"/>
<jvmarg value="-Dp12.path=${SSL_CERTS_DIR}/client/keycert.p12"/>
<jvmarg value="-Dp12.passwd=${SSL_P12_PASSWORD}"/>
<formatter type="plain"/>
<formatter type="xml"/>
<test todir="${build.out}" name="com.rabbitmq.client.test.ssl.SSLTests"/>
</junit>
<antcall target="remove-client-keystore"/>
</target>
<target name="test-functional" depends="test-build" description="Run the functional test suite.">
<junit printSummary="withOutAndErr"
haltOnFailure="${haltOnFailureJunit}"
failureproperty="test.failure"
fork="yes">
<classpath refid="test.classpath"/>
<formatter type="plain"/>
<formatter type="xml"/>
<test todir="${build.out}" name="com.rabbitmq.client.test.functional.FunctionalTests"/>
</junit>
</target>
<target name="test-server" depends="detect-umbrella, test-build" if="UMBRELLA_AVAILABLE">
<junit printSummary="withOutAndErr"
haltOnFailure="${haltOnFailureJunit}"
failureproperty="test.failure"
fork="yes">
<classpath refid="test.classpath"/>
<formatter type="plain"/>
<formatter type="xml"/>
<test todir="${build.out}"
name="com.rabbitmq.client.test.server.ServerTests"/>
</junit>
</target>
<!-- TODO: merge test-server, test-functional and this into one, once umbrellas have been merged -->
<target name="test-functional-and-server-with-ha" depends="detect-umbrella, test-build" if="UMBRELLA_AVAILABLE">
<junit printSummary="withOutAndErr"
haltOnFailure="${haltOnFailureJunit}"
failureproperty="test.failure"
fork="yes">
<classpath refid="test.classpath"/>
<formatter type="plain"/>
<formatter type="xml"/>
<test todir="${build.out}" name="com.rabbitmq.client.test.server.HATests"/>
</junit>
</target>
<target name="test-single" depends="test-build">
<junit printSummary="withOutAndErr"
haltOnFailure="${haltOnFailureJunit}"
failureproperty="test.failure"
fork="yes">
<classpath refid="test.classpath"/>
<formatter type="plain"/>
<formatter type="xml"/>
<test todir="${build.out}" name="${test}"/>
</junit>
</target>
<target name="jar" depends="build, bundlor.do">
<mkdir dir="${lib.out}"/>
<antcall target="doJarWithTags">
<param name="jar.name" value="rabbitmq-client"/>
<param name="base" value="${javac.out}"/>
</antcall>
</target>
<target name="maven-bundle" depends="jar,javadoc" description="This creates a bundle to upload to the central maven repo">
<mkdir dir="${bundle.out}"/>
<copy file="${lib.out}/rabbitmq-client.jar"
tofile="${bundle.out}/amqp-client-${impl.version}.jar"/>
<jar destfile="${bundle.out}/amqp-client-${impl.version}-sources.jar">
<fileset dir="src"/>
<fileset dir="${src.generated}"/>
</jar>
<jar destfile="${bundle.out}/amqp-client-${impl.version}-javadoc.jar">
<fileset dir="${javadoc.out}"/>
</jar>
<copy file="pom.xml" tofile="${bundle.out}/amqp-client-${impl.version}.pom"/>
<replace file="${bundle.out}/amqp-client-${impl.version}.pom"
token="VERSION" value="${impl.version}"/>
</target>
<target name="test-jar" depends="test-build, test-bundlor.do">
<mkdir dir="${lib.out}"/>
<antcall target="doJarWithTags">
<param name="jar.name" value="rabbitmq-client-tests"/>
<param name="base" value="${test.javac.out}"/>
</antcall>
</target>
<target name="doJarWithTags">
<jar destfile="${lib.out}/${jar.name}.jar"
basedir="${base}"
filesetmanifest="merge">
<manifest>
<section name="${jar.name}">
<attribute name="Specification-Title" value="AMQP"/>
<attribute name="Specification-Version" value="${spec.version}"/>
<attribute name="Specification-Vendor" value="AMQP Working Group (www.amqp.org)"/>
<attribute name="Implementation-Title" value="RabbitMQ"/>
<attribute name="Implementation-Version" value="${impl.version}"/>
<attribute name="Implementation-Vendor" value="Rabbit Technologies Ltd. (www.rabbitmq.com)"/>
</section>
</manifest>
</jar>
</target>
<target name="dist" depends="jar, test-jar" description="Build all library JARs and documentation">
<mkdir dir="${dist.out}"/>
<copy todir="${dist.out}">
<!-- ant doesn't seem to provide any form of usable abstraction over sets of file names -->
<!-- consequently we repeat ourselves here. see definition of javac.classpath, supra -->
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib.out}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="scripts">
<include name="**/*.sh"/>
<include name="**/*.bat"/>
</fileset>
</copy>
</target>
<target name="clean" description="Cleans build artifacts">
<delete dir="build"/>
</target>
<target name="clean-tests">
<delete dir="build/test"/>
</target>
<target name="bundlor.init">
<taskdef resource="com/springsource/bundlor/ant/antlib.xml"
uri="antlib:com.springsource.bundlor.ant">
<classpath id="bundlor.classpath">
<fileset dir="${bundlor.home}/dist"/>
<fileset dir="${bundlor.home}/lib"/>
</classpath>
</taskdef>
</target>
<target name="bundlor.do" depends="bundlor.init">
<bundlor:bundlor
inputPath="${javac.out}"
outputPath="${javac.out}"
manifestTemplatePath="bundlorTemplate.mf">
<propertyset>
<propertyref builtin="all"/>
</propertyset>
</bundlor:bundlor>
</target>
<target name="test-bundlor.do" depends="bundlor.init">
<bundlor:bundlor
inputPath="${test.javac.out}"
outputPath="${test.javac.out}"
manifestTemplatePath="bundlorTestTemplate.mf">
<propertyset>
<propertyref builtin="all"/>
</propertyset>
</bundlor:bundlor>
</target>
</project>