Skip to main content
summaryrefslogtreecommitdiffstats
blob: 9e0dc72e7d04cc3ab779426142c170b9214ddc13 (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
<project
  name="AggregationTasks"
  basedir="."
  default="default">

<!--

Purpose and primary targets

   This build.xml is to download and install the CBI aggregator (and other tools)
   and run one of three types of aggregations. Note: it assumes all has been checked out of Git
   and "ready to aggregate". It does recored the "commit" of some repositories, just as a way to
   improve documenting what was built.

   This script has 3 main "entry targets", each corresponding to one of the 3 types of aggregations:

      1. runAggregatorValidateOnly (default)
          This simply confirms the "constraints" as specified by the the *.aggr* contributions
          all make sense and "fit together" as well as that the repositories are available at the
          specified URLs. It is the "quickest" job, typically taking from 1 to 4 minutes.

      2. runAggregatorBuildOnly
          This aggregation does a complete aggregation. That is, in addition to "validating"
          the constraints, it downloads the artifacts, unpacks or verifies any pack.gz files,
          and creates a final repository. The distinguishing feature of this target is that
          if it is ran a second time it does not "clean" anything and downloads only anything new
          that is needed. Hence, the first time it is ran can take several hours,
          but subsequent runs can be much quicker (from just a few minutes to a few dozen minutes,
          depending on how much is new).

      3. runAggregatorCleanBuild
          This is the aggregation is similar to above, but always does a "clean build".
          It remove all artifacts and metadata that previously had been downloaded and starts "fresh".
          Hence, it always takes several hours to complete. But this is is important since there are few things
          that can go wrong that would only show up in a clean build.

Important properties

      Listed below are some of the most important properties that can be "passed in" (either as -D parameters on command line,
      or in a property file that is then specified on command line with -Daggr.properties=<yourPropertyFile>).

      - BUILD_HOME
           Technically should be an environment variable rather than an ant property. Such as invoking ant on command line
           with "BUILD_HOME=${PWD} ant ... ". The default is the environment variable "WORKSPACE" so if running on Hudson,
           nothing needs to be specified. Technically is not required, but if not running on Hudson, it is best to
           specify some directory outside of the working tree.

      - release
          'release' This is the release train name (e.g. 'neon', all lower case. It is used to form some email messages (from the CBI aggregator)
          as well as, in the final stages, some URL segments, such as when promoted to ".../staging/<release>". For production

Useful properties

      Listed below are some useful properties that can be "passed in" (either as -D parameters on command line,
      or in a property file that is then specified on command line with -Daggr.properties=<yourPropertyFile>).
      But, most users or use-cases will not need to be concerned with these.

      - git_protocol
          'git_protocol' specifies an alternative way to "get" the git repositories of the 'simrel.build' and 'simrel.tools'.
          If running with local versions of the repository, it can be slightly more efficient and reliable
          to use direct file access ("git_protocol=file://") instead of the default of "git://git.eclipse.org".

      - rewriteRepositoryURLValue
          'rewriteRepositoryURLValue' is simlar to the git_protocol property but applies to URLs in the *aggr* files.
          If running on Eclipse.org (or, if you otherwise have direct access to the file system, say with a mirrored repository)
          it is more efficient to use direct file access ("rewriteRepositoryURLValue=file:///home/data/httpd/download.eclipse.org")
          rather than the default specified in the *aggr* files ("https://download.eclipse.org"). If this property exists (i.e. has
          a value) then the script does a simple search-and-replace to rewrite matching URLs.

      - installEclipseAndTools
          The script always installs Eclipse and required tools *unless* is sees that eclipse is already installed.
          To force it to reinstall Eclipse and required tools use this installEclipseAndTools property. In practice,
          this value is seldom needed since often just as easy to delete the entire "BUILD_HOME" and start completely fresh.

      - platformFilename
          'platformFilename' is the name of the binary platform to install
          as the "base" into which the aggregator and other tools are installed into.
          The default is eclipse-platform-4.8-linux-gtk-x86_64.tar.gz.

      - platformLocation
          'platformLocation' is the location from where to the binary platform.
          By default, it is
          https://download.eclipse.org/eclipse/downloads/drops4/R-4.8-201806110500
          If you have access to the binary platform archive on your file system, you can specify
          its location instead, for some savings in "download time". For example:
          file:///files/eclipsefiles/

       - JAVA_HOME
          Should rarely be needed "these days". But is provided here in case it is desired
          to run the aggregator with a different VM than the VM that is running Ant.

-->

  <!-- globally make "environment variables" available -->
  <property environment="env" />

  <target
    name="installAggregatorAndTools"
    depends="init, savePrevious,installAggregator,installRelengTools,installTestsFromP2Repo"
    if="installEclipseAndTools"
    unless="eclipseAndToolsInstalled">

    <echo message="Installed fresh Eclipse, Aggregator, and Tools" />
    <property
      name="eclipseAndToolsInstalled"
      value="true" />

  </target>

  <target
    name="installAggregator"
    depends="init, savePrevious"
    if="installEclipseAndTools"
    unless="aggregatorInstalled">
    <property
      name="APP_NAME_P2DIRECTOR_AGG"
      value="org.eclipse.equinox.p2.director" />
    <property
      name="otherArgsAggr"
      value="-metadataRepository https://download.eclipse.org/cbi/updates/aggregator/ide/4.8/I20180518-0759/ -artifactRepository https://download.eclipse.org/cbi/updates/aggregator/ide/4.8/I20180518-0759/ -installIU org.eclipse.cbi.p2repo.aggregator.engine.feature.feature.group" />

      <!--
        Remote builds should use eclipse.p2.mirrors=true
        (the default). But, in some cases may want to add
        -Declipse.p2.mirrors=false
      -->
    <property
      name="vm_args_aggr"
      value="-Djava.io.tmpdir=${BUILD_HOME}/tmp" />
    <condition
      property="vm_args_aggr_settings"
      value="-vmargs ${vm_args_aggr}">
      <isset property="vm_args_aggr" />
    </condition>

    <mkdir dir="${ECLIPSE_HOME}" />

    <get
      src="${platformResource}"
      dest="${localPrereqCache}"
      usetimestamp="true" />

    <untar
      compression="gzip"
      overwrite="true"
      src="${localPrereqCache}/${platformFilename}"
      dest="${ECLIPSE_HOME}" />

    <!--
      This .options file mentioned elsewhere is most useful on non-eclipse.org
      sites, since
      on eclipse.org, by design, should not go through mirrors, but that's
      the purpose of the .options ... to list which mirrors that artifacts
      come
      from.
    -->

    <!-- Weird this chmod is required? Maybe an ant bug? Maybe no longer
      needed? (That is, maybe an early bug in packages?) -->
    <chmod
      file="${ECLIPSE_HOME}/eclipse/eclipse"
      perm="ugo+x"
      verbose="true" />

    <!-- and now get latest version of aggregator -->
    <exec
      executable="${eclipseExecutable}"
      dir="${basedir}"
      failonerror="true">
      <arg
        line="-data ${eclipseWorkspaceBase}/install_aggr -debug -consolelog -nosplash --launcher.suppressErrors -application ${APP_NAME_P2DIRECTOR_AGG} ${otherArgsAggr} ${vm_args_aggr_settings}" />
    </exec>
    <property
      name="aggregatorInstalled"
      value="true" />

  </target>

  <target
    name="installTestsFromP2Repo"
    depends="init"
    if="installEclipseAndTools"
    unless="testsInstalled">
    <property
      name="APP_NAME_P2DIRECTOR_TESTS"
      value="org.eclipse.equinox.p2.director" />
    <property
      name="repoReportURL"
      value="https://download.eclipse.org/cbi/updates/analyzers/4.7/" />

    <property
      name="OTHER_ARGS_TESTS"
      value="-metadataRepository ${repoReportURL} -artifactRepository ${repoReportURL} -installIU org.eclipse.cbi.p2repo.analyzers.feature.feature.group" />

    <property
      name="vm_args_tests"
      value="-Djava.io.tmpdir=${BUILD_HOME}/tmp" />
    <condition
      property="vm_args_tests_settings"
      value="-vmargs ${vm_args_tests}">
      <isset property="vm_args_tests" />
    </condition>

    <!-- install latest feature from repo -->
    <exec
      executable="${eclipseExecutable}"
      dir="${basedir}"
      failonerror="true">
      <arg
        line="-data ${eclipseWorkspaceBase}/installTests -debug -consolelog -nosplash --launcher.suppressErrors -application ${APP_NAME_P2DIRECTOR_TESTS} ${OTHER_ARGS_TESTS} ${vm_args_tests_settings}" />
    </exec>
    <property
      name="testsInstalled"
      value="true" />

  </target>


  <target
    name="installRelengTools"
    depends="init"
    if="installEclipseAndTools"
    unless="relengToolsInstalled">
    <property
      name="APP_NAME_P2DIRECTOR_RELENG"
      value="org.eclipse.equinox.p2.director" />
    <property
      name="OTHER_ARGS_RELENG"
      value="-metadataRepository https://download.eclipse.org/webtools/releng/repository/ -artifactRepository https://download.eclipse.org/webtools/releng/repository/ -installIU org.eclipse.wtp.releng.tools.feature.feature.group" />

    <property
      name="vm_args_releng"
      value="-Djava.io.tmpdir=${BUILD_HOME}/tmp" />

    <condition
      property="vm_args_releng_settings"
      value="-vmargs ${vm_args_releng}">
      <isset property="vm_args_releng" />
    </condition>

    <!-- install latest feature from repo -->
    <exec
      executable="${eclipseExecutable}"
      dir="${basedir}"
      failonerror="true">
      <arg
        line="-data ${eclipseWorkspaceBase}/installRelengTools -debug -consolelog -nosplash --launcher.suppressErrors -application ${APP_NAME_P2DIRECTOR_RELENG} ${OTHER_ARGS_RELENG} ${vm_args_releng_settings}" />
    </exec>
    <property
      name="relengToolsInstalled"
      value="true" />
  </target>

  <macrodef name="git-config">
    <attribute name="repodir" />
    <attribute name="configKey" />
    <attribute name="configValue" />
    <sequential>
      <echo message="execute git in @{repodir}" />
      <echo message="git config @{configKey} @{configValue}" />
      <!-- We list "before and after" just to learn more about the system.
        We
        will not always need to do that. -->
      <exec
        executable="git"
        failonerror="true"
        dir="@{repodir}">
        <arg value="config" />
        <arg value="--list" />
      </exec>
      <exec
        executable="git"
        failonerror="true"
        dir="@{repodir}">
        <arg value="config" />
        <arg value="@{configKey}" />
        <arg value="@{configValue}" />
      </exec>
      <exec
        executable="git"
        failonerror="true"
        dir="@{repodir}">
        <arg value="config" />
        <arg value="--list" />
      </exec>
    </sequential>
  </macrodef>

  <macrodef name="git-rev-parse">
    <attribute name="repodir" />
    <attribute
      name="reference"
      default="HEAD" />
    <attribute name="returnProperty" />
    <sequential>
      <echo message="execute git in @{repodir}" />
      <echo message="git rev-parse @{reference} returned in @{returnProperty}" />
      <local name="rc" />
      <local name="result" />
      <exec
        executable="git"
        failonerror="true"
        outputproperty="result"
        resultproperty="rc"
        dir="@{repodir}">
        <arg line="rev-parse @{reference}" />
      </exec>
      <property
        name="@{returnProperty}"
        value="${result}" />
      <echo message="In macro rc is ${rc}" />
      <echo message="In macro result is ${result}" />
      <echo message="In macro @{returnProperty} is ${@{returnProperty}}" />
    </sequential>
  </macrodef>


  <!-- We set repo config repeatedly (every build) since we do not know "who"
    cloned the repository first, "us", or "Hudson". And if Hudson (or Gerrit)
    does it then we do not know how they set or determine the correct config
    values. -->
  <target
    name="configRepo"
    depends="init"
    if="localRepoExists">
    <echo message="git config task to execute in ${buildModelDir}" />
    <!-- in macro "config" we list, then set then list again the configuration. -->
    <git-config
      repodir="${buildModelDir}"
      configKey="core.autocrlf"
      configValue="input" />
  </target>

  <!-- This is "the key" task. If it succeeds, we run tests (reports), and
    if they "pass", we promote to "staging". -->
  <target
    name="runAggregatorCleanBuild"
    description="Runs a clean aggregation"
    depends="init,rewriteRepositoryURL,installAggregatorAndTools">
    <!-- If not otherwise set in properties file, use these values. Note
      the
      build.eclipse.org production machine must override these values for
      property
      values appropriate for it (namely production.properties). -->
    <!-- We no longer "trust" Eclipse and Equinox repos. -trustedContributions
      Eclipse,Equinox -->
    <property
      name="AGG_APP_ARGS"
      value="${AGGREGATOR_APP_BASE_ARGS} --action CLEAN_BUILD" />
    <echo message="AGG_APP_ARGS: ${AGG_APP_ARGS}" />
    <!-- Important: on any non-production machines it is important to _not_
      use eclipse.p2.mirrors=false, so this value should be supplied by calling
      script's properties. Note, we include '-vmargs' here, in case there
      are not
      any. Not sure if the use of -vmargs _requires_ arguments or not, but
      probably
      would. note: -Declipse.p2.MD5Check=false may be needed as a workaround
      for
      bug [253713] (should not actually be required ... but have left note
      for
      historical reference) note: rememeber that JAVA_6 should not be used
      for
      jar processor, see for example, bug 244603 and bug 279596. -->


    <exec
      executable="${eclipseExecutable}"
      dir="${basedir}"
      failonerror="false"
      resultproperty="buildStatus">

      <!-- Adding -consolelog makes for too much, unneeded output, since
        the
        aggregator produces its verbose own output, slightly cleaner. <arg
        value="-consolelog"
        /> -->
      <arg value="-nosplash" />
      <arg value="-data" />
      <arg value="${eclipseWorkspaceBase}/runAggregatorCleanBuild" />
      <arg value="--launcher.suppressErrors" />
      <arg value="-application" />
      <arg value="org.eclipse.cbi.p2repo.cli.headless" />
      <arg value="aggregate" />
      <arg value="--buildId" />
      <arg value="${buildTimestamp}" />
      <arg line="${AGG_APP_ARGS}" />
      <arg line="${vm_setting}" />
      <arg line="${builder_vm_args_settings}" />
    </exec>

    <antcall target="checkStatus">
      <param
        name="status"
        value="${buildStatus}" />
      <param
        name="message"
        value="Aggregation Failed" />
    </antcall>

    <echo message="Waiting 2 seconds..." />
    <sleep seconds="2" />
    <echo message="Waiting 2 seconds..." />
    <sleep seconds="2" />
    <echo message="Waiting 2 seconds..." />
    <sleep seconds="2" />

    <antcall target="createBuildinfo" />
    <antcall target="createXZformats" />
    <!-- The tests depend on the symbolic link of "latests" being created,
      so we pause a few seconds for NSF to catch up. -->
    <echo message="Waiting 2 seconds..." />
    <sleep seconds="2" />
    <echo message="Waiting 2 seconds..." />
    <sleep seconds="2" />
    <echo message="Waiting 2 seconds..." />
    <sleep seconds="2" />

    <antcall target="runTests">
      <param
        name="tests"
        value="cleanBuildTests" />
    </antcall>

  </target>

  <target name="checkStatus">
    <echo message="status: ${status}" />
    <condition
      property="statusOK"
      value="true">
      <equals
        forceString="true"
        arg1="${status}"
        arg2="0" />
    </condition>
    <echo message="statusOK: ${statusOK}" />
    <antcall target="writeStatus" />
    <fail
      message="${message}"
      unless="statusOK" />

  </target>

  <target
    name="writeStatus"
    unless="statusOK">
    <echo
      message="build failed"
      file="${BUILD_HOME}/buildStatusFailed" />
  </target>

  <!-- Note: many tests would not be valid on "cached" version of repo, but,
    some might? Currently no tests are called, but, we might alter, so we
    make
    sure installed now, in anticipation. -->
  <target
    name="runAggregatorBuildOnly"
    description="Runs an aggregation, but uses prevoiusly cached artifacts, unless new ones are required by contribution"
    depends="init,rewriteRepositoryURL,installAggregatorAndTools,initRunTestsXML">

    <property
      name="AGG_APP_ARGS"
      value="${AGGREGATOR_APP_BASE_ARGS} --action BUILD" />
    <echo message="AGG_APP_ARGS: ${AGG_APP_ARGS}" />
    <!--
      Important: on any non-production machines it is important to _not_
      use eclipse.p2.mirrors=false, so this value should be supplied by calling
      script's properties. Note, we include '-vmargs' here, in case there
      are not any. Not sure if the use of -vmargs _requires_ arguments or
      not, but
      probably would. note: -Declipse.p2.MD5Check=false may be needed as
      a workaround
      for bug [253713] (should not be required any longer ... but have left
      note
      for historical reference) Another historical note, we used to "force"
      JAVA_5 to be be used for jar processor, see for example, bug 244603
      and bug 279596.
      But we have not "forced" everyone to use Java 8.
    -->

    <exec
      executable="${eclipseExecutable}"
      dir="${basedir}"
      failonerror="false"
      resultproperty="buildStatus">
      <arg value="-debug" />
      <arg value="file://${BUILD_HOME_DIR}/p2options/.options" />
      <!--
        Adding -consolelog makes for too much, unneeded output, since
        the aggregator produces its verbose own output, slightly cleaner.
      -->
      <arg value="-nosplash" />
      <arg value="-data" />
      <arg value="${eclipseWorkspaceBase}/runAggregatorBuildOnly" />
      <arg value="--launcher.suppressErrors" />
      <arg value="-application" />
      <arg value="org.eclipse.cbi.p2repo.cli.headless" />
      <arg value="aggregate" />
      <arg value="--buildId" />
      <arg value="${buildTimestamp}" />
      <arg line="${AGG_APP_ARGS}" />
      <arg line="${vm_setting}" />
      <arg line="${builder_vm_args_settings}" />
    </exec>

    <antcall target="checkStatus">
      <param
        name="status"
        value="${buildStatus}" />
      <param
        name="message"
        value="Aggregation Failed" />
    </antcall>

    <antcall target="createBuildinfo" />

    <antcall target="runTests">
      <param
        name="tests"
        value="cachedBuildTests" />
    </antcall>

  </target>

  <!--
    Note, we currently have no "tests" for the "validate only" case, but
    we could, might someday, so we go ahead an install, in anticipation.
    For example, we might simply test that all aggrcon files specify
    unique URL (to simple repository) or that "versions" are
    specified in *.aggrcon file.
  -->
  <target
    name="runAggregatorValidateOnly"
    description="Runs an aggregation, but validates constraints only. Does not fetch artifacts."
    depends="init,rewriteRepositoryURL,installAggregatorAndTools,initRunTestsXML">

    <property
      name="AGG_APP_ARGS"
      value="${AGGREGATOR_APP_BASE_ARGS} --action VALIDATE" />
    <echo message="AGG_APP_ARGS: ${AGG_APP_ARGS}" />

    <exec
      executable="${eclipseExecutable}"
      dir="${basedir}"
      failonerror="false"
      resultproperty="buildStatus">
      <arg value="-debug" />
      <!--
        In case extra tracing is desired:
        <arg value="file://${BUILD_HOME}/org.eclipse.simrel.tools/p2options/.options"
        />
      -->
      <!--
        Adding -consolelog makes for too much, unneeded output, since
        the aggregator produces its verbose own output, slightly cleaner.
      -->
      <arg value="-nosplash" />
      <arg value="-data" />
      <arg value="${eclipseWorkspaceBase}/runAggregatorValidateOnly" />
      <arg value="--launcher.suppressErrors" />
      <arg value="-application" />
      <arg value="org.eclipse.cbi.p2repo.cli.headless" />
      <arg value="aggregate" />
      <arg value="--buildId" />
      <arg value="${buildTimestamp}" />
      <arg line="${AGG_APP_ARGS}" />
      <arg line="${vm_setting}" />
      <arg line="${builder_vm_args_settings}" />
    </exec>

    <antcall target="checkStatus">
      <param
        name="status"
        value="${buildStatus}" />
      <param
        name="message"
        value="Aggregation Failed" />
    </antcall>

    <!-- setting dir to our workspace, so tests done on what "we" have -->
    <antcall target="createBuildinfo" />

    <antcall target="runTests">
      <param
        name="tests"
        value="validateOnlyTests" />
    </antcall>

  </target>

  <target
    name="runTests"
    depends="initRunTestsXML,checkrunTests"
    if="runTestsXML">
    <ant
      antfile="${runTestsXML}"
      target="${tests}"
      dir="${buildToolsDir}" />
  </target>
  <target
    name="checkrunTests"
    depends="initRunTestsXML"
    unless="runTestsXML">
    <echo message="runTestsXML was not defined as expected. Hence, no tests ran." />
  </target>
  <target
    name="initRunTestsXML"
    depends="getBuildToolsDir"
    if="toolsAvailable"
    unless="runTestsXML">
    <path id="runTests.paths">
      <fileset
        dir="${buildToolsDir}"
        includes="runTests.xml" />
    </path>
    <property
      name="runTestsXML"
      refid="runTests.paths" />
    <echo message="runTestsXML file: ${runTestsXML}" />
  </target>

  <target name="getBuildToolsDir">
    <property
      name="buildToolsDir"
      value="${BUILD_HOME}/org.eclipse.simrel.tools" />
    <available
      file="${buildToolsDir}"
      property="toolsAvailable" />
  </target>
  <target
    name="init"
    depends="getJVMLocation, getBUILD_HOME, setDefaultBUILD_HOME, setDefaultRelease, getBuildTimestamp, getJobName, getJobNumber, getBuildToolsDir, gitRevParseTools, getBuildModelDir, gitRevParseModel"
    unless="isInitialized">

    <!-- We assign a reasonable value for local builds, but for production
      builds should be .../production.properties This property file name
      is itself a property, so it can be overridden on one machine versus another.
      We do it this way, instead of just specifying -propertyFile on command line,
      so that the property values can be "nested" in other property values and
      evaluated lazily. -->
    <property
      name="aggrPropertyFile"
      value="${buildToolsDir}/aggr.properties" />
    <property file="${aggrPropertyFile}" />

      <!--
      The "binary platform" is enough, for now, and since smaller than the SDK,
      it is recommended as the "base" to install tools into. But a typical "SDK" has been
      left in this comment in case users are doing more than a normal "aggregation build".
      value="/home/data/httpd/archive.eclipse.org/eclipse/downloads/drops4/R-4.8-201806110500/eclipse-SDK-4.8-linux-gtk-x86_64.tar.gz"
      -->
      <!--
      Note: if there is local file system version of the prereq platform,
      if it faster to specify file://<location of platform>.
      <property name="platformLocation" value="file:///home/data/httpd/archive.eclipse.org/eclipse/downloads/drops4/R-4.8-201806110500" />
      We use "http://" by default to make it easy to "run from anywhere", but
      on the production machine, in production.properties, we specify the "file://" form.
      -->
    <property
      name="platformLocation"
      value="https://download.eclipse.org/eclipse/downloads/drops4/R-4.8-201806110500/" />
    <property
      name="platformFilename"
      value="eclipse-platform-4.8-linux-gtk-x86_64.tar.gz" />
    <property
      name="localPrereqCache"
      value="${BUILD_HOME}/localPrereqs" />
    <property
      name="platformResource"
      value="${platformLocation}/${platformFilename}" />
      <!-- directory must exist before "get" uses it or else the file is given name of "localPrereqs" -->
    <mkdir dir="${localPrereqCache}" />


    <property
      name="ECLIPSE_HOME"
      value="${BUILD_HOME}/eclipseInstall" />

    <property
      name="ECLIPSE_EXE"
      value="${ECLIPSE_HOME}/eclipse/eclipse" />

    <property
      name="AGGREGATOR_RESULTS"
      value="${BUILD_HOME}/aggregation" />

    <!-- git_protocol should be changed to somethign like "file://" for production
      builds, for efficiency and to avoid problems when the "internal" network
      is down. (Note no trailing slash). It can be added to a local copy
      of 'aggrPropertyFile' -->
    <property
      name="git_protocol"
      value="git://git.eclipse.org" />

    <!--
      rewriteRepositoryURLValue is an important variable, passed in through
      production.properties. It is the trigger to change http:// values,
      to file:// values. At one point, we needed, unrewriteMapsLine, to know
      how to
      "change back" and now use commonRepositoryDownloadURLValue to know
      "what to
      look for" to change to rewriteRepositoryURLValue, but this should not
      be
      needed to be changed, since we make the strong assumption that, in
      *.aggrcon
      files, this string occurs only in repository location attributes. If
      not true,
      more complex parsing/replacement would be required.
    -->
    <property
      name="commonRepositoryDownloadURLValue"
      value="https://download.eclipse.org" />

    <condition property="localRepoExists">
      <available file="${buildModelDir}/.git" />
    </condition>

    <property
      name="eclipseWorkspaceBase"
      value="${BUILD_HOME}/eclipseworkspaces" />

    <!--
      If the eclipse workspace exists, remove it, to make sure we are
      starting "fresh". Eclipse will create it. Be sure some "archive
      artifacts" job saves it away, if desired, just for it's ".log",
      if nothing else.
    -->
    <delete
      dir="${eclipseWorkspaceBase}"
      quiet="true" />

    <!-- Note: we put -vmargs directly in builder_vm_args_settings so that if desired
      to not have ANY vmargs, then we will not be left with a dangling (empty)
      -vmargs at the end of eclipse command line. -->
    <property
      name="builder_vm_args"
      value="-Xmx1024M -Djava.io.tmpdir=${BUILD_HOME}/tmp" />
    <condition
      property="builder_vm_args_settings"
      value="-vmargs ${builder_vm_args}">
      <isset property="builder_vm_args" />
    </condition>

    <!-- tmp directory must exist, for Java to use it -->
    <mkdir dir="${BUILD_HOME}/tmp" />
    <echo message="Made directory ${BUILD_HOME}/tmp" />


    <property
      name="eclipseExecutable"
      value="${ECLIPSE_EXE}" />

    <available
      file="${ECLIPSE_HOME}/eclipse"
      type="dir"
      property="eclipseExists" />

    <!-- set installEclipseAndTools on command line to force a reinstall,
      Otherwise, only installed if not installed yet. -->
    <condition property="installEclipseAndTools">
      <not>
        <isset property="eclipseExists" />
      </not>
    </condition>

    <!-- saveAndInstallEclipseAndTools should only be true if "installEclipseAndTools"
      are set on command line properties (and a version already exists). -->
    <condition property="saveAndInstallEclipseAndTools">
      <and>
        <isset property="eclipseExists" />
        <isset property="installEclipseAndTools" />
      </and>
    </condition>

    <!-- note the "https" may have to be "http" on localhost, non-production
      hudson machines -->
    <property
      name="hostForURL"
      value="https://hudson.eclipse.org" />

    <!-- TODO: this will not be correct for local builds, probably. Could
      do
      more to detect "local builds" and either not set, or set to correct
      values
      for a "local hudson". -->
    <property
      name="LOG_URL"
      value="${hostForURL}/simrel/job/${jobName}/${jobNumber}/console" />

    <!-- These are the arguments to the aggregator that are constant, whether
      doing "production build" or "local build". If doing production build,
      then
      is also needs the &dash;$dash;production argument (it is the one that
      cuases
      "blame mail" to be sent). If PRODUCTION is not set externally (such
      as on
      command line, or in a property file, we set it to blank here to avoid
      the
      literal '${PRODUCTION} from being passed as an argument. Be sure to
      udpate
      emailFrom as "build master" changes. -->
    <property
      name="PRODUCTION"
      value="" />
    <property
      name="p2AgentLocation"
      value="${BUILD_HOME}/.p2AgentLocation" />
    <!-- In the distant past, we have also used these arguments. The maven
      result one was always experimental. We have also learned it it better
      not
      to "trust" any repository. Can only use one or the other, not both
      &dash;&dash;mavenResult
      &dash;&dash;trustedContributions Eclipse,Equinox -->
    <property
      name="AGGREGATOR_APP_BASE_ARGS"
      value="${PRODUCTION} --buildModel ${buildModelDir}/simrel.aggr --buildRoot ${AGGREGATOR_RESULTS} --agentLocation ${p2AgentLocation} --eclipseLogLevel DEBUG --logLevel DEBUG --emailFrom frederic.gurr@eclipse-foundation.org --emailFromName ${release}Aggregator --logURL ${LOG_URL} --subjectPrefix ${release}Aggregation" />

    <echo message="= = = Properties at end of init = = = " />
    <echo message="git_protocol: ${git_protocol}" />
    <echo message="PRODUCTION: ${PRODUCTION}" />
    <echo message="rewriteRepositoryURLValue: ${rewriteRepositoryURLValue}" />
    <echo message="buildModelCommit: ${buildModelCommit}" />
    <echo message="toolsRepoCommit: ${toolsRepoCommit}" />
    <echo message="aggrPropertyFile: ${aggrPropertyFile}" />
    <echo message="buildId: ${buildTimestamp}" />
    <echo message="user.dir: ${user.dir}" />
    <echo message="user.home: ${user.home}" />
    <echo message="BUILD_HOME (normally HUDSON workspace): ${BUILD_HOME}" />
    <echo message="Eclipse workspace base: ${eclipseWorkspaceBase}" />
    <echo message="PATH: ${env.PATH}" />
    <echo message="JAVA_HOME: ${JAVA_HOME}" />
    <echo message="hostForURL: ${hostForURL}" />
    <echo message="jobName: ${jobName}" />
    <echo message="jobNumber: ${jobNumber}" />
    <echo message="ECLIPSE_EXE:  ${ECLIPSE_EXE}" />
    <echo message="eclipseExists: ${eclipseExists}" />
    <echo message="builder_vm_args: ${builder_vm_args}" />
    <echo message="builder_vm_args_settings: ${builder_vm_args_settings}" />
    <echo message=" = = = = = = = = = = = = " />
    <echoproperties />

    <!-- remove "build failed" status file, if there is one from previous
      run. -->
    <delete
      failonerror="true"
      quiet="true">
      <fileset dir="${BUILD_HOME}">
        <include name="buildStatusFailed" />
      </fileset>
    </delete>

    <!-- no need to initialize twice -->
    <property
      name="isInitialized"
      value="true" />

  </target>

  <target
    name="getBuildTimestamp"
    depends="getHudsonTimestamp"
    unless="buildTimestamp">
    <tstamp>
      <format
        property="buildTimestamp"
        pattern="yyyy-MM-dd_HH-mm-ss"
        timezone="UTC_TIME" />
    </tstamp>
    <echo message="Using Ant computed timestamp (since not running on Hudson): ${buildTimestamp}." />
  </target>

  <target
    name="getHudsonTimestamp"
    unless="buildTimestamp"
    if="env.BUILD_ID">
    <property
      name="buildTimestamp"
      value="${env.BUILD_ID}" />
    <echo message="Using timestamp from Hudson Build ID: ${buildTimestamp}" />
  </target>

  <target
    name="getJobName"
    depends="getHudsonJobName"
    unless="jobName">
    <property
      name="jobName"
      value="none" />
    <echo message="Using default jobName: none." />
  </target>

  <target
    name="getHudsonJobName"
    unless="jobName"
    if="env.JOB_NAME">
    <property
      name="jobName"
      value="${env.JOB_NAME}" />
    <echo message="Using jobName from Hudson Builder: ${jobName}" />
  </target>

  <target
    name="getJobNumber"
    depends="getHudsonJobNumber"
    unless="jobNumber">

    <property
      name="jobNumber"
      value="none" />
    <echo message="Using default jobNumber: ${jobNumber}." />
  </target>

  <target
    name="getHudsonJobNumber"
    unless="jobNumber"
    if="env.BUILD_NUMBER">
    <property
      name="jobNumber"
      value="${env.BUILD_NUMBER}" />
    <echo message="Using jobNumber from Hudson Builder: ${jobNumber}" />
  </target>

  <target
    name="getBUILD_HOME"
    depends="getHudsonBUILD_HOME"
    unless="BUILD_HOME">
    <condition
      property="BUILD_HOME"
      value="${env.BUILD_HOME}">
      <isset property="env.BUILD_HOME" />
    </condition>
  </target>

  <target
    name="getHudsonBUILD_HOME"
    unless="BUILD_HOME">
    <condition
      property="BUILD_HOME"
      value="${env.WORKSPACE}">
      <isset property="env.WORKSPACE" />
    </condition>
  </target>

  <target
    name="setDefaultBUILD_HOME"
    unless="BUILD_HOME">
    <!--
         We assume BUILD_HOME is "one up" from directory where build.xml file is.
         We always assume the 'simrel.build' and 'simrel.tools' projects are directly under "BUILD_HOME".
    -->
    <dirname
      property="BUILD_HOME"
      file="${basedir}" />
    <echo
      message="WARNING: BUILD_HOME set to a default value, ${BUILD_HOME}. If this is not correct, you must configure is explicitly as an environment variable." />
    <echo message="         Note: we always assume the 'simrel.build' and 'simrel.tools' projects are directly under 'BUILD_HOME'" />

  </target>
  <target
    name="setDefaultRelease"
    unless="release">
    <property
      name="release"
      value="noReleaseSpecified" />
    <echo
      message="WARNING: release set to a default value, ${release}. Typically this is not desired and may mean there is a configuration issue." />
  </target>
  <!-- Only rewrite, if a value has been provided -->
  <!-- TODO: should make the "exclude" part automatic based on presence/abscense
    of "useTrusted" property -->
  <target
    name="rewriteRepositoryURL"
    if="rewriteRepositoryURLValue"
    unless="rewroteURLs">
    <replace
      dir="${buildModelDir}"
      token="${commonRepositoryDownloadURLValue}"
      value="${rewriteRepositoryURLValue}">
      <include name="*.aggrcon" />
      <!-- <exclude name="ep.aggrcon"/> <exclude name="equinox.aggrcon"/> -->
    </replace>
    <echo message="Rewrote repository location URLs ..." />
    <echo message="        From: ${commonRepositoryDownloadURLValue}" />
    <echo message="          To: ${rewriteRepositoryURLValue}" />
    <echo message="   Excluding no files since no composite artifacts, just agregate" />
    <!-- <echo message=" Excluding: ep.aggrcon"/> <echo message=" Excluding:
      ep.aggrcon, equinox.aggrcon"/> -->
    <property
      name="rewroteURLs"
      value="true" />

  </target>

  <target
    name="getBuildModelDir"
    unless="buildModelDir">
    <property
      name="buildModelDir"
      value="${BUILD_HOME}/org.eclipse.simrel.build" />
  </target>

  <target name="createXZformats">
    <exec
      executable="/bin/bash"
      dir="${basedir}"
      failonerror="true">
      <arg line="convertxz.sh ${AGGREGATOR_RESULTS}/final" />
    </exec>
  </target>

  <target
    name="createBuildinfo"
    depends="init, gitRevParseModel, gitRevParseTools">

    <property
      name="BUILD_INFO_DIR"
      value="${AGGREGATOR_RESULTS}/final/buildInfo" />
  	<!--
  	  Note: The propertyfile task literally edits the properties,
  	  if the file already exists, does not create a new one. Therefore
  	  we delete it first.
  	-->
    <delete dir="${BUILD_INFO_DIR}" />
    <mkdir dir="${BUILD_INFO_DIR}" />

    <propertyfile file="${BUILD_INFO_DIR}/buildInfo.properties">
      <entry
        key="buildModelCommit"
        value="${buildModelCommit}" />
      <entry
        key="toolsRepoCommit"
        value="${toolsRepoCommit}" />
      <entry
        key="triggerJobName"
        value="${jobName}" />
      <entry
        key="triggerJobNumber"
        value="${jobNumber}" />
      <entry
        key="triggerBuildTimestamp"
        value="${buildTimestamp}" />
      <entry
        key="triggerBuildId"
        value="${buildTimestamp}" />
    </propertyfile>
    <!-- echo the key ones to end of log, just to have redundant record. -->
    <echo message="buildModelCommit: ${buildModelCommit}" />
    <echo message="toolsRepoCommit: ${toolsRepoCommit}" />
    <echo message="triggerJobName: ${jobName}" />
    <echo message="triggerJobNumber: ${jobNumber}" />
    <echo message="triggerBuildTimestamp: ${buildTimestamp}" />
    <echo message="triggerBuildId: ${buildTimestamp}" />
    <!-- just as well write out everything ... just in case something else
      needed in future. -->
    <echoproperties destfile="${BUILD_INFO_DIR}/allInfo.properties" />
  </target>

  <target
    name="gitRevParseModel"
    depends="getBuildModelDir">
    <git-rev-parse
      repodir="${buildModelDir}"
      returnproperty="buildModelCommit" />
    <echo message="In target gitRevParseModel, buildModelCommit: ${buildModelCommit}" />
  </target>
  <target
    name="gitRevParseTools"
    depends="getBuildToolsDir"
    if="toolsAvailable">
    <git-rev-parse
      repodir="${buildToolsDir}"
      returnproperty="toolsRepoCommit" />
    <echo message="In target gitRevParseTools, toolsRepoCommit: ${toolsRepoCommit}" />
  </target>

  <target
    name="default"
    description="By default run the runAggregatorValidateOnly target">
    <echo message="Using default target:" />
    <echo message="     runAggregatorValidateOnly" />
    <echo message="  Other meaningful targets to specify explicitly:" />
    <echo message="     runAggregatorBuildOnly" />
    <echo message="     runAggregatorCleanBuild" />
    <antcall target="runAggregatorValidateOnly" />
  </target>

  <target
    name="savePrevious"
    depends="init"
    if="saveAndInstallEclipseAndTools"
    unless="previousSaved">

    <!-- Remember, old, saved versions may have to be maually cleaned up,
      from
      time to time. But probably handled well enough by an occasional, manual
      "clean
      workspace" from Hudson's web interface. -->
    <move
      verbose="true"
      todir="${ECLIPSE_HOME}/eclipse${buildTimestamp}">
      <fileset dir="${ECLIPSE_HOME}/eclipse" />
    </move>

    <property
      name="previousSaved"
      value="true" />
  </target>
    <!-- It is not required for user to specify "vm", only
         needed if they want to override the system (or Hudson)
         default. We do the "work" in getJVMLocationInternal
         so we can set a "null default" in this task.
    -->
  <target
    name="getJVMLocation"
    depends="getJVMLocationInternal"
    unless="vm_setting">
      <!-- if vm_setting not set in 'getJVMLocationInternal'
           then we set it to "null" here so that is has a safe value
           when later used as <arg line="${vm_setting} />
      -->
    <property
      name="vm_setting"
      value="" />
    <echo message="vm_setting has no value: ${vm_setting}" />
  </target>
  <target
    name="getJVMLocationInternal"
    depends="getJAVA_HOME"
    if="JAVA_HOME"
    unless="vm_setting">
    <property
      name="vm_setting"
      value="-vm ${JAVA_HOME}/jre/bin" />
    <echo message="at end of 'getJVMLocationInternal' vm_setting: ${vm_setting}" />
  </target>
    <!-- we have all these "checks" and "print out" since
         it is not known how ant "knows about" JAVA_HOME.
         That is, ant could be running in a Java different from
         the one that is desired to be used to run aggregator.
         Put another way, users can define JAVA_HOME as an environment
         variable, or pass in a -DJAVA_HOME value. The later takes
         priority, if both exists.
         Example: -DJAVA_HOME=/shared/common/jdk1.8.0_x64-latest
    -->
  <target
    name="getJAVA_HOME"
    depends="printPredefinedJAVA_HOME"
    unless="JAVA_HOME">
    <condition
      property="JAVA_HOME"
      value="${env.JAVA_HOME}">
      <isset property="env.JAVA_HOME" />
    </condition>
    <echo message="at end of 'getJAVA_HOME', JAVA_HOME: ${JAVA_HOME}" />
  </target>
  <target
    name="printPredefinedJAVA_HOME"
    if="JAVA_HOME">
    <echo message="Found JAVA_HOME already defined to be ${JAVA_HOME}" />
  </target>

  <!-- Note: this target may be useful to anyone that has ran "build.xml" from
       their IDE workspace, since the build will leave some directories in
       their IDE workspace that do not show up in their IDE.
  -->
  <target
    name="cleanAllArtifacts"
    depends="getBUILD_HOME, setDefaultBUILD_HOME"
    description="This target is primarily for documentation. We do NOT want to call this automatically, since that would interfere with desired caching, etc. But may be desired to create custom versions in future, in some cases, so documented here.">
      <!-- Note the strong assumption that "BUILD_HOME" is the same
           value when running this 'clean' target, as when
           the directories were created.
      -->
    <delete
      dir="${BUILD_HOME}/localPrereqs"
      includeemptydirs="true" />
    <delete
      dir="${BUILD_HOME}/eclipseInstall"
      includeemptydirs="true" />
    <delete
      dir="${BUILD_HOME}/tmp"
      includeemptydirs="true" />
    <delete
      dir="${BUILD_HOME}/aggregation"
      includeemptydirs="true" />
  </target>

</project>

Back to the top