-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.xml
577 lines (508 loc) · 20.1 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
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="common" xmlns:ivy="antlib:org.apache.ivy.ant">
<dirname property="common.basedir" file="${ant.file.common}"/>
<import file="${common.basedir}/common-tasks.xml"/>
<available property="with.ivy" file="ivy.xml"/>
<target name="setup-properties">
<!-- load optional antlib specific configuration -->
<property file="build.properties"/>
<!--load in an optional file containing versions of things-->
<property file="version.properties"/>
<!-- load common configuration -->
<property file="${common.basedir}/build.properties"/>
<!--load in a file containing versions of ant
and other libraries-->
<property file="${ant.home}/lib/libraries.properties"/>
<!-- javac properties -->
<property name="javac.test-source" value="${javac.-source}"/>
<property name="javac.test-target" value="${javac.-target}"/>
<tstamp>
<format property="artifact.publication.datetime" pattern="yyyyMMddHHmmss"/>
</tstamp>
</target>
<target name="setup" depends="setup-properties">
<mkdir dir="${build.classes}"/>
<mkdir dir="${build.testclasses}"/>
<mkdir dir="${build.lib}"/>
<copy file="${common.basedir}/style.css" todir="docs"/>
</target>
<!--Milestones to extend or override-->
<target name="ready-to-compile" depends="setup"/>
<target name="ready-to-test-with-junit" depends="compile-tests"/>
<target name="ready-to-test-with-antunit" depends="setup-for-antunit-tests"/>
<target name="ready-to-package" depends="compile"/>
<target name="ready-to-distribute" depends="antlib"/>
<target name="package" depends="checksum-target-jar"
description="Package everything up"/>
<target name="compile" depends="setup,resolve">
<javac
srcdir="src/main"
destdir="${build.classes}"
debug="${javac.debug}"
source="${javac.-source}"
target="${javac.-target}"
includeantruntime="true"
classpathref="classpath.compile"
/>
</target>
<target name="check-for-NOTICE">
<available file="NOTICE" property="notice-present?"/>
<fail unless="notice-present?">You must create a product specific
NOTICE file based on common/NOTICE.template in the top level
directory</fail>
</target>
<target name="antlib" depends="compile, check-for-NOTICE">
<copy todir="${build.classes}">
<fileset dir="src/main" includes="**/*.xml,**/*.properties"/>
</copy>
<jar destfile="${jarname}">
<fileset dir="${build.classes}"/>
<metainf file="NOTICE"/>
<metainf file="${common.basedir}/LICENSE"/>
</jar>
</target>
<target name="checksum-target-jar"
description="checksum our jar" depends="antlib">
<checksums>
<file file="${target.jar}"/>
</checksums>
</target>
<target name="determine-test-types">
<condition property="skip-junit">
<not>
<available file="${src.junit}"/>
</not>
</condition>
<condition property="skip-antunit">
<not>
<available file="${src.antunit}"/>
</not>
</condition>
</target>
<target name="setup-for-junit-tests" depends="setup,determine-test-types"
unless="skip-junit">
<available classname="junit.framework.TestCase" property="junit-present?"/>
<fail unless="junit-present?">The JUnit library is not present.</fail>
<available classname="org.apache.tools.ant.BuildFileTest"
property="testutil-present?"
ignoresystemclasses="true"
classpath="${ant-testutil.jar}"/>
<fail unless="testutil-present?">Expected to find ant-testutil.jar
in ${ant-testutil.jar}, please set the property ant-testutil.jar
to the correct location.</fail>
</target>
<target name="setup-for-antunit-tests" depends="setup,determine-test-types"
unless="skip-antunit">
<available classname="org.apache.ant.antunit.AntUnit"
property="antunit-present?"/>
<fail unless="antunit-present?">The AntUnit Ant library is not present.</fail>
</target>
<target name="compile-tests" depends="setup-for-junit-tests, antlib, resolve"
unless="skip-junit">
<javac
srcdir="${src.junit}"
destdir="${build.testclasses}"
debug="${javac.debug}"
source="${javac.test-source}"
target="${javac.test-target}"
>
<classpath>
<pathelement location="${jarname}"/>
<pathelement location="${ant-testutil.jar}"/>
<path refid="classpath.test"/>
</classpath>
</javac>
<copy todir="${build.testclasses}">
<fileset dir="${src.junit}" includes="**/*.xml,**/*.properties"/>
</copy>
</target>
<target name="junit-test" depends="ready-to-test-with-junit,resolve"
unless="skip-junit">
<mkdir dir="${junit.report.dir}"/>
<junit
printsummary="false"
haltonfailure="false"
failureproperty="junit.tests.failed"
filtertrace="false"
fork="${junit.fork}"
forkmode="${junit.forkmode}"
includeantruntime="true"
>
<classpath>
<pathelement location="${jarname}"/>
<pathelement location="${ant-testutil.jar}"/>
<pathelement location="${build.testclasses}"/>
<path refid="classpath.test"/>
</classpath>
<batchtest todir="${junit.report.dir}">
<fileset dir="${src.junit}"/>
</batchtest>
<formatter type="xml"/>
<formatter type="plain" usefile="false"/>
</junit>
</target>
<target name="antunit-test" depends="ready-to-test-with-antunit,resolve"
unless="skip-antunit">
<condition property="antunit.includes" value="${antunit.testcase}"
else="**/test.xml,**/*-test.xml">
<isset property="antunit.testcase" />
</condition>
<property name="antunit.excludes" value="" />
<mkdir dir="${antunit.report.dir}" />
<au:antunit xmlns:au="antlib:org.apache.ant.antunit"
failOnError="false"
errorProperty="antunit.tests.failed"
>
<fileset dir="${src.antunit}" includes="${antunit.includes}"
excludes="${antunit.excludes}" />
<au:xmllistener todir="${antunit.report.dir}" />
<au:plainlistener/>
</au:antunit>
</target>
<target name="test" depends="junit-test, antunit-test">
<fail if="junit.tests.failed">At least one JUnit test has failed.</fail>
<fail if="antunit.tests.failed">At least one AntUnit test has failed.</fail>
</target>
<target name="clean" depends="setup-properties">
<delete dir="${build}"/>
<delete dir="${dist.base}"/>
<delete dir="${dist.name}"/>
<delete dir="${bin.dist.dir}"/>
<delete dir="${src.dist.dir}"/>
</target>
<target name="javadoc_check">
<uptodate property="javadoc.notrequired"
targetfile="${build.javadoc}/package-list">
<srcfiles dir="src/main" includes="**/*.java,**/*.html"/>
</uptodate>
</target>
<target name="javadoc" depends="setup-properties, javadoc_check"
description="--> creates the API documentation"
unless="javadoc.notrequired">
<mkdir dir="${build.javadoc}"/>
<javadoc useexternalfile="yes"
maxmemory="1000M"
destdir="${build.javadoc}"
version="true"
locale="en"
windowtitle="${artifact.name} API"
doctitle="${artifact.name}"
failonerror="true"
verbose="false">
<packageset dir="src/main"/>
<classpath>
<path refid="classpath.compile"/>
<fileset dir="${ant.home}/lib" includes="*.jar"/>
</classpath>
<tag name="todo" description="To do:" scope="all"/>
<tag name="ant.task" enabled="false" description="Task:" scope="types"/>
<tag name="ant.datatype" enabled="false" description="Data type:" scope="types"/>
<tag name="ant.attribute" enabled="false" description="Attribute:" scope="types"/>
<tag name="ant.attribute.group" enabled="false" description="Attribute group:" scope="types"/>
<tag name="ant.element" enabled="false" description="Nested element:" scope="types"/>
</javadoc>
</target>
<!--copy the target to the destination. Only allowed if the tests pass!-->
<target name="install" depends="test">
<copy file="${jarname}" todir="${ant.home}/lib"/>
</target>
<import file="${common.basedir}/m2.xml"/>
<import file="${common.basedir}/ivy.xml"/>
<target name="src-dist" depends="m2-pom,ivy.xml"
description="--> creates a source distribution">
<mkdir dir="${src.dist.dir}"/>
<defaultexcludes remove="**/.gitattributes"/>
<defaultexcludes remove="**/.gitignore"/>
<defaultexcludes remove="**/.gitmodules"/>
<copy todir="${src.dist.dir}">
<fileset dir=".">
<include name=".gitattributes"/>
<include name=".gitignore"/>
<include name=".gitmodules"/>
<include name="INSTALL"/>
<include name="NOTICE"/>
<include name="README"/>
<include name="TODO"/>
<include name="build.properties"/>
<include name="build.xml"/>
<include name="changes.xml"/>
<include name="common/"/>
<include name="contributors.xml"/>
<include name="docs/"/>
<include name="ivy.xml"/>
<include name="prepare.xml"/>
<include name="project-template.pom"/>
<include name="src/"/>
<include name="version.properties"/>
</fileset>
<fileset dir="common">
<include name="LICENSE"/>
</fileset>
<fileset file="${target.pom}"/>
</copy>
<defaultexcludes default="true"/>
<fixcrlf srcdir="${src.dist.dir}" eol="dos" includes="*.bat,*.cmd"/>
<fixcrlf srcdir="${src.dist.dir}" eol="unix">
<include name="**/*.sh"/>
<include name="**/*.pl"/>
</fixcrlf>
<fixcrlf srcdir="${src.dist.dir}">
<include name="**/*.java"/>
</fixcrlf>
<antcall target="create-readable-documents">
<param name="dest.dir" value="${src.dist.dir}"/>
</antcall>
</target>
<target name="bin-dist" depends="checksum-target-jar,m2-pom,ivy.xml,javadoc">
<mkdir dir="${bin.dist.dir}"/>
<copy todir="${bin.dist.dir}">
<fileset dir=".">
<include name="docs/"/>
<include name="README"/>
<include name="INSTALL"/>
<include name="NOTICE"/>
<include name="TODO"/>
<include name="changes.xml"/>
<include name="contributors.xml"/>
</fileset>
<fileset dir="common">
<include name="LICENSE"/>
</fileset>
<fileset file="${jarname}*"/>
<fileset file="${target.pom}"/>
</copy>
<copy todir="${bin.dist.dir}/javadoc">
<fileset dir="${build.javadoc}"/>
</copy>
<copy todir="${bin.dist.dir}/" includeemptydirs="false">
<fileset dir="src">
<include name="etc/"/>
<exclude name="etc/testcases/"/>
</fileset>
</copy>
<antcall target="create-readable-documents">
<param name="dest.dir" value="${bin.dist.dir}"/>
</antcall>
</target>
<target name="distribution" description="creates a complete distribution"
depends="ready-to-distribute">
<mkdir dir="${dist.base.binaries}"/>
<mkdir dir="${dist.base.source}"/>
<!--delete dir="${java-repository.dir}"/-->
<!--mkdir dir="${java-repository.dir}"/-->
<delete dir="${dist.name}"/>
<antcall target="bin-dist" inheritall="false">
<param name="bin.dist.dir" value="${dist.name}"/>
</antcall>
<zip destfile="${dist.base.binaries}/${dist.name}-bin.zip">
<zipfileset dir="${dist.name}/.." filemode="755">
<include name="${dist.name}/bin/*.pl"/>
<include name="${dist.name}/bin/*.py"/>
</zipfileset>
<fileset dir="${dist.name}/..">
<include name="${dist.name}/**"/>
<exclude name="${dist.name}/bin/*.pl"/>
<exclude name="${dist.name}/bin/*.py"/>
</fileset>
</zip>
<tar longfile="gnu"
destfile="${dist.base.binaries}/${dist.name}-bin.tar">
<tarfileset dir="${dist.name}/.." mode="755" username="ant" group="ant">
<include name="${dist.name}/bin/*.pl"/>
<include name="${dist.name}/bin/*.py"/>
</tarfileset>
<tarfileset dir="${dist.name}/.." username="ant" group="ant">
<include name="${dist.name}/**"/>
<exclude name="${dist.name}/bin/*.pl"/>
<exclude name="${dist.name}/bin/*.py"/>
</tarfileset>
</tar>
<gzip destfile="${dist.base.binaries}/${dist.name}-bin.tar.gz"
src="${dist.base.binaries}/${dist.name}-bin.tar"/>
<bzip2 destfile="${dist.base.binaries}/${dist.name}-bin.tar.bz2"
src="${dist.base.binaries}/${dist.name}-bin.tar"/>
<delete file="${dist.base.binaries}/${dist.name}-bin.tar"/>
<!--copy todir="${java-repository.dir}">
<fileset dir="${dist.name}/lib">
<include name="ant*.jar"/>
</fileset>
<mapper type="glob" from="*.jar" to="*-${version}.jar"/>
</copy>
<checksums>
<fileset dir="${java-repository.dir}" includes="*${version}.jar"/>
</checksums-->
<checksums>
<fileset dir="${dist.base.binaries}/">
<include name="**/*"/>
<exclude name="**/*.asc"/>
<exclude name="**/*.sha512"/>
</fileset>
</checksums>
<delete dir="${dist.name}"/>
<antcall target="src-dist" inheritall="false">
<param name="src.dist.dir" value="${dist.name}"/>
</antcall>
<defaultexcludes remove="**/.gitattributes"/>
<defaultexcludes remove="**/.gitignore"/>
<defaultexcludes remove="**/.gitmodules"/>
<zip destfile="${dist.base.source}/${dist.name}-src.zip">
<fileset dir="${dist.name}/..">
<include name="${dist.name}/**"/>
</fileset>
</zip>
<tar longfile="gnu"
destfile="${dist.base.source}/${dist.name}-src.tar">
<tarfileset dir="${dist.name}/.." username="ant" group="ant">
<include name="${dist.name}/**"/>
</tarfileset>
</tar>
<defaultexcludes default="true"/>
<gzip destfile="${dist.base.source}/${dist.name}-src.tar.gz"
src="${dist.base.source}/${dist.name}-src.tar"/>
<bzip2 destfile="${dist.base.source}/${dist.name}-src.tar.bz2"
src="${dist.base.source}/${dist.name}-src.tar"/>
<delete file="${dist.base.source}/${dist.name}-src.tar"/>
<delete dir="${dist.name}"/>
<checksums>
<fileset dir="${dist.base.source}/">
<include name="**/*"/>
<exclude name="**/*.asc"/>
<exclude name="**/*.sha512"/>
</fileset>
</checksums>
</target>
<target name="check-contributors">
<available property="contributors.file.exists?"
file="contributors.xml"/>
</target>
<target name="check-changes">
<available property="changes.file.exists?"
file="changes.xml"/>
</target>
<target name="style-contributors" depends="check-contributors"
if="contributors.file.exists?">
<xslt style="${common.basedir}/stylesheets/contributors.xsl" in="contributors.xml"
out="${dest.dir}/CONTRIBUTORS"/>
</target>
<target name="style-changes" depends="check-changes"
if="changes.file.exists?">
<xslt style="${common.basedir}/stylesheets/changes2whatsnew.xsl" in="changes.xml"
out="${dest.dir}/WHATSNEW"/>
<xslt style="${common.basedir}/stylesheets/changes2readmehtml.xsl" in="changes.xml"
out="${dest.dir}/README.html"/>
</target>
<target name="create-readable-documents"
depends="style-contributors,style-changes"/>
<!-- uploading of releases -->
<import file="${common.basedir}/upload.xml"/>
<target name="prepare-upload" depends="bin-dist">
<property name="upload.dir"
value="${build.javarepository}/org.apache.ant/${artifact.name}/${artifact.version}"/>
<mkdir dir="${upload.dir}"/>
<copy file="${jarname}" todir="${upload.dir}"/>
<copy file="${target.pom}" todir="${upload.dir}"/>
<copy file="${target.ivy.xml}" todir="${upload.dir}"/>
<jar destfile="${upload.dir}/${artifact.stub}-sources.jar">
<fileset dir="src/main"/>
<metainf file="NOTICE"/>
<metainf file="${common.basedir}/LICENSE"/>
</jar>
<jar destfile="${upload.dir}/${artifact.stub}-javadoc.jar">
<fileset dir="${build.javadoc}"/>
<metainf file="NOTICE"/>
<metainf file="${common.basedir}/LICENSE"/>
</jar>
</target>
<target name="check-sigs" depends="prepare-upload">
<uptodate property="jar.sig.ok"
srcfile="${upload.dir}/${artifact.stub}.jar"
targetfile="${upload.dir}/${artifact.stub}.jar.asc"/>
<uptodate property="pom.sig.ok"
srcfile="${upload.dir}/${artifact.stub}.pom"
targetfile="${upload.dir}/${artifact.stub}.pom.asc"/>
<uptodate property="sources.sig.ok"
srcfile="${upload.dir}/${artifact.stub}-sources.jar"
targetfile="${upload.dir}/${artifact.stub}-sources.jar.asc"/>
<uptodate property="javadoc.sig.ok"
srcfile="${upload.dir}/${artifact.stub}-javadoc.jar"
targetfile="${upload.dir}/${artifact.stub}-javadoc.jar.asc"/>
<uptodate property="ivy.sig.ok"
srcfile="${upload.dir}/${artifact.stub}-ivy.xml"
targetfile="${upload.dir}/${artifact.stub}-ivy.xml.asc"/>
<fail message="Your OpenPGP signature of the artifacts is too old or missing">
<condition>
<not>
<and>
<isset property="jar.sig.ok"/>
<isset property="pom.sig.ok"/>
<isset property="sources.sig.ok"/>
<isset property="javadoc.sig.ok"/>
<isset property="ivy.sig.ok"/>
</and>
</not>
</condition>
</fail>
</target>
<target name="upload" depends="check-sigs,perform-nexus-upload"/>
<!-- "fat" binary distributions with dependencies -->
<import file="${common.basedir}/fetch.xml"/>
<target name="fat-distribution"
description="creates a complete binary distribution with dependencies"
depends="distribution,fetch-dependencies">
<unzip src="${dist.base.binaries}/${dist.name}-bin.zip"
dest="."/>
<copy todir="${dist.name}">
<fileset dir="${build.deps}"/>
</copy>
<zip destfile="${dist.base.binaries}/${dist.name}-bin-withdeps.zip">
<zipfileset dir="${dist.name}/.." filemode="755">
<include name="${dist.name}/bin/*.pl"/>
<include name="${dist.name}/bin/*.py"/>
</zipfileset>
<fileset dir="${dist.name}/..">
<include name="${dist.name}/**"/>
<exclude name="${dist.name}/bin/*.pl"/>
<exclude name="${dist.name}/bin/*.py"/>
</fileset>
</zip>
<tar longfile="gnu"
destfile="${dist.base.binaries}/${dist.name}-bin-withdeps.tar">
<tarfileset dir="${dist.name}/.." mode="755" username="ant" group="ant">
<include name="${dist.name}/bin/*.pl"/>
<include name="${dist.name}/bin/*.py"/>
</tarfileset>
<tarfileset dir="${dist.name}/.." username="ant" group="ant">
<include name="${dist.name}/**"/>
<exclude name="${dist.name}/bin/*.pl"/>
<exclude name="${dist.name}/bin/*.py"/>
</tarfileset>
</tar>
<gzip destfile="${dist.base.binaries}/${dist.name}-bin-withdeps.tar.gz"
src="${dist.base.binaries}/${dist.name}-bin-withdeps.tar"/>
<bzip2 destfile="${dist.base.binaries}/${dist.name}-bin-withdeps.tar.bz2"
src="${dist.base.binaries}/${dist.name}-bin-withdeps.tar"/>
<delete file="${dist.base.binaries}/${dist.name}-bin-withdeps.tar"/>
<checksums>
<fileset dir="${dist.base.binaries}/">
<include name="**/*-withdeps*"/>
<exclude name="**/*.asc"/>
<exclude name="**/*.sha512"/>
</fileset>
</checksums>
<delete dir="${dist.name}"/>
</target>
</project>