Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1b519980857f73ad1fe99c9f00eb0d32c5b0252f (plain) (blame)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
<project
  name="runTests2"
  default="runTests2"
  basedir=".">

  <target
    name="init"
    depends="initWorkspace, initDownloadHosts, initBuildId, initBuildType, initBasicDirectories, initStreamSpecificVariables, initTargetPlatform, initPlatformSpecificProperties, initCurrentUpdateSite, initconfigure.team.cvs.test,setJavaMajorVersion"
    unless="runTest2Initialized">

    <property
      name="EOL"
      value="${line.separator}" />

    <property
      name="selectiveVerbose"
      value="false" />
    <!-- 
      If not explicitly passed in from caller, assume 'all'. This is the
      default target already, in global test.xml, but this allows us to be explicit
      (and, make sure it continues working). 
    -->
    <condition
      property="testSuite"
      value="${env.testSuite}"
      else="all">
      <isset property="env.testSuite" />
    </condition>
    <property
      name="buildURL"
      value="http://${DOWNLOAD_HOST}/eclipse/downloads/${dropsDirSegment}/${buildId}" />

    <!-- if 'baselinePerf' is specified, need to it for "buildId", plus adjust
      URL to it, not what we just built. Only "tests" always get buildURL -->
    <condition
      property="buildIdToUse"
      value="${baselinePerfVersionLabel}"
      else="${buildId}">
      <istrue value="${baselinePerf}" />
    </condition>
    <condition
      property="archiveLocation"
      value="${baselinePerfLocation}"
      else="${buildURL}">
      <istrue value="${baselinePerf}" />
    </condition>
    <property
      name="eclipse.perf.dbloc"
      value="${eclipse.perf.dbloc.value}" />
    <!-- TODO: Do we need "buildID" coded somewhere, to know WHICH build to
      match with? Or, else will take large number of "baselines" averaged? -->

    <condition
      property="eclipse.perf.config"
      value="build=${baselinePerfVersion}-${buildIdTimestamp};config=${testedPlatformConfig};jvm=${javaMajorVersion}"
      else="build=${buildId};config=${testedPlatformConfig};jvm=${javaMajorVersion}">
      <istrue value="${baselinePerf}" />
    </condition>
    <!-- This "assert" property works, in this context, because we run baseline
      first, when buildIdToUse != buildId that is a "baseline run" (so, no "assert"
      for that baseline run). But, when buildIdToUse == buildId that is a "normal
      run" so then we do want to "assert" against the already-collected baseline
      data. Note: Note, docs say order does not matter, and could specify "just
      build" and reset filled in with what's in 'config', but some experiences
      makes me doubt that? TODO: design problem: how to distinguish assert against
      baseline vs. baseline alt. -->
    <condition
      property="eclipse.perf.assertAgainst"
      value="build=${baselinePerfVersion}-${buildIdTimestamp};config=${testedPlatformConfig};jvm=${javaMajorVersion};">
      <equals
        arg1="${buildIdToUse}"
        arg2="${buildId}" />
    </condition>
    <!-- frameworkperfargs is used by library.xml ... probably an easier way? -->
    <condition
      property="frameworkperfargs"
      value="-Declipse.perf.dbloc=${eclipse.perf.dbloc} -Declipse.perf.config=${eclipse.perf.config} -Declipse.perf.assertAgainst=${eclipse.perf.assertAgainst}"
      else="-Declipse.perf.dbloc=${eclipse.perf.dbloc} -Declipse.perf.config=${eclipse.perf.config}">
      <isset property="eclipse.perf.assertAgainst" />
    </condition>
    <echo message="setRuntimeArchive os ${os} ws ${ws} arch ${arch}" />
    <echo message="build id of runtimeArchive ${buildIdToUse}" />

    <echo message="Variables in 'runTests2.xml'" />
    <echo message="DOWNLOAD_HOST: ${DOWNLOAD_HOST}" />
    <echo message="WORKSPACE: ${WORKSPACE}" />
    <echo message="buildId: ${buildId}" />
    <echo message="buildIdToUse: ${buildIdToUse}" />
    <echo message="relengBaseBuilderDir: ${relengBaseBuilderDir}" />
    <echo message="configurationDir: ${configurationDir}" />
    <echo message="java.home: ${java.home}" />
    <echo message="eclipseStream: ${eclipseStream}" />
    <echo message="eclipseStreamMajor: ${eclipseStreamMajor}" />
    <echo message="eclipseStreamMinor: ${eclipseStreamMinor}" />
    <echo message="eclipseStreamService: ${eclipseStreamService}" />
    <echo message="buildType: ${buildType}" />
    <echo message="testSuite: ${testSuite}" />


    <!-- there's nothing "automatic" about the local cache (so far). If specified
      (such as on Hudson command line that executes this file, as, say, -DlocalCache=file:///shared/eclipse/localCache
      then all the downloads required must be already available there. It is intended
      to speed up local testing to avoid re-downloading files. -->
    <!-- currently, following is dead code. Leaving for now as a reminder to
      allow localCache again, someday -->
    <condition
      property="archiveLocation"
      value="${localCache}"
      else="${buildURL}">
      <isset property="localCache" />
    </condition>

    <echo message="buildURL ${buildURL}" />
    <echo message="archiveLocation ${archiveLocation}" />
    <property
      name="runTest2Initialized"
      value="true" />

  </target>

  <target
    name="getPlatformIndependentZips"
    depends="init"
    unless="skipInstall">

    <get
      retries="5"
      verbose="${selectiveVerbose}"
      src="${archiveLocation}/eclipse-Automated-Tests-${buildIdToUse}.zip"
      dest="${testDir}/eclipse-Automated-Tests-${buildIdToUse}.zip" />

  </target>

  <target
    name="getwinzips"
    depends="init, getPlatformIndependentZips"
    unless="skipInstall">
    <get
      verbose="${selectiveVerbose}"
      src="${archiveLocation}/eclipse-SDK-${buildIdToUse}-win32.zip"
      dest="${executionDir}/eclipse-SDK-${buildIdToUse}-win32.zip" />
    <get
      verbose="${selectiveVerbose}"
      src="${archiveLocation}/eclipse-platform-${buildIdToUse}-win32.zip"
      dest="${executionDir}/eclipse-platform-${buildIdToUse}-win32.zip" />
    <get
      verbose="${selectiveVerbose}"
      src="${previousReleaseLocation}/eclipse-platform-${previousReleaseVersion}-win32.zip"
      dest="${platformLocation}/eclipse-platform-${previousReleaseVersion}-win32.zip" />
  </target>
  <target
    name="getwinzips64"
    depends="init, getPlatformIndependentZips"
    unless="skipInstall">
    <get
      verbose="${selectiveVerbose}"
      src="${archiveLocation}/eclipse-SDK-${buildIdToUse}-win32-x86_64.zip"
      dest="${executionDir}/eclipse-SDK-${buildIdToUse}-win32-x86_64.zip" />
    <get
      verbose="${selectiveVerbose}"
      src="${archiveLocation}/eclipse-platform-${buildIdToUse}-win32-x86_64.zip"
      dest="${executionDir}/eclipse-platform-${buildIdToUse}-win32-x86_64.zip" />
    <get
      verbose="${selectiveVerbose}"
      src="${previousReleaseLocation}/eclipse-platform-${previousReleaseVersion}-win32-x86_64.zip"
      dest="${platformLocation}/eclipse-platform-${previousReleaseVersion}-win32-x86_64.zip" />
  </target>
  <target
    name="getlinzips"
    depends="init, getPlatformIndependentZips"
    unless="skipInstall">
    <get
      verbose="${selectiveVerbose}"
      src="${archiveLocation}/eclipse-SDK-${buildIdToUse}-linux-gtk-x86_64.tar.gz"
      dest="${executionDir}/eclipse-SDK-${buildIdToUse}-linux-gtk-x86_64.tar.gz" />
    <get
      verbose="${selectiveVerbose}"
      src="${archiveLocation}/eclipse-platform-${buildIdToUse}-linux-gtk-x86_64.tar.gz"
      dest="${executionDir}/eclipse-platform-${buildIdToUse}-linux-gtk-x86_64.tar.gz" />
    <get
      verbose="${selectiveVerbose}"
      src="${previousReleaseLocation}/eclipse-platform-${previousReleaseVersion}-linux-gtk-x86_64.tar.gz"
      dest="${platformLocation}/eclipse-platform-${previousReleaseVersion}-linux-gtk-x86_64.tar.gz" />
  </target>

  <target
    name="getlinzips32"
    depends="init, getPlatformIndependentZips"
    unless="skipInstall">
    <get
      verbose="${selectiveVerbose}"
      src="${archiveLocation}/eclipse-SDK-${buildIdToUse}-linux-gtk.tar.gz"
      dest="${executionDir}/eclipse-SDK-${buildIdToUse}-linux-gtk.tar.gz" />
    <get
      verbose="${selectiveVerbose}"
      src="${archiveLocation}/eclipse-platform-${buildIdToUse}-linux-gtk.tar.gz"
      dest="${executionDir}/eclipse-platform-${buildIdToUse}-linux-gtk.tar.gz" />
    <get
      verbose="${selectiveVerbose}"
      src="${previousReleaseLocation}/eclipse-platform-${previousReleaseVersion}-linux-gtk.tar.gz"
      dest="${platformLocation}/eclipse-platform-${previousReleaseVersion}-linux-gtk.tar.gz" />
  </target>

  <target
    name="getmacosx"
    depends="init, getPlatformIndependentZips"
    unless="skipInstall">
    <get
      verbose="${selectiveVerbose}"
      src="${archiveLocation}/eclipse-SDK-${buildIdToUse}-macosx-cocoa-x86_64.tar.gz"
      dest="${executionDir}/eclipse-SDK-${buildIdToUse}-macosx-cocoa-x86_64.tar.gz" />
    <get
      verbose="${selectiveVerbose}"
      src="${archiveLocation}/eclipse-platform-${buildIdToUse}-macosx-cocoa-x86_64.tar.gz"
      dest="${executionDir}/eclipse-platform-${buildIdToUse}-macosx-cocoa-x86_64.tar.gz" />
    <get
      verbose="${selectiveVerbose}"
      src="${previousReleaseLocation}/eclipse-platform-${previousReleaseVersion}-macosx-cocoa-x86_64.tar.gz"
      dest="${platformLocation}/eclipse-platform-${previousReleaseVersion}-macosx-cocoa-x86_64.tar.gz" />
  </target>

  <target
    name="initconfigure.team.cvs.test"
    depends="computeExpectedLocation,getcvstestProperties" />

  <target name="computeExpectedLocation">
    <condition
      property="cvstest.properties"
      value="/shared/eclipse/buildtests/cvstest.properties">
      <and>
        <os family="unix" />
        <not>
          <os family="mac" />
        </not>
      </and>
    </condition>
    <condition
      property="cvstest.properties"
      value="c:\users\hudsonbuild\cvstest.properties">
      <os family="windows" />
    </condition>
    <condition
      property="cvstest.properties"
      value="/Users/hudsonbuild/cvstest.properties">
      <os family="mac" />
    </condition>
  </target>

  <target
    name="getcvstestProperties"
    if="cvsPropertiesAvailable"
    depends="computeExpectedLocation,checkCVSPropExists,logNoExistence"
    unless="cvstestPropertiesInitialized">

    <echo message="cvstest.properties file: ${cvstest.properties}" />
    <property file="${cvstest.properties}" />
    <property
      name="cvstestPropertiesInitialized"
      value="true" />

  </target>

  <target
    name="checkCVSPropExists"
    depends="computeExpectedLocation">
    <condition property="cvsPropertiesAvailable">
      <available file="${cvstest.properties}" />
    </condition>
  </target>
  <target
    name="logNoExistence"
    depends="checkCVSPropExists"
    unless="cvsPropertiesAvailable">
    <echo message="cvs properties file was not found in this environment. " />
    <echo message="   expected file: ${cvstest.properties} " />
  </target>

  <target
    name="initTargetPlatform"
    unless="testPlatform">
    <condition
      property="testPlatform"
      value="linuxjava9">
      <and>
        <equals
          arg1="${osgi.os}"
          arg2="linux" />
        <equals
          arg1="${osgi.ws}"
          arg2="gtk" />
        <equals
          arg1="${osgi.arch}"
          arg2="x86_64" />
        <equals
          arg1="${jvm.version}"
          arg2="java9" />
      </and>
    </condition>
    <condition
      property="testPlatform"
      value="win7-64">
      <and>
        <equals
          arg1="${osgi.os}"
          arg2="win32" />
        <equals
          arg1="${osgi.ws}"
          arg2="win32" />
        <equals
          arg1="${osgi.arch}"
          arg2="x86_64" />
      </and>
    </condition>
    <condition
      property="testPlatform"
      value="win7">
      <and>
        <equals
          arg1="${osgi.os}"
          arg2="win32" />
        <equals
          arg1="${osgi.ws}"
          arg2="win32" />
        <equals
          arg1="${osgi.arch}"
          arg2="x86" />
      </and>
    </condition>

    <condition
      property="testPlatform"
      value="linux">
      <and>
        <equals
          arg1="${osgi.os}"
          arg2="linux" />
        <equals
          arg1="${osgi.ws}"
          arg2="gtk" />
        <equals
          arg1="${osgi.arch}"
          arg2="x86_64" />
      </and>
    </condition>
    <condition
      property="testPlatform"
      value="linux32">
      <and>
        <equals
          arg1="${osgi.os}"
          arg2="linux" />
        <equals
          arg1="${osgi.ws}"
          arg2="gtk" />
        <equals
          arg1="${osgi.arch}"
          arg2="x86" />
      </and>
    </condition>
    <condition
      property="testPlatform"
      value="macosx">
      <and>
        <equals
          arg1="${osgi.os}"
          arg2="macosx" />
        <equals
          arg1="${osgi.ws}"
          arg2="cocoa" />
        <equals
          arg1="${osgi.arch}"
          arg2="x86_64" />
      </and>
    </condition>
    <condition
      property="testPlatform"
      value="macmini">
      <and>
        <equals
          arg1="${osgi.os}"
          arg2="macosx" />
        <equals
          arg1="${osgi.ws}"
          arg2="cocoa" />
        <equals
          arg1="${osgi.arch}"
          arg2="x86" />
      </and>
    </condition>
    <echo message="[DEBUG] in runTest2.xml: os ws arch ${osgi.os} ${osgi.ws} ${osgi.arch}" />
    <echo message="[INFO] in runTest2.xml: testPlatform  ${testPlatform}" />
  </target>

  <!-- Note that in getting the target platform, we nearly always get the
    'buildId' version, the one we just built. But, in some cases, we use "baselinePerf"
    version for performance regression testing. In that case, we still get the
    "buildId" version of tests ... the ones we just built ... only what we run
    them on changes. When we do use 'baselinePerf', that is specified as 'true'
    in Hudson job, which signals to use the baselinePerf version defined in 'streamSpecific.properties. -->
  <target
    name="downloadTargetPlatform"
    depends="init">
    <!-- TODO: should add checks for checksum integrity on downloads. Perhaps
      use mirror URLs? (though, that'd not effect production) -->
    <fail
      unless="testPlatform"
      message="testPlatform did not match any of the supported combinations of osgi.os, osgi.ws, osgi.arch" />
    <condition
      property="getArtifacts"
      value="getwinzips">
      <equals
        arg1="${testPlatform}"
        arg2="win7" />
    </condition>
    <condition
      property="getArtifacts"
      value="getwinzips64">
      <equals
        arg1="${testPlatform}"
        arg2="win7-64" />
    </condition>
    <condition
      property="getArtifacts"
      value="getlinzips">
      <equals
        arg1="${testPlatform}"
        arg2="linux" />
    </condition>
    <condition
      property="getArtifacts"
      value="getlinzips">
      <equals
        arg1="${testPlatform}"
        arg2="linuxjava9" />
    </condition>
    <condition
      property="getArtifacts"
      value="getlinzips32">
      <equals
        arg1="${testPlatform}"
        arg2="linux32" />
    </condition>

    <condition
      property="getArtifacts"
      value="getmacosx">
      <equals
        arg1="${testPlatform}"
        arg2="macosx" />
    </condition>
    <echo message="getArtifacts ${getArtifacts}" />
    <antcall target="${getArtifacts}" />

  </target>

  <target name="initConfigurationDir">
    <property
      name="configurationDir"
      value="${WORKSPACE}/eclipse.platform.releng.aggregator/production/testScripts/configuration" />
  </target>

  <target
    name="initPlatformSpecificProperties"
    depends="initTargetPlatform, initConfigurationDir"
    unless="platformSpecificPropertiesInitialized">
    <property
      name="platformSpecificProperties"
      value="${configurationDir}/sdk.tests/testConfigs/${testPlatform}/platformSpecific.properties" />
    <loadproperties>
      <file file="${platformSpecificProperties}" />
    </loadproperties>
    
    <property
      name="platformSpecificPropertiesInitialized"
      value="true" />
  </target>

  <target
    name="runTests2"
    depends="init, initConfigurationDir, downloadTargetPlatform">

    <copy
      todir="${executionDir}"
      verbose="true">
      <fileset dir="${configurationDir}/sdk.tests/testConfigs/${testPlatform}" />
    </copy>
    <copy
      verbose="true"
      todir="${executionDir}"
      overwrite="true">
      <fileset dir="${configurationDir}/sdk.tests/testScripts" />
    </copy>

    <echoproperties
      description="Echo all properties in runTest2 after all is initialized, shortly before tests are ran."
      destfile="${WORKSPACE}/propertiesAllFromRunTest2.properties" />

    <!-- TODO: seems this unzip could/should be moved to test.xml? To do once
      only, of course, if not already done. We (sort of) do in test.xml. See its
      setupRepo task. -->
    <property
      name="repoZip"
      value="${executionDir}/eclipse-junit-tests-${buildIdToUse}.zip" />
    <echo message="repoZip: ${repoZip}" />
    <antcall target="unzipTestFramework" />

    <!-- We print these properties to a file primarily to capture variables
      that might have been set in Hudson, which do not "survive" going through
      the bat or script files. ... Though, makes me wonder if we really need to
      do that? Seems we could call test.xml directly? In principle, we could call
      printProperty from anywhere, but seems best to centralize the function. -->
    <antcall target="printProductionProperties" />

    <!-- The PHP properties are useful to display (directly or indirectly)
      on "test results" page (such as "testPlatform" headings). -->
    <antcall target="printMainPropertiesAsPHP" />

    <!-- following are all required by "runtests" ... used to be part of it,
      but wanted these variables to print out, even if merely testing scripts,
      but not actually running tests. -->
    <condition
      property="executionArguments"
      value="/c ${testScript}">
      <and>
        <os family="windows" />
      </and>
    </condition>
    <property
      name="executionArguments"
      value="${testScript}" />

    <echo message="=== properties in runTests2, for runTests executable:" />
    <echo message="  = properties used in exec task:" />
    <echo message="      executionDir ${executionDir}" />
    <echo message="      testExecutable ${testExecutable}" />
    <echo message="      testScript ${testScript}" />
    <echo message="      executionArguments ${executionArguments}" />
    <echo message="  = properties set as env variables:" />
    <echo message="      propertiesFile: ${WORKSPACE}/production.properties" />
    <echo message="      jvm: ${jvm}" />
    <echo message="      testedPlatform: ${testedPlatform}" />
    <echo message="      testedPlatformConfig: ${testedPlatformConfig}" />

    <antcall target="runtests" />

  </target>

  <target
    name="printProductionProperties"
    depends="init">
    <!-- here we want to print properties, such as passed in via Hudson, that
      can be used later, by test.xml, but since it is started by as separate processes,
      there is no direct access to Hudson properties ... so we make them persistent.
      In many cases, the property will not be defined, in which case we do not
      want to write anything for that property (or, it will appear to have been
      set, even if set to an empty string). -->

    <printProperty property="buildId" />
    <printProperty property="buildIdToUse" />
    <printProperty property="buildType" />
    <printProperty property="eclipseStream" />
    <printProperty property="previousReleaseVersion" />
    <printProperty property="previousReleaseVersionRepo" />
    <printProperty property="baselinePerf" />
    <printProperty property="osgi.os" />
    <printProperty property="osgi.ws" />
    <printProperty property="osgi.arch" />
    <printProperty property="DOWNLOAD_HOST" />
    <printProperty property="ARCHIVE_HOST" />
    <printProperty property="executionDir" />
    <printProperty property="install" />
    <printProperty property="eclipse-home" />
    <printProperty property="isMacAppLayout" />
    <printProperty property="configurationDir" />
    <printProperty property="org.eclipse.core.net.prefs" />
    <printProperty property="testSuite" />
    <printProperty property="skipDerby" />
    <printProperty property="test.target" />
    <printProperty property="testExecutable" />
    <printProperty property="testScript" />
    <printProperty property="jvm" />
    <printProperty property="javaversionEscaped" />
    <printProperty property="javaMajorVersion" />
    <printProperty property="testedPlatform" />
    <printProperty property="testedPlatformConfig" />
    <printProperty property="eclipse.perf.dbloc" />
    <printProperty property="eclipse.perf.config" />
    <printProperty property="eclipse.perf.assertAgainst" />
    <printProperty property="currentUpdateSite" />

    <!-- The following will leave pw in file, which is not a lot different
      that leave them printed in log, as we also do. But, could be improved by
      just leaving filename in properties, and reading them in at the time needed
      in test.xml. -->
    <printProperty property="cvstest.properties" />
  </target>

  <target
    name="initStreamSpecificProperties"
    depends="initConfigurationDir"
    unless="streamSpecificPropertiesSet">
    <property file="${configurationDir}/streamSpecific.properties" />
    <property
      name="streamSpecificPropertiesSet"
      value="true" />
  </target>
  <target
    name="initCurrentUpdateSite"
    depends="initDownloadHosts, initStreamVariables, initBuildId, initBuildType"
    unless="currentUpdateSite">
    <property
      name="currentUpdateSite"
      value="http://${DOWNLOAD_HOST}/eclipse/updates/${updateSiteSegment}-${buildType}-builds/${buildId}" />
  </target>
  <target
    name="checkInstallDir"
    if="install">
    <echo message="[DEBUG] in test.xml: Found the value of install already set, to ${install}" />
  </target>

  <target
    name="initInstallDir"
    depends="initBuildId, initStreamSpecificProperties, checkInstallDir"
    unless="install">
    <property
      name="testDir"
      value="${WORKSPACE}/workarea/${buildId}" />
    <echo message="[DEBUG] in runTests2.xml: testDir: ${testDir}" />

    <property
      name="executionDir"
      value="${testDir}/eclipse-testing" />
    <mkdir dir="${executionDir}" />
    <echo message="[DEBUG] in runTests2.xml: executionDir: ${executionDir}" />

    <!--default directory where test-eclipse-sdk will be installed -->
    <property
      name="install"
      value="${executionDir}/test-eclipse" />
    <mkdir dir="${install}" />
    <echo message="[DEBUG] in runTests2.xml: the value of install was set to: ${install}" />
  </target>


  <!-- eclipse-home set to be the folder that will later contain the plugins
    folder. Note: we have to set eclipse-home, rather than use "eclpse.home"
    or "eclipse.home.location" because at this point we are executing from the
    "setup" version of eclipse (aka basebuilder) not the actual version of eclipse
    we will later be testing. -->
  <target
    name="initEclipseHome"
    depends="initStreamSpecificProperties, initInstallDir, checkEclipseHome"
    unless="eclipse-home">

    <condition
      property="eclipse-home"
      value="${install}/Eclipse.app/Contents/Eclipse"
      else="${install}/eclipse">
      <and>
        <os family="mac" />
        <istrue value="${isMacAppLayout}" />
      </and>
    </condition>
    <echo message="[DEBUG] in runTest2.xml the value of eclipse-home was set to: ${eclipse-home}" />
  </target>
  <!-- Intended to be called only from initEclipseHome, simply as extra information
    for debugging -->
  <target
    name="checkEclipseHome"
    if="eclipse-home">
    <echo message="[DEBUG] Found the value of eclipse-home already set, to ${eclipse-home}" />
  </target>

  <macrodef name="printProperty">
    <!-- the use of properyfile and local require at least Ant 1.8 -->
    <attribute name="property" />
    <sequential>
      <echo message="DEBUG @{property}: ${@{property}}" />
      <!-- for our use, 'del' operation won't typically delete anything, since
        would not have been there to begin with, but is an easy way to prevent an
        undefined property from being written -->
      <local name="oper" />
      <condition
        property="oper"
        value="="
        else="del">
        <isset property="@{property}" />
      </condition>
      <propertyfile file="${WORKSPACE}/production.properties">
        <entry
          key="@{property}"
          value="${@{property}}"
          operation="${oper}" />
      </propertyfile>
    </sequential>
  </macrodef>


  <!-- This initStreamSpecificVariables target was copied from buildAll.xml
    and does about exactly the same thing, purposely left close to original,
    though not as much is actually required. TODO: in future, pull out into one
    file, and reuse You can tell from comment, it is out dated. Its purpose,
    here, is entirely to pick up "stream specific" stings from the releng maps
    project, 'configuration' folder. Important note: here, unlike the one in
    buildAll.xml, we assume the maps have already been checked out, say by Hudson,
    as a peer of eclipseBuilder, rather then us doing the checkout here, ourselves.
    Not sure which is easier, but current means Hudson job has to be set up with
    two git checkout steps, right version for maps (for 3.8 vs 4.2). -->
  <target
    name="initStreamSpecificVariables"
    unless="initStreamSpecificVariablesComplete"
    depends="initWorkspace,initBuildType,initConfigurationDir,initStreamVariables,initDownloadHosts">
    <echo message="DEBUG: executing initStreamSpecificVariables" />

    <!-- these conditions used to be in "init". Conceptually seems right to
      be in "stream specific" init (since their value depends on stream) but may
      have side effects?). This is really no longer relevant, as everything we
      build/tests comes from "drops4" ... but will leave in case we ever have a
      "drops5" ... or, have to back port tests to re-test 3.8! (Which, we probably
      do, for 3.8?) -->
    <condition
      property="dropsDirSegment"
      value="drops4"
      else="drops">
      <equals
        arg1="${eclipseStreamMajor}"
        arg2="4" />
    </condition>

    <loadproperties srcFile="${configurationDir}/streamSpecific.properties" />

    <!-- echo a few typically expected properties, to make sure getting right
      file -->

    <echo message="streamSpecificPropertiesTitle: ${streamSpecificPropertiesTitle}" />

    <echo message="previousReleaseLocation: ${previousReleaseLocation}" />
    <echo message="previousReleaseVersion: ${previousReleaseVersion}" />
    <echo message="previousReleaseVersionRepo: ${previousReleaseVersionRepo}" />

    <property
      name="initStreamSpecificVariablesComplete"
      value="true" />
  </target>

  <!-- DOWNLOAD_HOST and ARCHIVE_HOST can be defined on command line, if running
    on local test environments. -->
  <target
    name="initDownloadHosts"
    unless="DOWNLOAD_HOST">
    <!-- we assume if "DOWNLOAD_HOST" is defined, then ARCHIVE_HOST has been
      defined also. -->
    <property environment="env" />
    <echo message="DEBUG: Found DOWNLOAD_HOST not defined. Setting in 'initDownloadHosts'" />
    <echo message="DEBUG:      env.DOWNLOAD_HOST: ${env.DOWNLOAD_HOST}" />
    <condition
      property="DOWNLOAD_HOST"
      value="${env.DOWNLOAD_HOST}"
      else="download.eclipse.org">
      <isset property="env.DOWNLOAD_HOST" />
    </condition>
    <condition
      property="ARCHIVE_HOST"
      value="${env.ARCHIVE_HOST}"
      else="archive.eclipse.org">
      <isset property="env.ARCHIVE_HOST" />
    </condition>
  </target>

  <target
    name="initWorkspace"
    unless="WORKSPACE">
    <property environment="env" />
    <condition
      property="WORKSPACE"
      value="${env.WORKSPACE}"
      else="${basedir}">
      <isset property="env.WORKSPACE" />
    </condition>
  </target>


  <target
    name="initBuildId"
    unless="buildId">
    <!--property file that can contain the buildId, if not otherwise set -->
    <property file="label.properties" />
    <fail
      unless="buildId"
      message="buildId (e.g I20140731-0800) needs to be provided to run the tests" />
  </target>

  <target name="initBuildType">

    <fail
      unless="buildId"
      message="buildId value must be provided by caller (such as 'I20120717-0800'" />
    <!-- this "buildId check" may be overly strict, but best to start off strict
      for now, loosen in future if we start to find/have variety -->
    <condition property="buildIdOK">
      <matches
        pattern="^[IMXYNPSR]\d{8}-\d{4}$"
        string="${buildId}" />
    </condition>
    <fail
      message="buildId variable had unexpected format. Should be of the form  [IMXYNPSR] 8 digits '-' 4 digits, but was ${buildId}"
      unless="buildIdOK" />

    <script language="javascript">
      <![CDATA[
      var buildId = project.getProperty("buildId");
      var pattern = new RegExp(/^([IMXYNPSR])(\d{8})-(\d{4})$/);

      var sArray = pattern.exec(buildId);
      // sArray 0 is "whole match"
      project.setProperty("buildType", sArray[1]);
      project.setProperty("buildIdTimestamp",sArray[2]+sArray[3]);
      ]]>
    </script>


    <fail unless="buildType" />
  </target>
  <!-- main purpose of initStreamVariables, it to be sure we have eclipseStreamMajor
    and eclipseStreamMinor Uses script, which requires Java 1.6 (or ... else
    gets complicated to setup) -->
  <target
    name="initStreamVariables"
    depends="initConfigurationDir"
    unless="streamVariablesInitialized">
    <property file="${configurationDir}/streamSpecific.properties" />
    <fail
      unless="eclipseStream"
      message="eclipseStream value must be provided by caller, such as '4.3' or '4.4.2." />
    <condition property="streamOK">
      <matches
        pattern="\d\.\d(\.\d)?"
        string="${eclipseStream}" />
    </condition>
    <fail
      message="eclipseStream variable had unexpected format. Should be of form digit.digit[.digit], but was ${eclipseStream}"
      unless="streamOK" />

    <script language="javascript">
      <![CDATA[
      var eclipseStream = project.getProperty("eclipseStream");
      var pattern = new
      RegExp(/(\d+)\.(\d+)(\.(\d+))?/);
      var sArray = pattern.exec(eclipseStream);
      // sArray[0] is "whole match"
      project.setProperty("eclipseStreamMajor", sArray[1]);
      project.setProperty("eclipseStreamMinor", sArray[2]);
      // zero based: index 3 is 4th item, etc, and we have digit only in a nested group (due to optional)
      if (sArray.length > 4) {
         project.setProperty("eclipseStreamService", sArray[4]);
      }
      project.setProperty("updateSiteSegment", sArray[1] + "." + sArray[2]);
      ]]>
    </script>

    <fail
      unless="eclipseStreamMajor"
      message="eclipseStreamMajor not defined or computable" />
    <fail
      unless="eclipseStreamMinor"
      message="eclipseStreamMinor not defined or computable" />
    <!-- eclipseStreamService may not always be defined? And we do not currently
      use it. <fail unless="eclipseStreamService" message="eclipseStreamService
      not defined or computable" /> -->
    <fail
      unless="updateSiteSegment"
      message="updateSiteSegment not defined or computable" />
    <property
      name="streamVariablesInitialized"
      value="true" />

  </target>

  <target
    name="initBasicDirectories"
    depends="initWorkspace,initBuildId, initStreamSpecificProperties,initInstallDir, initEclipseHome, initPlatformSpecificProperties, setJavaMajorVersion"
    unless="basicDirectoriesInitialized">

    <property environment="env" />

    <property
      name="repoZip"
      value="${executionDir}/eclipse-junit-tests-${buildId}.zip" />
    <echo message="repoZip: ${repoZip}" />

    <property
      name="repoLocation"
      value="${executionDir}/testRepo" />
    <echo message="repoLocation: ${repoLocation}" />


    <property
      name="platformLocation"
      value="${executionDir}/platformLocation" />
    <mkdir dir="${platformLocation}" />
    <echo message="platformLocation: ${platformLocation}" />
    
    <property
      name="testedPlatformConfig"
      value="${osgi.os}.${osgi.ws}.${osgi.arch}" />
    
    <property
      name="testedPlatform"
      value="${env.JOB_NAME}_${osgi.os}.${osgi.ws}.${osgi.arch}_${javaMajorVersion}" />

    <!-- The directory that will contain all files containing information on
      the tests that ran. -->
    <property
      name="results"
      value="${executionDir}/results" />
    <mkdir dir="${results}" />
    <mkdir dir="${results}/xml" />
    <mkdir dir="${results}/html" />
    <echo message="results: ${results}" />

    <!--Directory for JUnit report output, console log output and .log content
      for each test suite. Overrides default in org.eclipse.test/library.xml -->
    <property
      name="junit-report-output"
      value="${results}/${testedPlatform}" />
    <mkdir dir="${junit-report-output}" />
    <echo message="junit-report-output: ${junit-report-output}" />

    <property
      name="directorLogs"
      value="${results}/${testedPlatform}/directorLogs" />
    <mkdir dir="${directorLogs}" />
    <echo message="directorLogs: ${directorLogs}" />

    <!-- this directory, with some sort files are created during unit tests
      ... need to find where to disable/enable JaCoCo -->
    <property
      name="coverage-output"
      value="${results}/coverageIGNORE" />

    <property
      name="basicDirectoriesInitialized"
      value="true" />
    <echo message="basicDirectoriesInitialized" />
  </target>
  <!-- This task unzips the test framework that was built. It includes misc.
    files, the Test Framework proper, and a zipped up repo of the unit tests.
    We also do this in "testAll" scripts ...? TODO: investigate how to avoid
    doing there, if already done. -->
  <target name="unzipTestFramework">
    <fail unless="testDir" />
    <fail unless="buildId" />

    <property
      name="testResults"
      value="${testDir}/testresults" />
    <property
      name="testFramework"
      value="${testDir}/eclipse-Automated-Tests-${buildId}.zip" />

    <condition property="testFrameworkExists">
      <available file="${testFramework}" />
    </condition>
    <fail unless="testFrameworkExists" />

    <echo message="testFramework: ${testFramework}" />
    <echo message="testDir: ${testDir}" />
    <echo message="testResults: ${testResults}" />

    <!--set up testing directory -->
    <unzip
      src="${testFramework}"
      dest="${testDir}"
      overwrite="false">
      <patternset>
        <exclude name="**/equinoxp2tests.properties" />
        <exclude name="**/test.xml" />
      </patternset>
    </unzip>
  </target>

  <target
    name="runtests"
    depends="init"
    unless="env.TESTING_TEST_XML">

    <!--run the tests -->
    <exec
      dir="${executionDir}"
      executable="${testExecutable}">
      <arg line="${executionArguments}" />
      <arg value="${testSuite}" />
      <env
        key="propertyFile"
        file="${WORKSPACE}/production.properties" />
      <env
        key="jvm"
        file="${jvm}" />
      <env
        key="testedPlatform"
        value="${testedPlatform}" />
    </exec>
  </target>

  <!-- Prints properties in "PHP form" to use on test results summary, to
    be sure accurate and meaningful. -->
  <target
    name="printMainPropertiesAsPHP"
    depends="init"
    unless="printedMainPHPProperties">

    <property
      name="EOL"
      value="${line.separator}" />


    <property
      name="phpPropertyFile"
      value="${junit-report-output}/testProperties.php" />

    <!-- on first write to php file, don't append -->
    <echo
      message="&lt;?php${EOL}"
      append="false"
      file="${phpPropertyFile}" />
    <escapeProperty property="ant.version" />
    <printPHPProperty
      phpvar="ANT_VERSION"
      value="ant.versionEscaped" />
    <printPHPProperty
      phpvar="ANT_JAVA_VERSION"
      value="ant.java.versionEscaped" />
    <printPHPProperty
      phpvar="INVOKED_JAVA_VERSION"
      value="javaversionEscaped" />
    <!-- Note: there might be times, the java.runtime.version at this point
      in time, may not be quite right ... such as if invoked with some other VM
      with the intent of using 'jvm' on "eclipse" command line ... which we currently
      do not do. -->
    <printPHPProperty
      phpvar="JAVA_VERSION"
      value="java.version" />
    <printPHPProperty
      phpvar="JAVA_MAJOR_VERSION"
      value="javaMajorVersion" />
    <printPHPProperty
      phpvar="JAVA_RUNTIME_VERSION"
      value="java.runtime.version" />
    <printPHPProperty
      phpvar="JAVA_VM_INFO"
      value="java.vm.info" />
    <printPHPProperty
      phpvar="JAVA_SPECIFICATION_VERSION"
      value="java.specification.version" />
    <printPHPProperty
      phpvar="JAVA_VENDOR"
      value="java.vendor" />
    <printPHPProperty
      phpvar="OSGI_OS"
      value="osgi.os" />
    <printPHPProperty
      phpvar="OSGI_WS"
      value="osgi.ws" />
    <printPHPProperty
      phpvar="OSGI_ARCH"
      value="osgi.arch" />
    <!-- NODE_NAME will be empty string, if on master -->
    <condition
      property="hudsonSlave"
      value="master">
      <or>
        <not>
          <isset property="env.NODE_NAME" />
        </not>
        <equals
          arg1="${env.NODE_NAME}"
          arg2="" />
        <equals
          arg1="${env.NODE_NAME}"
          arg2=" " />
      </or>
    </condition>
    <!-- if not set above, we'll set to the non blank NODE_NAME -->
    <property
      name="hudsonSlave"
      value="${env.NODE_NAME}" />

    <printPHPProperty
      phpvar="HUDSON_NODE_NAME"
      value="hudsonSlave" />
    <!-- I believe all (common) platforms have env variable for HOSTNAME. If
      not, user might want to set/export to be meaningful. (Surprisingly, it doesn't
      seem obvious that Hudson makes this available in its process environment). -->
    <printPHPProperty
      phpvar="HOSTNAME"
      value="env.HOSTNAME" />
    <printPHPProperty
      phpvar="HUDSON_JOB_NAME"
      value="env.JOB_NAME" />
    <printPHPProperty
      phpvar="HUDSON_BUILD_NUMBER"
      value="env.BUILD_NUMBER" />
    <printPHPProperty
      phpvar="HUDSON_BUILD_URL"
      value="env.BUILD_URL" />
    <!-- With HUDSON_URL and WORKSPACE_PATH should be able to figure out URL
      to WORKSPACE, though only temporarily available (until next job is ran). -->
    <printPHPProperty
      phpvar="HUDSON_URL"
      value="env.HUDSON_URL" />
    <printPHPProperty
      phpvar="HUDSON_WORKSPACE"
      value="env.WORKSPACE" />
    <printPHPProperty
      phpvar="TESTED_RUNTIME_ID"
      value="buildIdToUse" />
    <printPHPProperty
      phpvar="TEST_TARGET"
      value="test.target" />
    <printPHPProperty
      phpvar="ECLIPSE_PERF_DBLOC"
      value="eclipse.perf.dbloc" />

    <printPHPProperty
      phpvar="ECLIPSE_PERF_CONFIG"
      value="eclipse.perf.config" />
    <printPHPProperty
      phpvar="ECLIPSE_PERF_ASSERTAGAINST"
      value="eclipse.perf.assertAgainst" />

    <!-- We end with an empty line, but it is recommended to not end included
      PHP files with "end PHP" marker. -->
    <echo
      message="${EOL}"
      append="true"
      file="${phpPropertyFile}" />

    <!-- set property so we only print these variables once -->
    <property
      name="printedMainPHPProperties"
      value="true" />

  </target>
  <target
    name="setJVMProperties"
    depends="initPlatformSpecificProperties,setJVMfromUserSpecified"
    unless="jvm">
    <property
      name="VMSource"
      value="VM used for tests, is same that invoked Ant: '${java.home}/bin/java' (that is, 'jvm' not specified by caller)." />
    <echo message="VMSource: ${VMSource}" />
    <!-- Remember, we don't want J2SE-X.0 set at all, if there is nothing that
      can run tests that require that level. -->
    <property
      name="jvm"
      value="${java.home}/bin/java" />

    <exec
      executable="${jvm}"
      outputproperty="javaversion">
      <arg line="-version" />
    </exec>
    <echo message="full output from 'java -version' of ${jvm} is " />
    <echo message="${javaversion}" />
    <escapeProperty property="javaversion" />
    <echo message="full output from 'java -version' of ${jvm} is " />
    <echo message="${javaversionEscaped}" />

    <!--enable tests requiring 1.5 or or greater vms to run if running vm level
      detected matches required execution environment -->
    <condition
      property="J2SE-8.0"
      value="${jvm}">
      <matches
        string="${javaversionEscaped}"
        pattern='^.*java version .*1\.[8]' />
    </condition>
    <condition
      property="J2SE-7.0"
      value="${jvm}">
      <matches
        string="${javaversionEscaped}"
        pattern='^.*java version .*1\.[78]' />
    </condition>
    <condition
      property="J2SE-6.0"
      value="${jvm}">
      <matches
        string="${javaversionEscaped}"
        pattern='^.*java version .*1\.[678]' />
    </condition>
    <condition
      property="J2SE-5.0"
      value="${jvm}">
      <matches
        string="${javaversionEscaped}"
        pattern='^.*java version .*1\.[5678]' />
    </condition>
    <echo
      level="info"
      message="DEBUG: values from setJVMfromUserSpecified" />
    <echo message="J2SE-8.0:  ${J2SE-8.0}" />
    <echo message="J2SE-7.0:  ${J2SE-7.0}" />
    <echo message="J2SE-6.0:  ${J2SE-6.0}" />
    <echo message="J2SE-5.0:  ${J2SE-5.0}" />
  </target>
  <target
    name="setJVMfromUserSpecified"
    if="jvm"
    unless="javaversionEscaped">

    <property
      name="VMSource"
      value="VM used for tests, specified by caller: 'jvm'=${jvm}" />
    <echo message="VMSource: ${VMSource}" />
    <!-- Remember, we don't want J2SE-X.0 set at all, if there is nothing that
      can run tests that require that level. -->
    <exec
      executable="${jvm}"
      outputproperty="javaversion">
      <arg line="-version" />
    </exec>
    <echo message="full output from 'java -version' of ${jvm} is " />
    <echo message="${javaversion}" />
    <escapeProperty property="javaversion" />
    <echo message="full output from 'java -version' of ${jvm} is " />
    <echo message="${javaversionEscaped}" />

    <condition
      property="J2SE-8.0"
      value="${jvm}">
      <matches
        string="${javaversionEscaped}"
        pattern='^.*java version .*1\.[8]' />
    </condition>
    <condition
      property="J2SE-7.0"
      value="${jvm}">
      <matches
        string="${javaversionEscaped}"
        pattern='^.*java version .*1\.[78]' />
    </condition>
    <condition
      property="J2SE-6.0"
      value="${jvm}">
      <matches
        string="${javaversionEscaped}"
        pattern='^.*java version .*1\.[678]' />
    </condition>
    <condition
      property="J2SE-5.0"
      value="${jvm}">
      <matches
        string="${javaversionEscaped}"
        pattern='^.*java version .*1\.[5678]' />
    </condition>
    <echo
      level="info"
      message="DEBUG: values from setJVMfromUserSpecified" />
    <echo message="J2SE-8.0:  ${J2SE-8.0}" />
    <echo message="J2SE-7.0:  ${J2SE-7.0}" />
    <echo message="J2SE-6.0:  ${J2SE-6.0}" />
    <echo message="J2SE-5.0:  ${J2SE-5.0}" />
  </target>
  <!-- function to centralize how we get (that is, set) the value of 'javaMajorVersion'.
    (expected to be integer, such as 5,6,7,8,9, or will be "0" if the version
    could not be determined, for some reason. -->

  <target
    name="setJavaMajorVersion"
    depends="setJVMProperties"
    unless="javaMajorVersion">

    <echo message="javaversion in setJavaMajorVersion: ${javaversionEscaped}" />
    <script language="javascript">

      <!-- technically does not have to be wrapped in "CDATA" (Ant and BSD define
        it that way, but if not done, other tools (such as XML Editor) can break
        the code by changing the formatting. -->
    <![CDATA[
      var javaVer = project.getProperty("javaversionEscaped");
      var pattern = new RegExp(/^.*1\.([456789]\.\d)/);
      var sArray = pattern.exec(javaVer);
      // sArray 0 is "whole match"
      // so can always exist if any match,
      // but can be null if no match?
      // For safety from programing
      // errors, we'll check for null and length
      if (sArray != null) {
          var length = sArray.length;
          if (length > 1) {
            project.setProperty("javaMajorVersion", sArray[1]);
          } else {
            project.setProperty("javaMajorVersion", "0");
          }
      }
      ]]>
    </script>
  </target>

  <macrodef name="printPHPProperty">
    <attribute name="phpvar" />
    <attribute name="value" />
    <sequential>
      <!-- DEBUG <echo message="@{value}" /> -->
      <condition
        property="printValue@{value}"
        value="${@{value}}"
        else="NotSet">
        <isset property="@{value}" />
      </condition>
      <echo
        message="$@{phpvar}=&quot;${printValue@{value}}&quot;;${EOL}"
        file="${phpPropertyFile}"
        append="true" />
    </sequential>
  </macrodef>
  <macrodef name="escapeProperty">
    <!-- the use of propertyfile and local require at least Ant 1.8 -->
    <attribute name="property" />
    <sequential>
      <echo message="DEBUG @{property}: ${@{property}}" />
      <loadresource property="@{property}Escaped">
        <propertyresource name="@{property}" />
        <filterchain>
          <tokenfilter>
            <filetokenizer />
            <replacestring
              from='"'
              to='\"' />
          </tokenfilter>
        </filterchain>
      </loadresource>
    </sequential>
  </macrodef>
</project>

Back to the top