-
Notifications
You must be signed in to change notification settings - Fork 49
/
build.xml
1920 lines (1797 loc) · 73.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
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<project default="run" basedir="." name="build.xml to wrap maven">
<!-- ****************************** Configuration ****************************** -->
<!-- TODO: support building from workspace (flat - no plugins/, tests/, features/ in pom.xml) -->
<!-- TODO: support fetching entire tree if not available from ${svn.root} into ./ dir -->
<!-- default maven version -->
<property name="maven.version" value="3.0-beta-1" />
<!-- set name of component(s) to build+test, IN ORDER; if no subcomponents, use "." -->
<property name="COMPONENTS" value="." />
<!-- svn root, including trunk or branch path -->
<property name="svn.root" value="http://anonsvn.jboss.org/repos/tdesigner/trunk" />
<!-- if true, use -Dmaven.repo.local=${COMMON_TOOLS}/m2-repository; if false, use default ~/.m2/repository; or set another path if preferred -->
<property name="maven.repo.local" value="true" />
<!-- name/version we're building -->
<property name="product.name" value="Teiid Designer" />
<property name="product.id" value="TeiidDesigner" />
<property name="product.version" value="7.0.0-beta-1" />
<!-- update site description :: not used if site.xml already present -->
<property name="update.site.description" value="Nightly Build" />
<!-- ****************************** Usage Instructions ****************************** -->
<target name="help" description="Usage Instructions" depends="init">
<echo>
To run this script in Eclipse:
Run As > Ant Build
To run this script via commandline (build default modules + run tests, then collect test results and build per-component + overall update site zips):
cd /path/to/checked/out/source/tree; ant
or, to build everything but not *run* the tests:
ant -DMAVEN_FLAGS="clean install -Dmaven.test.skip"
or
ant -Dnotests=true
or, to purge the local repo (or purge then build):
ant purge -q
or
ant clean-run
or, to rebuild even if sources have not changed:
ant -Dbuild.if.sources.unchanged=true
or, to fetch fresh sources, then build anew:
ant -Dclean.sources=true
or, to (re-)run tests w/o (re-)building first:
ant -DMAVEN_FLAGS="osgi-test:test -B -fn"
or, to re-build a single component's update site w/o building, testing, and installing it into the m2 repo:
ant create.update.site
or, to re-build the overall update site w/o building first (no applicable when COMPONENTS=.):
ant create.overall.update.site -Dbuild.if.sources.unchanged=true
To have hudson manage sources (rather than having this script checkout/update them) use:
-Dhudson.managed.sources=true
Note: if tests stall on Linux, install Xvfb and this script will use that to run Maven, unless use:
-DnoXvfb=true
Here is the order in which components must be built:
</echo>
<for param="COMPONENT" list="${COMPONENTS}" delimiter=";">
<sequential>
<echo message=" @{COMPONENT}," />
</sequential>
</for>
</target>
<!-- ******************* MAIN ENTRY TARGETS ******************* -->
<target name="clean-run" description="purge m2 repo, then run build" depends="purge, run" />
<target name="purge" depends="init">
<antcall target="genPomXml">
<param name="COMPONENT" value="purge" />
<param name="packaging" value="pom" />
</antcall>
<antcall target="mvn">
<param name="COMPONENT" value="purge" />
<param name="MAVEN_DIR" value="${WORKINGDIR}/purge/site" />
<param name="MAVEN_FLAGS" value="dependency:purge-local-repository -e -U -q -B -fae" />
<param name="noXvfb" value="true" />
</antcall>
<delete dir="${WORKINGDIR}/purge" includeemptydirs="true" quiet="true" />
<delete dir="${COMMON_TOOLS}/m2-repository/org/jboss/tools" includeemptydirs="true" quiet="true" />
</target>
<target name="run"
description="run a build, collect test results, generate overall update site"
depends="build, collect.all.test.results, create.overall.update.site, collect.update.site.results"
/>
<target name="build"
description="run a build"
depends="init, get.bootstrap.scripts, get.sources, get.components.to.build, run.build"
/>
<target name="test"
description="run tests w/o first getting sources + list of components to build; assumes an upstream build job was already run"
depends="init, get.bootstrap.scripts, get.all.components, run.build, collect.all.test.results"
/>
<!-- ******************* MAIN ENTRY TARGETS ******************* -->
<!-- override for local build -->
<condition property="isInHudson" value="true">
<or>
<contains string="${user.dir}" substring="hudson" />
<contains string="${user.name}" substring="hudson" />
<contains string="${user.home}" substring="hudson" />
</or>
</condition>
<target name="local" unless="isInHudson">
<property name="WORKINGDIR" value="${basedir}" />
<property name="COMMON_TOOLS" value="${java.io.tmpdir}" />
</target>
<target name="get.ant-contrib" unless="ant-contrib.jar.exists">
<property name="ANTCONTRIB_MIRROR" value="http://downloads.sourceforge.net/ant-contrib/" />
<get usetimestamp="true"
dest="${COMMON_TOOLS}/ant-contrib-1.0b2-bin.zip"
src="${ANTCONTRIB_MIRROR}/ant-contrib-1.0b2-bin.zip"
/>
<touch file="${COMMON_TOOLS}/ant-contrib-1.0b2-bin.zip" />
<mkdir dir="${java.io.tmpdir}/ant-contrib-1.0b2-bin.zip_" />
<unzip src="${COMMON_TOOLS}/ant-contrib-1.0b2-bin.zip"
dest="${java.io.tmpdir}/ant-contrib-1.0b2-bin.zip_"
overwrite="true"
/>
<copy file="${java.io.tmpdir}/ant-contrib-1.0b2-bin.zip_/ant-contrib/lib/ant-contrib.jar"
tofile="${COMMON_TOOLS}/ant-contrib.jar"
failonerror="true"
/>
<delete dir="${java.io.tmpdir}/ant-contrib-1.0b2-bin.zip_" includeemptydirs="true" quiet="true" />
</target>
<target name="get.svnant" unless="svnant.jar.exists">
<echo level="debug">${os.name}, ${os.arch}, ${os.version}, ${osgi.os}</echo>
<property name="SVNANT_MIRROR" value="http://www.tigris.org/files/documents/906/46267" />
<if>
<istrue value="${isWindows}" />
<then>
<var name="svnant.enabled" unset="true" />
<var name="svnant.enabled" value="false" />
</then>
<else>
<exec executable="wget" dir="${COMMON_TOOLS}">
<arg line="${SVNANT_MIRROR}/svnant-1.3.0.zip --no-clobber" />
</exec>
</else>
</if>
<if>
<istrue value="${svnant.enabled}" />
<then>
<if>
<available file="${COMMON_TOOLS}/svnant-1.3.0.zip" type="file" />
<then>
<touch file="${COMMON_TOOLS}/svnant-1.3.0.zip" />
<mkdir dir="${java.io.tmpdir}/svnant-1.3.0.zip_" />
<unzip src="${COMMON_TOOLS}/svnant-1.3.0.zip"
dest="${java.io.tmpdir}/svnant-1.3.0.zip_"
overwrite="true"
/>
<copy todir="${COMMON_TOOLS}" failonerror="true">
<fileset dir="${java.io.tmpdir}/svnant-1.3.0.zip_/svnant-1.3.0/lib/" includes="*.jar" />
</copy>
<delete dir="${java.io.tmpdir}/svnant-1.3.0.zip_" includeemptydirs="true" quiet="true" />
</then>
<elseif>
<or>
<not>
<available file="${COMMON_TOOLS}/svnant.jar" type="file" />
</not>
<not>
<available file="${COMMON_TOOLS}/svnkit.jar" type="file" />
</not>
<not>
<available file="${COMMON_TOOLS}/svnClientAdapter.jar" type="file" />
</not>
</or>
<then>
<fail>Error!
Build cannot proceed!
Must install svnant.jar, svnkit.jar + svnClientAdapter.jar from
${SVNANT_MIRROR}/svnant-1.3.0.zip
into ${COMMON_TOOLS}/.
</fail>
</then>
</elseif>
</if>
</then>
<else>
<echo level="warning">Warning!
Svnant unavailable. Will use Maven to fetch sources.
</echo>
</else>
</if>
</target>
<target name="get.maven" unless="maven.exists">
<property name="MAVEN_MIRROR" value="http://mirror.csclub.uwaterloo.ca/apache/maven/binaries" />
<get usetimestamp="true"
dest="${COMMON_TOOLS}/apache-maven-${maven.version}-bin.tar.gz"
src="${MAVEN_MIRROR}/apache-maven-${maven.version}-bin.tar.gz"
/>
<untar compression="gzip"
overwrite="false"
dest="${COMMON_TOOLS}"
src="${COMMON_TOOLS}/apache-maven-${maven.version}-bin.tar.gz"
/>
<chmod perm="755" file="${COMMON_TOOLS}/apache-maven-${maven.version}/bin/mvn" />
</target>
<target name="init" depends="local">
<macrodef name="now">
<attribute name="level" default="warning" />
<text name="info" optional="true" />
<sequential>
<var name="now" unset="true" />
<tstamp>
<format property="now" pattern="hh:mm:ss" />
</tstamp>
<echo level="@{level}">${now} @{info}</echo>
</sequential>
</macrodef>
<condition property="isWindows" value="true" else="false">
<or>
<os family="windows" />
<contains string="${os.name}" substring="windows" casesensitive="false" />
</or>
</condition>
<!-- https://jira.jboss.org/jira/browse/JBQA-3313 Use static, shared space outside workspace, instead of working directly in the workspace -->
<condition property="WORKINGDIR" value="/home/hudson/static_build_env/jbds/tools/sources" else="${basedir}">
<available file="/home/hudson/static_build_env/jbds" type="dir" />
</condition>
<mkdir dir="${WORKINGDIR}" />
<echo level="info">WORKINGDIR = ${WORKINGDIR}</echo>
<condition property="COMMON_TOOLS"
value="/home/hudson/static_build_env/jbds/tools"
else="${WORKINGDIR}/../tools"
>
<available file="/home/hudson/static_build_env/jbds" type="dir" />
</condition>
<mkdir dir="${COMMON_TOOLS}" />
<echo level="info">COMMON_TOOLS = ${COMMON_TOOLS}</echo>
<available file="${COMMON_TOOLS}/ant-contrib.jar" type="file" property="ant-contrib.jar.exists" />
<antcall target="get.ant-contrib" />
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${COMMON_TOOLS}/ant-contrib.jar" />
</classpath>
</taskdef>
<property name="svnant.enabled" value="true" />
<available file="${COMMON_TOOLS}/svnant.jar" type="file" property="svnant.jar.exists" />
<antcall target="get.svnant" />
<taskdef resource="org/tigris/subversion/svnant/svnantlib.xml">
<classpath>
<pathelement location="${COMMON_TOOLS}/svnant.jar" />
<pathelement location="${COMMON_TOOLS}/svnkit.jar" />
<pathelement location="${COMMON_TOOLS}/svnClientAdapter.jar" />
</classpath>
</taskdef>
<available file="${COMMON_TOOLS}/apache-maven-${maven.version}/bin/mvn" type="file" property="maven.exists" />
<antcall target="get.maven" />
</target>
<target name="get.sources" description="if sources not already on disk, fetch them" unless="hudson.managed.sources">
<property name="clean.sources" value="false" />
<property name="svn.recurse" value="true" />
<!-- = = = = = = = = = = = = = = = = =
COMPONENT: component to fetch or update
op: up (update) or co (checkout)
= = = = = = = = = = = = = = = = = -->
<macrodef name="svn.fetch">
<attribute name="component" />
<attribute name="op" />
<sequential>
<!-- check out or update -->
<if>
<equals arg1="@{op}" arg2="up" />
<then>
<now level="info">Update '@{COMPONENT}'</now>
<if>
<istrue value="${svnant.enabled}" />
<then>
<!-- remove generated site/ folder -->
<if>
<not>
<equals arg1="@{component}" arg2="." />
</not>
<then>
<delete dir="${WORKINGDIR}/@{component}/site"
includeemptydirs="true"
quiet="true"
/>
</then>
</if>
<!--
<svn javahl="false" svnkit="true" failonerror="false">
<revert recurse="${svn.recurse}" dir="@{component}" />
</svn>
-->
<svn javahl="false" svnkit="true" failonerror="false">
<update recurse="${svn.recurse}" dir="@{component}" />
</svn>
</then>
<else>
<antcall target="mvn">
<param name="MAVEN_DIR" value="${WORKINGDIR}" />
<param name="MAVEN_FLAGS"
value="scm:update -f ${WORKINGDIR}/parent-pom.xml -e -q -B -fae -Dmaven.test.skip -DworkingDirectory=${WORKINGDIR}/@{component} -DconnectionUrl=scm:svn:${svn.root}/@{component} -DdeveloperConnectionUrl=scm:svn:${svn.root}/@{component}"
/>
<param name="noXvfb" value="true" />
</antcall>
</else>
</if>
</then>
<else>
<now level="info">Fetch sources from ${svn.root}/@{component} into ${WORKINGDIR}/@{component}</now>
<if>
<istrue value="${svnant.enabled}" />
<then>
<svn javahl="false" svnkit="true" failonerror="true">
<checkout recurse="${svn.recurse}"
url="${svn.root}/@{component}"
destpath="${WORKINGDIR}/@{component}"
/>
</svn>
</then>
<else>
<antcall target="mvn">
<param name="MAVEN_DIR" value="${WORKINGDIR}" />
<param name="MAVEN_FLAGS"
value="scm:checkout -f ${WORKINGDIR}/parent-pom.xml -e -q -B -fae -Dmaven.test.skip -DskipCheckoutIfExists=true -DcheckoutDirectory=${WORKINGDIR}/@{component} -DworkingDirectory=${WORKINGDIR}/@{component} -DconnectionUrl=scm:svn:${svn.root}/@{component} -DdeveloperConnectionUrl=scm:svn:${svn.root}/@{component}"
/>
<param name="noXvfb" value="true" />
</antcall>
</else>
</if>
</else>
</if>
<!-- Store svn info so we can compare it later and thus not need to update or checkout every time -->
<if>
<istrue value="${svnant.enabled}" />
<then>
<svn javahl="false" svnkit="true" failonerror="false">
<info target="${WORKINGDIR}/@{component}"
propprefix="svn.info.@{component}"
verbose="false"
/>
</svn>
</then>
</if>
<if>
<isset property="svn.info.@{component}.rev" />
<then>
<echo file="${WORKINGDIR}/svn.info-@{component}.txt">svn.info.@{component}.rev = ${svn.info.@{component}.rev}
</echo>
</then>
</if>
<echo file="${WORKINGDIR}/build.cfg" message="@{component}," append="true" />
</sequential>
</macrodef>
<!-- only reset the file if we don't already have a value for COMPONENTS.to.build; thus when called later for "site" component build, append instead of overwriting -->
<if>
<not>
<isset property="COMPONENTS.to.build" />
</not>
<then>
<echo file="${WORKINGDIR}/build.cfg" message="COMPONENTS.to.build = " />
</then>
</if>
<!-- check for each component dir in ${WORKINGDIR}; if not found, fetch -->
<if>
<and>
<isset property="COMPONENT" />
<not>
<equals arg1="${COMPONENT}" arg2="" />
</not>
</and>
<then>
<var name="COMPONENTS" unset="true" />
<var name="COMPONENTS" value="${COMPONENT}" />
</then>
</if>
<for param="COMPONENT" list="${COMPONENTS}" delimiter=",;
">
<sequential>
<if>
<equals arg1="${clean.sources}" arg2="true" />
<then>
<delete dir="${WORKINGDIR}/@{COMPONENT}" includeemptydirs="true" quiet="true" />
</then>
</if>
<if>
<not>
<available file="${WORKINGDIR}/@{COMPONENT}" type="dir" />
</not>
<then>
<svn.fetch component="@{COMPONENT}" op="co" />
</then>
<else>
<if>
<available file="${WORKINGDIR}/svn.info-@{COMPONENT}.txt" type="file" />
<then>
<property file="${WORKINGDIR}/svn.info-@{COMPONENT}.txt" />
<!-- check svn info; if new version found, svn up -->
<if>
<istrue value="${svnant.enabled}" />
<then>
<svn javahl="false" svnkit="true" failonerror="false">
<info target="${WORKINGDIR}/@{COMPONENT}"
propprefix="svn.info.@{COMPONENT}.check"
verbose="false"
/>
</svn>
</then>
</if>
<if>
<or>
<not>
<isset property="svn.info.@{COMPONENT}.rev" />
</not>
<not>
<isset property="svn.info.@{COMPONENT}.check.rev" />
</not>
<not>
<equals arg1="${svn.info.@{COMPONENT}.rev}"
arg2="${svn.info.@{COMPONENT}.check.rev}"
/>
</not>
</or>
<then>
<svn.fetch component="@{COMPONENT}" op="up" />
</then>
<else>
<if>
<and>
<isset property="build.if.sources.unchanged" />
<istrue value="${build.if.sources.unchanged}" />
</and>
<then>
<svn.fetch component="@{COMPONENT}" op="up" />
</then>
</if>
</else>
</if>
</then>
<else>
<svn.fetch component="@{COMPONENT}" op="up" />
</else>
</if>
</else>
</if>
</sequential>
</for>
</target>
<target name="get.bootstrap.scripts">
<!-- also get files required to bootstrap the build -->
<get src="${svn.root}/parent-pom.xml" dest="${WORKINGDIR}/parent-pom.xml" usetimestamp="true" />
<get src="${svn.root}/genpom.xml" dest="${WORKINGDIR}/genpom.xml" usetimestamp="true" />
</target>
<target name="get.all.components">
<var name="COMPONENTS.to.build" unset="true" />
<var name="COMPONENTS.to.build" value="" />
<for param="COMPONENT" list="${COMPONENTS}" delimiter="; ">
<sequential>
<var name="COMPONENTS.to.build" value="${COMPONENTS.to.build}@{COMPONENT}," />
</sequential>
</for>
</target>
<target name="get.components.to.build">
<if>
<available file="${WORKINGDIR}/build.cfg" type="file" />
<then>
<property file="${WORKINGDIR}/build.cfg" />
<if>
<equals arg1="${COMPONENTS.to.build}" arg2="" />
<then>
<echo level="warning">All components up to date: nothing to do!
To force a build of unchanged components, use -Dbuild.if.sources.unchanged=true</echo>
<!-- create fake test result file to avoid Hudson failure -->
<delete dir="${basedir}/surefire-reports/NoTestsRun" includeemptydirs="true" />
<mkdir dir="${basedir}/surefire-reports/NoTestsRun" />
<echo file="${basedir}/surefire-reports/NoTestsRun/TEST-org.jboss.tools.NoTestsRun.xml"><?xml version="1.0" encoding="UTF-8" ?>
<testsuite failures="0" time="0.001" errors="0" skipped="0" tests="1" name="org.jboss.tools.NoTestsRun">
<testcase time="0.001" classname="org.jboss.tools.NoTestsRun" name="NoTestsRun"/>
</testsuite>
</echo>
<property name="no.tests.run" value="true" />
<property name="no.overall" value="true" />
</then>
<elseif>
<not>
<equals arg1="${COMPONENTS.to.build}" arg2=".," />
</not>
<then>
<echo level="warning">The following components' sources have changed and will be built:
COMPONENTS.to.build = ${COMPONENTS.to.build}
</echo>
</then>
</elseif>
<elseif>
<equals arg1="${COMPONENTS.to.build}" arg2=".," />
<then>
<property name="no.overall" value="true" />
</then>
</elseif>
</if>
</then>
<else>
<antcallback target="get.all.components" return="COMPONENTS.to.build" />
</else>
</if>
</target>
<target name="run.build">
<!-- could set -Dmaven.test.skip to skip tests, or use osgi-test:test to just (re-)run tests w/o first building -->
<property name="MAVEN_FLAGS" value="clean install -B -fn -q -U -e -Dsurefire.useFile=false" />
<!-- commandline overrides to suppress doing tests -->
<if>
<or>
<isset property="notest" />
<isset property="notests" />
<isset property="skiptest" />
<isset property="skiptests" />
</or>
<then>
<property name="noXvfb" value="true" />
<if>
<not>
<contains string="${MAVEN_FLAGS}" substring="-Dmaven.test.skip" />
</not>
<then>
<var name="MAVEN_FLAGS" value="${MAVEN_FLAGS} -Dmaven.test.skip" />
</then>
</if>
</then>
</if>
<for param="COMPONENT" list="${COMPONENTS.to.build}" delimiter=",
">
<sequential>
<if>
<equals arg1="@{COMPONENT}" arg2="site" />
<then>
<now level="warning">Build overall update @{COMPONENT}</now>
</then>
<else>
<now level="warning">Build '@{COMPONENT}' component</now>
</else>
</if>
<!-- TODO if needed: optional extra instructions to do before a maven build -->
<loadfile property="@{COMPONENT}.pom.xml" srcfile="${WORKINGDIR}/@{COMPONENT}/pom.xml" />
<if>
<and>
<!-- if pom.xml does not call custom build.xml directly -->
<not>
<contains string="${@{COMPONENT}.pom.xml}"
substring="<ant antfile="build.xml" />"
/>
</not>
<available file="${WORKINGDIR}/@{COMPONENT}/build.xml" type="file" />
<not>
<equals arg1="@{COMPONENT}" arg2="." />
</not>
</and>
<then>
<echo>Run custom '@{COMPONENT}/build.xml'</echo>
<ant antfile="${WORKINGDIR}/@{COMPONENT}/build.xml">
<property name="COMPONENT" value="@{COMPONENT}" />
<property name="basedir" value="${WORKINGDIR}/@{COMPONENT}" />
</ant>
</then>
</if>
<!-- If poms already exist, DO NOT OVERWRITE unless -Doverwrite.existing.pom.xml=true -->
<ant antfile="genpom.xml" target="run" dir="${WORKINGDIR}">
<property name="COMPONENT" value="@{COMPONENT}" />
</ant>
<antcall target="mvn">
<param name="COMPONENT" value="@{COMPONENT}" />
</antcall>
<!-- don't collect test results if there are no test results to collect! -->
<if>
<not>
<contains string="${MAVEN_FLAGS}" substring="-Dmaven.test.skip" />
</not>
<then>
<antcall target="collect.test.results">
<param name="COMPONENT" value="@{COMPONENT}" />
</antcall>
</then>
<else>
<property name="no.tests.run" value="true" />
</else>
</if>
<!-- prevent recursion: overall site component is built with create.overall.update.site, not simpler create.update.site; also, don't rebuild the site if it's already been done by "." component -->
<if>
<and>
<not>
<equals arg1="@{COMPONENT}" arg2="site" />
</not>
<not>
<equals arg1="@{COMPONENT}" arg2="." />
</not>
</and>
<then>
<antcall target="create.update.site">
<param name="COMPONENT" value="@{COMPONENT}" />
</antcall>
</then>
</if>
</sequential>
</for>
<now level="info">Builds done</now>
</target>
<target name="mvn">
<var name="mvnExe" value="mvn" />
<antcallback target="getMvnExe" return="mvnExe" />
<echo level="verbose">Exe: ${COMMON_TOOLS}/apache-maven-${maven.version}/bin/${mvnExe}</echo>
<echo level="verbose">Pom: ${WORKINGDIR}/${COMPONENT}/pom.xml</echo>
<property name="MAVEN_DIR" value="${WORKINGDIR}/${COMPONENT}" />
<!-- support using true/false/other path values of maven.repo.local -->
<if>
<isset property="maven.repo.local" />
<then>
<if>
<isfalse value="${maven.repo.local}" />
<then>
<var name="maven.repo.local" value="" />
</then>
<elseif>
<istrue value="${maven.repo.local}" />
<then>
<var name="maven.repo.local" value=" -Dmaven.repo.local=${COMMON_TOOLS}/m2-repository" />
</then>
</elseif>
<else>
<var name="maven.repo.local" value=" -Dmaven.repo.local=${maven.repo.local}" />
</else>
</if>
</then>
<else>
<var name="maven.repo.local" value=" -Dmaven.repo.local=${COMMON_TOOLS}/m2-repository" />
</else>
</if>
<!-- 3 hr timeout = 10800000ms -->
<echo level="info">${mvnExe} ${MAVEN_FLAGS} ${maven.repo.local}</echo>
<exec executable="${COMMON_TOOLS}/apache-maven-${maven.version}/bin/${mvnExe}"
dir="${MAVEN_DIR}"
failifexecutionfails="true"
failonerror="true"
timeout="10800000"
>
<env key="M2_HOME" value="${COMMON_TOOLS}/apache-maven-${maven.version}" />
<env key="MAVEN_OPTS" value="-Xms512m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m" />
<!-- more debug output with <env key="MAVEN_OPTS" value="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"/> -->
<!-- <arg line="-o -Dmaven.test.skip" /> -->
<arg line="${MAVEN_FLAGS} ${maven.repo.local}" />
</exec>
</target>
<!-- Use Xvfb wrapper for maven when invoking UI tests -->
<target name="getMvnExe" unless="noXvfb">
<if>
<available file="/usr/bin/Xvfb" type="file" />
<then>
<if>
<not>
<available file="${COMMON_TOOLS}/apache-maven-${maven.version}/bin/mvnWithXvfb" type="file" />
</not>
<then>
<echo file="${COMMON_TOOLS}/apache-maven-${maven.version}/bin/mvnWithXvfb">#!/bin/bash
if [[ -f /tmp/.X3-lock ]]; then
kill -9 `cat /tmp/.X3-lock`
rm -fr /tmp/.X3-lock
fi
/usr/bin/Xvfb :3 -ac 2>&1 1>/dev/null &
DISPLAY=:3 /opt/maven3/bin/mvn $*
kill -9 `cat /tmp/.X3-lock`
rm -fr /tmp/.X3-lock
</echo>
<chmod perm="755" file="${COMMON_TOOLS}/apache-maven-${maven.version}/bin/mvnWithXvfb" />
</then>
</if>
<var name="mvnExe" value="mvnWithXvfb" />
</then>
</if>
</target>
<target name="collect.test.results">
<delete dir="${basedir}/surefire-reports/NoTestsRun" includeemptydirs="true" />
<property name="COMPONENT" value="" />
<!-- collect test results by copying ${WORKINGDIR}/${COMPONENT}/**/target/surefire-reports/*.xml into ${basedir}/surefire-reports/${COMPONENT} -->
<delete dir="${basedir}/surefire-reports/${COMPONENT}" includeemptydirs="true" />
<mkdir dir="${basedir}/surefire-reports/${COMPONENT}" />
<copy todir="${basedir}/surefire-reports/${COMPONENT}"
flatten="true"
preservelastmodified="true"
overwrite="true"
>
<fileset dir="${WORKINGDIR}/${COMPONENT}" includes="**/target/surefire-reports/*.xml" />
</copy>
</target>
<target name="collect.all.test.results" unless="no.tests.run">
<var name="test.results.all" value="" />
<var name="test.results.errors.failures.skipped" value="" />
<!-- Parse this: <testsuite errors="0" skipped="0" tests="10" time="0.042" failures="0" name="org.jboss.tools.jmx.ui.JMXUIAllTests"> -->
<for param="testresultfile" delimiter=",
">
<path>
<fileset dir="${basedir}/surefire-reports/"
includes="**/TEST-*.xml"
excludes="**/*pom.xml, **/build.xml"
/>
</path>
<sequential>
<var name="testsuite.name" unset="true" />
<var name="testsuite.tests" unset="true" />
<var name="testsuite.time" unset="true" />
<var name="testsuite.skipped" unset="true" />
<var name="testsuite.errors" unset="true" />
<var name="testsuite.failures" unset="true" />
<xmlproperty file="@{testresultfile}" keepRoot="true" collapseAttributes="true" />
<for param="ts" list="testsuite.skipped, testsuite.errors, testsuite.failures" delimiter=", ">
<sequential>
<propertyregex override="true"
property="ts.label"
defaultvalue="@{ts}"
input="@{ts}"
regexp="testsuite\.(.+)"
replace="\1"
/>
<if>
<isset property="@{ts}" />
<then>
<if>
<equals arg1="${@{ts}}" arg2="0" />
<then>
<var name="@{ts}" value="" />
</then>
<else>
<var name="@{ts}" value="; ${@{ts}} ${ts.label}" />
</else>
</if>
</then>
</if>
</sequential>
</for>
<if>
<or>
<not>
<equals arg1="${testsuite.skipped}" arg2="" />
</not>
<not>
<equals arg1="${testsuite.errors}" arg2="" />
</not>
<not>
<equals arg1="${testsuite.failures}" arg2="" />
</not>
</or>
<then>
<var name="test.results.errors.failures.skipped"
value="${test.results.errors.failures.skipped}${testsuite.name} ran ${testsuite.tests} tests in ${testsuite.time}s${testsuite.skipped}${testsuite.errors}${testsuite.failures}${line.separator}"
/>
</then>
</if>
<if>
<isset property="testsuite.name" />
<then>
<var name="test.results.all"
value="${test.results.all}${testsuite.name} ran ${testsuite.tests} tests in ${testsuite.time}s${testsuite.skipped}${testsuite.errors}${testsuite.failures}${line.separator}"
/>
</then>
</if>
<var name="testsuite.name" unset="true" />
<var name="testsuite.tests" unset="true" />
<var name="testsuite.time" unset="true" />
<var name="testsuite.skipped" unset="true" />
<var name="testsuite.errors" unset="true" />
<var name="testsuite.failures" unset="true" />
</sequential>
</for>
<echo level="verbose">-------------------------------------------------------
A L L T E S T R E S U L T S
-------------------------------------------------------
${test.results.all}
-------------------------------------------------------
</echo>
<if>
<and>
<isset property="test.results.errors.failures.skipped" />
<not>
<equals arg1="${test.results.errors.failures.skipped}" arg2="" />
</not>
</and>
<then>
<echo level="error">-------------------------------------------------------
T E S T R E S U L T S
-------------------------------------------------------
${test.results.errors.failures.skipped}
-------------------------------------------------------
</echo>
</then>
</if>
</target>
<!-- collect names, dates, and contained features in all generated update site zips, including the overall one -->
<target name="collect.update.site.results" depends="init">
<var name="COMPONENTS.to.check" unset="" />
<if>
<isset property="COMPONENTS.to.build" />
<then>
<var name="COMPONENTS.to.check" value="${COMPONENTS.to.build}" />
</then>
<else>
<var name="COMPONENTS.to.check" value="${COMPONENTS}" />
</else>
</if>
<if>
<and>
<not>
<equals arg1="${COMPONENTS.to.check}" arg2="." />
</not>
<not>
<contains string="${COMPONENTS.to.check}" substring=",site" />
</not>
</and>
<then>
<var name="COMPONENTS.to.check" value="${COMPONENTS.to.check},site" />
</then>
</if>
<for param="COMPONENT" list="${COMPONENTS.to.check}" delimiter=",;
">
<sequential>
<!-- rename any leftover site.zip files -->
<for param="updateZip">
<path>
<fileset dir="${WORKINGDIR}/@{COMPONENT}" includes="**/site.zip" />
</path>
<sequential>
<if>
<equals arg1="@{COMPONENT}" arg2="site" />
<then>
<var name="destinationZip"
value="${WORKINGDIR}/@{COMPONENT}/site/target/JBossTools-ALL-Update-SNAPSHOT.zip"
/>
</then>
<else>
<var name="COMPONENT.name" value="" />
<if>
<equals arg1="@{COMPONENT}" arg2="." />
<then>
<var name="COMPONENT.name" value="${product.id}" />
</then>
<else>
<var name="COMPONENT.name" value="@{COMPONENTS}" />
</else>
</if>
<var name="destinationZip"
value="${WORKINGDIR}/@{COMPONENT}/site/target/JBossTools-${COMPONENT.name}-Update-SNAPSHOT.zip"
/>
</else>
</if>
<!-- rename resulting update site zip -->
<move file="${WORKINGDIR}/@{COMPONENT}/site/target/site.zip"
tofile="${destinationZip}"
overwrite="true"
preservelastmodified="false"
/>
</sequential>
</for>
<for param="updateZip">
<path>
<fileset dir="${WORKINGDIR}/@{COMPONENT}" includes="**/JBossTools*Update*.zip" />
</path>
<sequential>
<propertyregex property="updateZip"
defaultvalue="@{updateZip}"
input="@{updateZip}"
regexp=".+/site/target/([^/]+.+\.zip)"
replace="\1"
override="true"
/>
<exec executable="unzip" outputproperty="zip.contents">
<arg line="-l @{updateZip}" />
</exec>
<if>
<and>
<isset property="zip.contents" />
<contains string="${zip.contents}" substring="plugins/" />
<contains string="${zip.contents}" substring=".jar" />
</and>
<then>
<echo level="info">@{COMPONENT} :: ${updateZip}</echo>
<for param="featureJar" list="${zip.contents}" delimiter="
">
<sequential>
<if>
<and>
<contains string="@{featureJar}" substring="features/" />
<contains string="@{featureJar}" substring=".jar" />
</and>
<then>
<echo level="info"> :: @{featureJar}</echo>
</then>
</if>
</sequential>
</for>
</then>
<else>
<echo level="warn">@{COMPONENT} :: ${updateZip}</echo>
</else>
</if>
</sequential>
</for>
<if>
<not>
<isset property="zip.contents" />
</not>
<then>
<echo level="warn">No update site found for @{COMPONENT}.</echo>
</then>
</if>
<var name="zip.contents" unset="true" />
<var name="zip.features" unset="true" />
<echo level="info">
</echo>
</sequential>
</for>
</target>
<!-- Used to build the overall update site for all components; requires a custom site.xml (generated from category.*.xml) and previously checked in pom.xml -->
<target name="create.overall.update.site" depends="init" unless="no.overall">
<if>
<isset property="no.overall" />
<then>
<echo>All components up to date: nothing to do!
To force a build of unchanged components, use -Dbuild.if.sources.unchanged=true</echo>
</then>
<else>
<property name="update.site.path" value="site" />
<!-- Fetch fresh sources (checkout or update) -->
<antcall target="get.sources">
<param name="COMPONENT" value="site" />
</antcall>
<!-- Get correct version of site.xml + resolve variables -->
<loadfile property="site.xml.transformed"
srcfile="${WORKINGDIR}/${update.site.path}/category.${product.id}.xml"
>
<filterchain>
<expandproperties />
</filterchain>
</loadfile>
<echo file="${WORKINGDIR}/${update.site.path}/site.xml" message="${site.xml.transformed}" />
<var name="site.xml.transformed" unset="true" />
<!-- Build update site -->
<antcall target="build.update.site">
<param name="COMPONENTS.to.build" value="site" />
<param name="update.site.path" value="${update.site.path}" />
</antcall>
<!-- Copy overall site into workspace so it can be archived by Hudson -->
<if>