forked from jgroups-extras/jgroups-raft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
440 lines (370 loc) · 18 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
<?xml version="1.0"?>
<project name="jgroups-raft" default="compile" basedir="."
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:staging="antlib:org.sonatype.nexus.ant.staging">
<description>
Ant/ivy based build.xml file for jgroups-raft. Needs ant to run
</description>
<property name="version" value="0.5-SNAPSHOT"/>
<property name="build.properties.file" value="build.properties"/>
<property file="${build.properties.file}"/>
<property name="root.dir" value="${basedir}"/>
<property name="src.dir" value="${root.dir}/src"/>
<property name="compile.dir" value="${root.dir}/classes"/>
<property name="tests.dir" value="${root.dir}/tests"/>
<property name="junit-functional.dir" value="${tests.dir}/junit-functional"/>
<property name="lib.dir" value="${root.dir}/lib"/>
<property name="dist.dir" value="${root.dir}/dist"/>
<property name="tmp.dir" value="${root.dir}/tmp"/>
<property name="doc.dir" value="${root.dir}/doc"/>
<property name="manual.dir" value="${doc.dir}/manual"/>
<property name="protocols.adoc" value="${manual.dir}/protocols.adoc"/>
<property name="javadoc.dir" value="${dist.dir}/javadoc"/>
<property name="conf.dir" value="${root.dir}/conf"/>
<property name="bin.dir" value="${root.dir}/bin"/>
<property name="javadoc.packages" value="org.jgroups.*"/>
<property name="timestamp" value=".timestamp"/>
<property name="maven.executable" value="mvn"/>
<property name="ivy.version" value="2.4.0" />
<property name="ivy.props" value="ivy.properties"/>
<property name="asciidoc.executable" value="asciidoctor"/>
<!-- 5 minutes per test suite timeout -->
<property name="unittest.timeout" value="1800000"/>
<property name="test.verbose" value="0"/>
<!-- Parallelization controls (disable with "-Dparallel.classes=false") -->
<property name="parallel.classes" value="classes"/>
<path id="jg.classpath">
<pathelement location="${compile.dir}"/>
<pathelement location="${conf.dir}"/>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<target name="define-testng-task">
<taskdef resource="testngtasks" classpathref="jg.classpath"/>
</target>
<target name="check-lib-exists">
<available file="${lib.dir}" type="dir" property="lib.dir.exists"/>
</target>
<target name="check-ivy-exists">
<mkdir dir="${lib.dir}"/>
<pathconvert property="ivy.exists" pathsep=" " setonempty="false">
<path>
<fileset dir="${lib.dir}" includes="ivy*.jar" />
</path>
</pathconvert>
</target>
<target name="check-jars-exist">
<mkdir dir="${lib.dir}"/>
<pathconvert property="jars.exist" pathsep=" " setonempty="false">
<path>
<fileset dir="${lib.dir}" excludes="ivy*.jar" />
</path>
</pathconvert>
</target>
<target name="get-ivy" description="Fetches ivy from a maven repo" depends="check-ivy-exists" unless="ivy.exists">
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"
dest="${lib.dir}" usetimestamp="true"/>
</target>
<target name="retrieve" depends="check-jars-exist,get-ivy,define-ivy-task" unless="jars.exist"
description="Retrieves all dependent libs defined in ivy.xml unless already present">
<ivy:retrieve type="jar,bundle,source" transitive="false"/>
</target>
<!-- =================================
target: publish
================================= -->
<target name="publish" depends="define-ivy-task"
description="Publishes this project to the local ivy repo (artifacts need to be in ./dist)">
<property name="revision" value="${version}"/>
<!--<ivy:deliver
deliverpattern="${dist.dir}/ivy.xml"
pubrevision="${version}"
status="release"
organisation="org.jgroups"
module="jgroups-raft"
revision="${version}"
/>-->
<!--<ivy:makepom ivyfile="${root.dir}/ivy.xml" pomfile="${dist.dir}/jgroups-raft-${version}.pom"/>-->
<copy todir="${dist.dir}">
<fileset dir="${root.dir}">
<include name="pom.xml"/>
</fileset>
<globmapper from="pom.xml" to="jgroups-raft-${version}.pom"/>
</copy>
<ivy:publish artifactspattern="${dist.dir}/[artifact]-[revision](-[classifier]).[ext]"
publishivy="false"
resolver="local-maven2"
overwrite="true"
forcedeliver="true"
pubrevision="${revision}"
status="release"
organisation="org.jgroups"
module="jgroups-raft"
revision="${version}"
haltonmissing="true"/>
<echo message="project ${ant.project.name} released with version ${revision}" />
</target>
<!-- =================================
target: publish-to-repo
================================= -->
<target name="publish-to-repo" depends="define-ivy-task"
description="Publishes this project to the remote maven repo (artifacts need to be in ./dist)">
<property name="revision" value="${version}"/>
<!--<ivy:deliver
deliverpattern="${dist.dir}/ivy.xml"
pubrevision="${version}"
status="release"
organisation="org.jgroups"
module="jgroups-raft"
revision="${version}"
/>-->
<!--<ivy:makepom ivyfile="${root.dir}/ivy.xml" pomfile="${dist.dir}/jgroups-raft-${version}.pom"/>-->
<copy todir="${dist.dir}">
<fileset dir="${root.dir}">
<include name="pom.xml"/>
</fileset>
<globmapper from="pom.xml" to="jgroups-raft-${version}.pom"/>
</copy>
<ivy:publish artifactspattern="${dist.dir}/[artifact]-[revision](-[classifier]).[ext]"
publishivy="false"
resolver="nexus"
overwrite="true"
forcedeliver="true"
pubrevision="${revision}"
status="release"
organisation="org.jgroups"
module="jgroups-raft"
revision="${version}"
haltonmissing="true"/>
<echo message="project ${ant.project.name} released with version ${revision}" />
</target>
<target name="define-ivy-task">
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="jg.classpath"/>
</target>
<target name="prepare" depends="retrieve">
<property environment="env"/>
<mkdir dir="${compile.dir}"/>
<copy file="${ivy.props}.template" tofile="${ivy.props}" overwrite="false"/>
<copy file="${build.properties.file}.template" tofile="${build.properties.file}" overwrite="false"/>
</target>
<target name="compile" depends="prepare" description="Compiles all Java files">
<javac destdir="${compile.dir}"
source="1.8"
target="1.8"
classpathref="jg.classpath"
includeantruntime="false"
debug="on"
deprecation="off"
optimize="off"
listfiles="false"
includes="org/**">
<src path="${src.dir}"/>
<src path="${junit-functional.dir}"/>
</javac>
</target>
<target name="jar"
description="Compiles and creates JARs in ./dist"
depends="jgroups-raft.jar, jgroups-raft-sources.jar">
</target>
<target name="jgroups-raft.jar"
description="Creates the jgroups-raft.jar (includes everything)"
depends="clean,compile">
<mkdir dir="${dist.dir}"/>
<xmlproperty file="${ant.file}" collapseAttributes="true"/>
<jar destfile="${dist.dir}/jgroups-raft-${version}.jar"
basedir="${compile.dir}"
includes="org/jgroups/**">
<fileset dir="${conf.dir}" includes="*.dtd, *.xml, jg-messages*.properties" excludes="*-service.xml"/>
<fileset dir="${root.dir}">
<include name="README*"/>
</fileset>
</jar>
</target>
<target name="jgroups-raft-sources.jar"
description="Creates the jgroups-raft-sources.jar (no demos, tests)">
<mkdir dir="${dist.dir}"/>
<jar jarfile="${dist.dir}/jgroups-raft-${version}-sources.jar"
basedir="${src.dir}"
includes="org/jgroups/**">
</jar>
</target>
<target name="check-manual">
<uptodate property="manual.up-to-date" targetfile="${manual.dir}/build/${timestamp}">
<srcfiles dir="${manual.dir}/" includes="**/*"/>
</uptodate>
<echo message="manual.up-to-date=${manual.up-to-date}"/>
</target>
<target name="manual" description="Generates the manual (AsciiDoc --> HTML)"
depends="check-manual,compile" unless="manual.up-to-date">
<echo message="Building manual from asciidoc ..."/>
<copy todir="${manual.dir}/">
<fileset dir="${doc.dir}/stylesheets">
<include name="*.css"/>
</fileset>
</copy>
<prot-properties-to-doc protocols-file="${protocols.adoc}"/>
<run-asciidoc dir="${manual.dir}" input="manual.adoc"/>
<copy todir="${manual.dir}/build/images">
<fileset dir="${manual.dir}/images">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="${manual.dir}/build">
<fileset dir="${doc.dir}/stylesheets">
<include name="*.css"/>
</fileset>
</copy>
<touch file="${manual.dir}/build/${timestamp}"/>
</target>
<!-- generate java doc -->
<target name="javadoc"
depends="prepare,check-javadoc" unless="javadoc.exists"
description="Creates Javadoc documentation in ./dist/javadoc">
<mkdir dir="${javadoc.dir}"/>
<javadoc packagenames="${javadoc.packages}"
sourcepath="${src.dir}"
destdir="${javadoc.dir}"
classpathref="jg.classpath"
author="true"
version="true"
use="true"
bottom="Copyright © 2014-2015 Red Hat. All Rights Reserved."
useexternalfile="yes"
doctitle="jgroups-raft">
<!-- The tag option for Javadoc is available in Java 1.4 or later. -->
<tag name="todo" description="To do:"/>
</javadoc>
</target>
<target name="check-javadoc" description="Checks whether the ./dist/javadoc dir exists">
<available file="${javadoc.dir}" type="dir" property="javadoc.exists"/>
</target>
<target name="all-tests" depends="compile" description="Runs all tests">
<sequential>
<antcall target="functional"/>
</sequential>
</target>
<target name="functional" depends="compile,define-testng-task" description="Runs functional tests">
<mkdir dir="${tmp.dir}/test-results/xml/functional"/>
<runtest suitename="functional"
groups="functional"
parallel="${parallel.classes}"
threadcount="10" />
</target>
<target name="clean"
description="Removes all class files and ./dist">
<delete dir="${compile.dir}" failonerror="false"/>
<delete dir="${dist.dir}" failonerror="false"/>
<delete dir="${tmp.dir}" failonerror="false"/>
<delete file="${conf.dir}/MANIFEST.MF" failonerror="false"/>
<delete>
<fileset dir="${root.dir}" defaultexcludes="no">
<include name="**/*~"/>
</fileset>
</delete>
<delete dir="${manual.dir}/build"/>
<delete>
<fileset dir="${manual.dir}" defaultexcludes="no">
<include name="*.adoc.tmp"/>
<include name="*.css"/>
</fileset>
</delete>
</target>
<target name="clean-all" depends="clean" description="Also removes lib">
<delete dir="${lib.dir}" failonerror="false"/>
</target>
<target name="reports" description="Produces the test report">
<mkdir dir="${tmp.dir}/test-results/html"/>
<junitreport todir="${tmp.dir}/test-results/html">
<fileset dir="${tmp.dir}/test-results/xml">
<include name="**/*.xml"/>
</fileset>
<report format="frames" todir="${tmp.dir}/test-results/html"/>
</junitreport>
<echo message="******************************************************************"/>
<echo message="The test report is ${tmp.dir}/test-results/html/index.html"/>
<echo message="******************************************************************"/>
</target>
<macrodef name="runtest" description="Runs a configuration-dependent test suite">
<attribute name="classpath" default="jg.classpath"/>
<attribute name="suitename" />
<attribute name="groups" /> <!-- comma-separated list, e.g. udp,functional -->
<attribute name="excludedgroups" default="broken"/>
<attribute name="parallel" default="${parallel.classes}"/>
<attribute name="threadcount" default="1"/>
<attribute name="outputdir" default="${tmp.dir}/test-results/xml"/>
<attribute name="initial.mcast.addr" default="${jgroups.udp.mcast_addr}"/>
<attribute name="initial.mcast.port" default="23000"/>
<attribute name="initial.tcp.port" default="23000"/>
<attribute name="tcp.recv.buf.size" default="200000"/>
<attribute name="tcp.send.buf.size" default="64000"/>
<attribute name="jvmarg1" default="-Dnonex=1"/>
<attribute name="jvmarg2" default="-Dnoney=1"/>
<!--<element name="additional-args" optional="true"/>-->
<sequential>
<property name="default-excludes" value=""/>
<testng classpathref="@{classpath}"
suitename="@{suitename}"
testname="@{suitename}"
groups="@{groups}"
excludedgroups="@{excludedgroups},${default-excludes}"
parallel="@{parallel}"
threadcount="@{threadcount}"
usedefaultlisteners="false"
outputdir="@{outputdir}"
listeners="org.jgroups.raft.util.JUnitXMLReporter"
timeout="${unittest.timeout}"
timeOut="${unittest.timeout}"
verbose="0"
configfailurepolicy="continue">
<classfileset dir="${compile.dir}"/>
<!--<xmlfileset dir="${testng.conf.dir}" includes="@{xml.file}"/>-->
<sysproperty key="INITIAL_MCAST_ADDR" value="@{initial.mcast.addr}"/>
<sysproperty key="INITIAL_MCAST_PORT" value="@{initial.mcast.port}"/>
<sysproperty key="INITIAL_TCP_PORT" value="@{initial.tcp.port}"/>
<sysproperty key="tcp.recv_buf_size" value="@{tcp.recv.buf.size}"/>
<sysproperty key="tcp.send_buf_size" value="@{tcp.send.buf.size}"/>
<!--jvmarg value="-Djgroups.bind_addr=${jgroups.bind_addr}"/-->
<jvmarg value="-Djgroups.udp.ip_ttl=0"/>
<jvmarg value="-Djgroups.tcpping.initial_hosts=${jgroups.tcpping.initial_hosts}"/>
<jvmarg value="-Djgroups.tunnel.gossip_router_hosts=${jgroups.tunnel.gossip_router_hosts}"/>
<jvmarg value="-Dtests.tmp.dir=${tmp.dir}"/>
<jvmarg value="-Dlog4j.configuration=file:${conf.dir}/log4j.properties"/>
<jvmarg value="-Dlog4j.configurationFile=${conf.dir}/log4j2.xml"/>
<jvmarg value="-Djava.net.preferIPv4Stack=${java.net.preferIPv4Stack}"/>
<jvmarg value="-Djava.net.preferIPv6Addresses=${java.net.preferIPv6Addresses}"/>
<jvmarg value="-Xms400M"/>
<jvmarg value="-Xmx800M"/>
<jvmarg value="@{jvmarg1}"/>
<jvmarg value="@{jvmarg2}"/>
<!--<additional-args/>-->
</testng>
</sequential>
</macrodef>
<macrodef name="prot-properties-to-doc">
<attribute name="protocols-file" default="${protocols.adoc}"/>
<sequential>
<echo message="Replacing variables in @{protocols-file}"/>
<java classname="org.jgroups.raft.util.PropsToAsciidoc" classpathref="jg.classpath" fork="true">
<arg value="@{protocols-file}"/>
<!--jvmarg value="-Dcom.sun.management.jmxremote"/-->
<!--permissions>
<grant class="javax.management.MBeanTrustPermission" name="*" actions=""/>
<grant class="java.io.FilePermission" name="${manual.dir}/-" actions="read,write"/>
<grant class="java.security.AllPermission"/>
</permissions-->
</java>
</sequential>
</macrodef>
<macrodef name="run-asciidoc">
<attribute name="dir"/>
<attribute name="input"/>
<sequential>
<mkdir dir="@{dir}/build"/>
<echo message="Generating index.html in @{dir}/build"/>
<exec executable="${asciidoc.executable}" dir="@{dir}">
<arg line="-n -a source-highlighter=highlightjs -a stylesheet=${asciidoctor-style} -a icons -o @{dir}/build/index.html @{input}"/>
</exec>
</sequential>
</macrodef>
</project>