forked from JetBrains/kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
1338 lines (1168 loc) · 62.7 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<project name="Kotlin" default="dist" xmlns:if="ant:if" xmlns:unless="ant:unless">
<import file="common.xml" optional="false"/>
<property file="resources/kotlinManifest.properties"/>
<!-- Set to false to disable proguard run on kotlin-compiler.jar. Speeds up the build -->
<property name="shrink" value="true"/>
<!-- Set to false to disable compiler's javadoc generation. Speeds up the build -->
<property name="generate.javadoc" value="true"/>
<!-- Set to false to prevent jarjar and metadata stripping on kotlin-reflect.jar and reflection sources. Use to debug reflection -->
<property name="obfuscate.reflect" value="true"/>
<property name="max.heap.size.for.forked.jvm" value="1024m"/>
<property name="bootstrap.home" value="${basedir}/dependencies/bootstrap-compiler"/>
<property name="bootstrap.compiler.home" value="${bootstrap.home}/Kotlin/kotlinc"/>
<property name="bootstrap.runtime" value="${bootstrap.compiler.home}/lib/kotlin-runtime.jar"/>
<property name="bootstrap.reflect" value="${bootstrap.compiler.home}/lib/kotlin-reflect.jar"/>
<property name="bootstrap.script.runtime" value="${bootstrap.compiler.home}/lib/kotlin-script-runtime.jar"/>
<property name="bootstrap.kotlin.test" value="${bootstrap.compiler.home}/lib/kotlin-test.jar" />
<property name="intermediate-sources" value="out/src" />
<property name="kotlin-home" value="${output}/kotlinc"/>
<property name="build.number" value="snapshot"/>
<property name="bootstrap.build.no.tests" value="false"/>
<property name="idea.sdk" value="${basedir}/ideaSDK"/>
<property name="protobuf.jar" value="${basedir}/dependencies/protobuf-2.6.1.jar"/>
<property name="protobuf-lite.jar" value="${basedir}/dependencies/protobuf-2.6.1-lite.jar"/>
<property name="javax.inject.jar" value="${basedir}/lib/javax.inject.jar"/>
<property name="java.target" value="1.6"/>
<condition property="bootstrap.or.local.build" value="true">
<or>
<istrue value="${bootstrap.build.no.tests}"/>
<not>
<isset property="teamcity.version"/>
</not>
</or>
</condition>
<include file="jslib_files.xml" />
<property name="compiled.stdlib.js" value="stdlib.js"/>
<property name="compiled.stdlib.meta.js" value="kotlin.meta.js"/>
<property name="stdlib.js.dir" value="${basedir}/js/js.translator/testData"/>
<!--
The compiler produced on the first step of the build (Bootstrap No Tests) is only guaranteed to work against the OLD runtime
located in dependencies/bootstrap-compiler/.../kotlin-runtime.jar, because the newly built compiler is just a Kotlin application,
compiled by the old compiler with the old runtime in classpath. If you advance the ABI version, the newly built compiler will NOT work
against the runtime it will produce on its own because they have different ABI versions.
So on the first step of bootstrap we copy that runtime to kotlin-runtime-internal-bootstrap.jar (see 'prepare-dist' target) and change
the compiler classpath accordingly. On the second step this is believed to be not required, because there are
little to no differences between the new and the newest runtime.
-->
<condition property="compiler.manifest.class.path"
value="kotlin-runtime-internal-bootstrap.jar kotlin-reflect-internal-bootstrap.jar kotlin-script-runtime-internal-bootstrap.jar"
else="kotlin-runtime.jar kotlin-reflect.jar kotlin-script-runtime.jar">
<istrue value="${bootstrap.or.local.build}"/>
</condition>
<path id="classpath">
<file file="${bootstrap.runtime}"/>
<file file="${bootstrap.kotlin.test}" />
<file file="${bootstrap.reflect}"/>
<file file="${bootstrap.script.runtime}"/>
<fileset dir="${idea.sdk}" includes="core/*.jar"/>
<pathelement location="${protobuf.jar}"/>
<fileset dir="${basedir}/lib" includes="**/*.jar"/>
<fileset dir="${dependencies}" includes="jansi.jar"/>
<fileset dir="${dependencies}" includes="jline.jar"/>
<fileset dir="${dependencies}" includes="cli-parser-1.1.2.jar"/>
<fileset dir="${basedir}/ideaSDK/jps" includes="jps-model.jar"/>
</path>
<typedef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${bootstrap.compiler.home}/lib/kotlin-ant.jar"/>
<path id="javac2.classpath">
<pathelement location="${idea.sdk}/lib/javac2.jar"/>
<pathelement location="${idea.sdk}/lib/asm-all.jar"/>
</path>
<taskdef name="javac2" classname="com.intellij.ant.Javac2" classpathref="javac2.classpath" loaderref="javac2.loader"/>
<typedef name="skip" classname="com.intellij.ant.ClassFilterAnnotationRegexp" classpathref="javac2.classpath" loaderref="javac2.loader"/>
<dirset id="compilerSources.dirset" dir="${basedir}/">
<include name="core/descriptor.loader.java/src"/>
<include name="core/descriptors/src"/>
<include name="core/deserialization/src"/>
<include name="core/util.runtime/src"/>
<include name="compiler/backend/src"/>
<include name="compiler/backend-common/src"/>
<include name="compiler/ir/backend.common/src"/>
<include name="compiler/ir/backend.jvm/src"/>
<include name="compiler/ir/ir.psi2ir/src"/>
<include name="compiler/ir/ir.tree/src"/>
<include name="compiler/builtins-serializer/src"/>
<include name="compiler/cli/src"/>
<include name="compiler/cli/cli-common/src"/>
<include name="compiler/conditional-preprocessor/src/"/>
<include name="compiler/container/src"/>
<include name="compiler/frontend/src"/>
<include name="compiler/resolution/src"/>
<include name="compiler/frontend.java/src"/>
<include name="compiler/light-classes/src"/>
<include name="compiler/plugin-api/src"/>
<include name="compiler/daemon/src"/>
<include name="compiler/daemon/daemon-common/src"/>
<include name="build-common/src"/>
<include name="compiler/incremental-compilation-impl/src"/>
<include name="compiler/serialization/src"/>
<include name="compiler/util/src"/>
<include name="js/js.dart-ast/src"/>
<include name="js/js.translator/src"/>
<include name="js/js.frontend/src"/>
<include name="js/js.inliner/src"/>
<include name="js/js.parser/src"/>
<include name="js/js.serializer/src"/>
<include name="plugins/annotation-collector/src"/>
</dirset>
<property name="idea.out" value="${basedir}/out/production"/>
<patternset id="compilerClassesFromIDEA.fileset">
<include name="frontend/**"/>
<include name="resolution/**"/>
<include name="container/**"/>
<include name="descriptors/**"/>
<include name="deserialization/**"/>
<include name="serialization/**"/>
<include name="descriptor.loader.java/**"/>
<include name="frontend.java/**"/>
<include name="backend/**"/>
<include name="backend-common/**"/>
<include name="backend.common/**"/>
<include name="backend.jvm/**"/>
<include name="ir.psi2ir/**"/>
<include name="ir.tree/**"/>
<include name="cli/**"/>
<include name="cli-common/**"/>
<include name="conditional-preprocessor/**"/>
<include name="daemon/**"/>
<include name="daemon-common/**"/>
<include name="build-common/**"/>
<include name="incremental-compilation-impl/**"/>
<include name="util/**"/>
<include name="util.runtime/**"/>
<include name="light-classes/**"/>
<include name="plugin-api/**"/>
<include name="annotation-collector/**"/>
<include name="builtins-serializer/**"/>
<include name="js.dart-ast/**"/>
<include name="js.translator/**"/>
<include name="js.frontend/**"/>
<include name="js.inliner/**"/>
<include name="js.parser/**"/>
<include name="js.serializer/**"/>
</patternset>
<path id="compilerSources.path">
<dirset refid="compilerSources.dirset"/>
</path>
<macrodef name="cleandir">
<attribute name="dir"/>
<sequential>
<echo message="Cleaning @{dir}"/>
<delete dir="@{dir}" failonerror="false"/>
<mkdir dir="@{dir}"/>
</sequential>
</macrodef>
<target name="clean">
<delete dir="${output}"/>
</target>
<target name="clean_idea_output">
<delete dir="${basedir}/out"/>
</target>
<target name="init">
<mkdir dir="${kotlin-home}"/>
<mkdir dir="${kotlin-home}/lib"/>
</target>
<target name="prepare-dist">
<copy todir="${kotlin-home}/bin">
<fileset dir="${basedir}/compiler/cli/bin"/>
</copy>
<fixcrlf srcdir="${kotlin-home}/bin" excludes="**/*.bat" eol="unix"/>
<copy todir="${kotlin-home}/license">
<fileset dir="${basedir}/license"/>
</copy>
<echo file="${kotlin-home}/build.txt" message="${build.number}"/>
<chmod dir="${kotlin-home}/bin" excludes="**/*.bat" perm="755"/>
<sequential if:true="${bootstrap.or.local.build}">
<copy file="${bootstrap.runtime}" tofile="${kotlin-home}/lib/kotlin-runtime-internal-bootstrap.jar"/>
<copy file="${bootstrap.reflect}" tofile="${kotlin-home}/lib/kotlin-reflect-internal-bootstrap.jar"/>
<copy file="${bootstrap.script.runtime}" tofile="${kotlin-home}/lib/kotlin-script-runtime-internal-bootstrap.jar"/>
<copy file="${bootstrap.kotlin.test}" tofile="${kotlin-home}/lib/kotlin-test-internal-bootstrap.jar" failonerror="false"/>
<jar destfile="${kotlin-home}/lib/kotlin-reflect-internal-bootstrap.jar" update="true">
<manifest>
<attribute name="Class-Path" value="kotlin-runtime-internal-bootstrap.jar"/>
</manifest>
</jar>
<jar destfile="${kotlin-home}/lib/kotlin-test-internal-bootstrap.jar" update="true">
<manifest>
<attribute name="Class-Path" value="kotlin-runtime-internal-bootstrap.jar"/>
</manifest>
</jar>
</sequential>
<sequential unless:true="${bootstrap.or.local.build}">
<copy file="${bootstrap.runtime}" todir="${kotlin-home}/lib"/>
<copy file="${bootstrap.reflect}" todir="${kotlin-home}/lib"/>
<copy file="${bootstrap.script.runtime}" todir="${kotlin-home}/lib"/>
<copy file="${bootstrap.kotlin.test}" todir="${kotlin-home}/lib"/>
</sequential>
</target>
<target name="copy-dist-to-bootstrap">
<delete dir="${basedir}/dependencies/bootstrap-compiler/Kotlin/kotlinc" />
<copy todir="${basedir}/dependencies/bootstrap-compiler/Kotlin/kotlinc">
<fileset dir="${basedir}/dist/kotlinc" />
</copy>
</target>
<target name="compiler-sources">
<jar jarfile="${output}/kotlin-compiler-sources.jar">
<!-- TODO How to convert it from pathset or dirset ? -->
<fileset dir="core/descriptor.loader.java/src"/>
<fileset dir="core/descriptors/src"/>
<fileset dir="core/deserialization/src"/>
<fileset dir="core/util.runtime/src"/>
<fileset dir="compiler/backend/src"/>
<fileset dir="compiler/backend-common/src"/>
<fileset dir="compiler/ir/backend.common/src"/>
<fileset dir="compiler/ir/backend.jvm/src"/>
<fileset dir="compiler/ir/ir.psi2ir/src"/>
<fileset dir="compiler/ir/ir.tree/src"/>
<fileset dir="compiler/builtins-serializer/src"/>
<fileset dir="compiler/cli/src"/>
<fileset dir="compiler/cli/cli-common/src"/>
<fileset dir="compiler/conditional-preprocessor/src"/>
<fileset dir="compiler/daemon/src"/>
<fileset dir="compiler/daemon/daemon-common/src"/>
<fileset dir="build-common/src"/>
<fileset dir="compiler/incremental-compilation-impl/src"/>
<fileset dir="compiler/container/src"/>
<fileset dir="compiler/frontend/src"/>
<fileset dir="compiler/resolution/src"/>
<fileset dir="compiler/frontend.java/src"/>
<fileset dir="compiler/light-classes/src"/>
<fileset dir="compiler/plugin-api/src"/>
<fileset dir="plugins/annotation-collector/src"/>
<fileset dir="compiler/serialization/src"/>
<fileset dir="compiler/util/src"/>
<fileset dir="js/js.dart-ast/src"/>
<fileset dir="js/js.translator/src"/>
<fileset dir="js/js.frontend/src"/>
<fileset dir="js/js.inliner/src"/>
<fileset dir="js/js.parser/src"/>
<fileset dir="js/js.serializer/src"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.compiler.sources}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
<sequential if:true="${generate.javadoc}">
<delete dir="${output}/kotlin-compiler-javadoc" failonerror="false"/>
<javadoc destdir="${output}/kotlin-compiler-javadoc"
sourcepathref="compilerSources.path"
classpathref="classpath"
linksource="yes"
windowtitle="${manifest.impl.title.kotlin.compiler}"/>
<jar jarfile="${output}/kotlin-compiler-javadoc.jar">
<fileset dir="${output}/kotlin-compiler-javadoc"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.compiler.javadoc}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
</sequential>
<sequential unless:true="${generate.javadoc}">
<jar jarfile="${output}/kotlin-compiler-javadoc.jar">
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.compiler.javadoc}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
</sequential>
</target>
<macrodef name="new-kotlin2js">
<attribute name="output"/>
<element name="src"/>
<sequential>
<local name="src.line"/>
<path id="src.path">
<src/>
</path>
<pathconvert property="src.line" refid="src.path" pathsep=" "/>
<java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true"
maxmemory="${max.heap.size.for.forked.jvm}">
<classpath>
<pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
</classpath>
<assertions>
<enable/>
</assertions>
<arg value="-cp"/>
<arg value="${kotlin-home}/lib/kotlin-compiler.jar"/>
<arg value="org.jetbrains.kotlin.cli.js.K2JSCompiler"/>
<arg line="${src.line}"/>
<arg value="-output"/>
<arg value="@{output}"/>
<arg value="-no-stdlib"/>
<arg value="-version"/>
<arg value="-meta-info"/>
<arg value="-kjsm"/>
<arg line="-main noCall"/>
<arg line="-module-kind commonjs"/>
</java>
</sequential>
</macrodef>
<target name="js-stdlib-merge">
<!-- value should be one of: whitespace, simple, advanced -->
<property name="compilationLevel" value="whitespace"/>
<!-- value should be one of: default, quiet, verbose -->
<property name="warningLevel" value="default"/>
<taskdef name="closure-compiler"
classname="com.google.javascript.jscomp.ant.CompileTask"
classpath="${dependencies}/closure-compiler.jar"/>
<closure-compiler
compilationLevel="${compilationLevel}"
prettyprint="true"
languagein="ECMASCRIPT5_STRICT"
warning="${warningLevel}"
output="${js.stdlib.output.dir}/kotlin.js"
outputWrapperFile="${stdlib.js.dir}/closure-wrapper.txt">
<sources dir="${stdlib.js.dir}">
<file name="kotlin_lib_ecma5.js"/>
<file name="kotlin_lib.js"/>
<file name="long.js"/>
</sources>
<sources dir="${js.stdlib.output.dir}">
<file name="builtins.js"/>
<file name="${compiled.stdlib.js}"/>
</sources>
<externs dir="${stdlib.js.dir}">
<file name="externs.js"/>
</externs>
</closure-compiler>
<!--
Few hacks to compose one kotlin.js from several smaller files:
1. Wrapper function takes Kotlin and _, whereas they are already defined above (see closure-wrapper.txt), so delete these
parameters.
2. Since we deleted parameters, we can get rid or arguments passed to wrapper function.
They are module.exports and require("Kotlin"), accordingly to CommonJS spec.
3. We can omit return _, since it's already exported by the code in UMD wrapper.
-->
<replaceregexp file="${js.stdlib.output.dir}/kotlin.js"
match="module.exports,\s*require\([^)]+\)"
replace=""
byline="true" encoding="UTF-8" />
<replaceregexp file="${js.stdlib.output.dir}/kotlin.js"
match="function\s*\(_,\s*Kotlin\)"
replace="function()"
byline="true" encoding="UTF-8" />
<replaceregexp file="${js.stdlib.output.dir}/kotlin.js"
match="return\s+_;"
replace=""
byline="true" encoding="UTF-8" />
</target>
<target name="js-stdlib">
<property environment="env"/>
<kotlin-pp src="libraries/stdlib/src" output="${intermediate-sources}/stdlib/js" profile="JS" />
<!-- We don't want descriptors for built-ins to be serialized, so we compile these files separately. -->
<new-kotlin2js output="${js.stdlib.output.dir}/tmp-builtins/kotlin.js">
<src>
<union>
<resources refid="kotlin.builtin.native.files"/>
</union>
</src>
</new-kotlin2js>
<new-kotlin2js output="${js.stdlib.output.dir}/tmp/kotlin.js">
<src>
<union>
<fileset refid="kotlin.builtin.files"/>
<resources refid="js.lib.files"/>
</union>
</src>
</new-kotlin2js>
<move file="${js.stdlib.output.dir}/tmp-builtins/kotlin.js" tofile="${js.stdlib.output.dir}/builtins.js" />
<move file="${js.stdlib.output.dir}/tmp/kotlin.js" tofile="${js.stdlib.output.dir}/${compiled.stdlib.js}" />
<move file="${js.stdlib.output.dir}/tmp/kotlin" todir="${js.stdlib.output.dir}" />
<move file="${js.stdlib.output.dir}/tmp/${compiled.stdlib.meta.js}" tofile="${js.stdlib.output.dir}/${compiled.stdlib.meta.js}" />
<condition property="jdk17" value="${env.JDK_17}" else="${env.JAVA_HOME}">
<isset property="env.JDK_17" />
</condition>
<java classname="org.apache.tools.ant.launch.Launcher"
fork="true"
failonerror="true"
timeout="4000000"
taskname="startAnt"
jvm="${jdk17}/bin/java">
<env key="JAVA_HOME" value="${jdk17}"/>
<classpath>
<pathelement location="${ant.home}/lib/ant-launcher.jar"/>
</classpath>
<arg line="-f" />
<arg line="build.xml" />
<arg line="js-stdlib-merge" />
</java>
<jar jarfile="${kotlin-home}/lib/kotlin-jslib.jar" duplicate="fail">
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<zipfileset dir="${js.stdlib.output.dir}" prefix="">
<include name="kotlin.js"/>
<include name="${compiled.stdlib.meta.js}"/>
<include name="kotlin/**"/>
</zipfileset>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="${manifest.impl.attribute.kotlin.version}" value="${manifest.impl.value.kotlin.version}"/>
<attribute name="${manifest.impl.attribute.kotlin.runtime.component}" value="${manifest.impl.value.kotlin.runtime.component.core}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.javascript.stdlib}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
<attribute name="Specification-Title" value="${manifest.spec.title.kotlin.javascript.lib}"/>
</manifest>
</jar>
</target>
<target name="pack-js-stdlib-sources">
<jar destfile="${kotlin-home}/lib/kotlin-jslib-sources.jar" duplicate="fail">
<resources refid="js.lib.files" />
<fileset refid="kotlin.builtin.files" />
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="${manifest.impl.attribute.kotlin.version}" value="${manifest.impl.value.kotlin.version}"/>
<attribute name="${manifest.impl.attribute.kotlin.runtime.component}" value="${manifest.impl.value.kotlin.runtime.component.core}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.jvm.runtime.sources}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
</target>
<target name="kotlin-js-stdlib" depends="js-stdlib,pack-js-stdlib-sources"/>
<target name="preloader">
<cleandir dir="${output}/classes/preloader"/>
<javac destdir="${output}/classes/preloader" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<src location="${basedir}/compiler/preloader/src"/>
</javac>
<jar jarfile="${kotlin-home}/lib/kotlin-preloader.jar">
<fileset dir="${output}/classes/preloader"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.preloader}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
<attribute name="Main-Class" value="org.jetbrains.kotlin.preloading.Preloader"/>
</manifest>
</jar>
</target>
<target name="runner">
<cleandir dir="${output}/classes/runner"/>
<kotlinc output="${output}/classes/runner">
<src location="${basedir}/compiler/cli/cli-runner/src"/>
</kotlinc>
<local name="runtime.jar"/>
<condition property="runtime.jar" value="kotlin-runtime-internal-bootstrap.jar" else="kotlin-runtime.jar">
<istrue value="${bootstrap.or.local.build}"/>
</condition>
<jar jarfile="${kotlin-home}/lib/kotlin-runner.jar">
<fileset dir="${output}/classes/runner"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.runner}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
<attribute name="Main-Class" value="org.jetbrains.kotlin.runner.Main"/>
<attribute name="Class-Path" value="${runtime.jar}"/>
</manifest>
</jar>
</target>
<target name="serialize-builtins">
<cleandir dir="${output}/builtins"/>
<java classname="org.jetbrains.kotlin.preloading.Preloader"
classpath="${bootstrap.compiler.home}/lib/kotlin-preloader.jar"
failonerror="true"
fork="true"
maxmemory="${max.heap.size.for.forked.jvm}">
<assertions>
<enable/>
</assertions>
<arg value="-cp"/>
<arg value="${bootstrap.compiler.home}/lib/kotlin-compiler.jar"/>
<arg value="org.jetbrains.kotlin.serialization.builtins.RunKt"/>
<arg value="${output}/builtins"/>
<arg value="core/builtins/native"/>
<arg value="core/builtins/src"/>
</java>
</target>
<macrodef name="pack-compiler">
<attribute name="jarfile"/>
<attribute name="compress" default="true"/>
<sequential>
<jar jarfile="@{jarfile}" compress="@{compress}" duplicate="preserve">
<fileset dir="${output}/classes/compiler"/>
<fileset dir="${output}/builtins">
<include name="kotlin/**"/>
</fileset>
<fileset dir="${basedir}/core/descriptor.loader.java/src" includes="META-INF/services/**"/>
<fileset dir="${basedir}/compiler/frontend.java/src" includes="META-INF/services/**"/>
<fileset dir="${basedir}/compiler/backend/src" includes="META-INF/services/**"/>
<fileset dir="${basedir}/compiler/cli/src" includes="META-INF/services/**"/>
<fileset dir="${basedir}/resources" includes="kotlinManifest.properties"/>
<fileset dir="idea/src">
<include name="META-INF/extensions/common.xml"/>
<include name="META-INF/extensions/kotlin2jvm.xml"/>
<include name="META-INF/extensions/kotlin2js.xml"/>
</fileset>
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
<zipgroupfileset dir="${basedir}/ideaSDK/core" includes="*.jar" excludes="util.jar"/>
<zipfileset src="${idea.sdk}/lib/jna-platform.jar"/>
<zipfileset src="${idea.sdk}/lib/oromatcher.jar"/>
<zipfileset src="${idea.sdk}/jps/jps-model.jar"/>
<zipfileset src="${dependencies}/jline.jar"/>
<zipfileset src="${dependencies}/cli-parser-1.1.2.jar"/>
<zipfileset src="${protobuf.jar}"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.compiler}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
<attribute name="Class-Path" value="${compiler.manifest.class.path}"/>
<attribute name="Main-Class" value="org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"/>
</manifest>
</jar>
</sequential>
</macrodef>
<target name="compiler-quick">
<delete dir="${output}/classes/compiler"/>
<copy todir="${output}/classes/compiler">
<fileset dir="${idea.out}/">
<patternset refid="compilerClassesFromIDEA.fileset"/>
</fileset>
<!-- out/production contains classes under module directories, here we are merging them all into one root-->
<cutdirsmapper dirs="1"/>
</copy>
<delete file="${kotlin-home}/lib/kotlin-compiler.jar"/>
<pack-compiler jarfile="${kotlin-home}/lib/kotlin-compiler.jar" compress="false"/>
</target>
<target name="compiler">
<taskdef resource="proguard/ant/task.properties">
<classpath>
<pathelement path="${dependencies}/proguard.jar"/>
<pathelement path="${dependencies}/proguard-anttask.jar"/>
</classpath>
</taskdef>
<cleandir dir="${output}/classes/compiler"/>
<javac2 destdir="${output}/classes/compiler" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<withKotlin modulename="kotlin-compiler">
<compilerarg value="-version"/>
</withKotlin>
<skip pattern="kotlin/Metadata"/>
<src refid="compilerSources.path"/>
<classpath refid="classpath"/>
</javac2>
<pack-compiler jarfile="${output}/kotlin-compiler-before-shrink.jar"/>
<delete file="${kotlin-home}/lib/kotlin-compiler.jar" failonerror="false"/>
<copy file="${output}/kotlin-compiler-before-shrink.jar"
tofile="${kotlin-home}/lib/kotlin-compiler.jar"
unless:true="${shrink}" />
<sequential if:true="${shrink}">
<available property="rtjar" value="${java.home}/lib/rt.jar" file="${java.home}/lib/rt.jar"/>
<available property="rtjar" value="${java.home}/../Classes/classes.jar" file="${java.home}/../Classes/classes.jar"/>
<available property="jssejar" value="${java.home}/lib/jsse.jar" file="${java.home}/lib/jsse.jar"/>
<available property="jssejar" value="${java.home}/../Classes/jsse.jar" file="${java.home}/../Classes/jsse.jar"/>
<proguard configuration="${basedir}/compiler/compiler.pro"/>
</sequential>
<pack-compiler-for-maven/>
</target>
<macrodef name="pack-compiler-for-maven">
<sequential>
<jar jarfile="${output}/kotlin-compiler-for-maven.jar" duplicate="preserve">
<patternset id="lib.metainf.patternset">
<include name="**"/>
<exclude name="META-INF/build.txt"/>
<exclude name="META-INF/MANIFEST.MF"/>
</patternset>
<!-- TODO: don't include both to the jar: it's impossible to test changes to core in the local maven build without bootstrap -->
<zipfileset src="${kotlin-home}/lib/kotlin-compiler.jar" includes="**"/>
<zipfileset src="${bootstrap.runtime}">
<patternset refid="lib.metainf.patternset"/>
</zipfileset>
<zipfileset src="${bootstrap.reflect}">
<patternset refid="lib.metainf.patternset"/>
</zipfileset>
<zipfileset src="${bootstrap.script.runtime}">
<patternset refid="lib.metainf.patternset"/>
</zipfileset>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.compiler}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
<attribute name="Main-Class" value="org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"/>
</manifest>
</jar>
</sequential>
</macrodef>
<target name="compiler-for-maven">
<pack-compiler-for-maven/>
</target>
<target name="kotlin-build-common-test">
<cleandir dir="${output}/classes/kotlin-build-common-test"/>
<javac2 destdir="${output}/classes/kotlin-build-common-test" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<withKotlin modulename="kotlin-build-common"/>
<skip pattern="kotlin/Metadata"/>
<src>
<pathelement path="build-common/test"/>
<pathelement path="compiler/incremental-compilation-impl/test"/>
</src>
<classpath>
<pathelement path="${bootstrap.runtime}"/>
<pathelement path="${bootstrap.reflect}"/>
<pathelement path="${bootstrap.script.runtime}"/>
<pathelement path="${bootstrap.kotlin.test}"/>
<pathelement path="${protobuf.jar}"/>
<pathelement path="${idea.sdk}/lib/junit-4.12.jar"/>
<pathelement path="${kotlin-home}/lib/kotlin-compiler.jar"/>
</classpath>
</javac2>
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="dependencies/jarjar.jar"/>
<jarjar jarfile="${kotlin-home}/lib/kotlin-build-common-test.jar">
<fileset dir="${output}/classes/kotlin-build-common-test"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<zipfileset src="${protobuf.jar}"/>
<rule pattern="com.intellij.**" result="org.jetbrains.kotlin.com.intellij.@1"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.build.common}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jarjar>
</target>
<target name="daemon-client">
<cleandir dir="${output}/classes/daemon-client"/>
<kotlinc output="${output}/classes/daemon-client" modulename="client">
<src>
<pathelement path="compiler/daemon/daemon-client/src"/>
</src>
<classpath>
<pathelement path="${kotlin-home}/lib/kotlin-compiler.jar"/>
<pathelement path="${dependencies}/native-platform-uberjar.jar"/>
</classpath>
</kotlinc>
<jar destfile="${kotlin-home}/lib/kotlin-daemon-client.jar">
<fileset dir="${output}/classes/daemon-client"/>
<zipfileset src="${dependencies}/native-platform-uberjar.jar" includes="**" />
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.daemon-client}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
<jar jarfile="${output}/kotlin-daemon-client-sources.jar">
<fileset dir="compiler/daemon/daemon-common/src"/>
<fileset dir="compiler/daemon/daemon-client/src"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.daemon.client.sources}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
</target>
<target name="android-extensions-compiler">
<cleandir dir="${output}/classes/android-extensions/android-extensions-compiler"/>
<javac2 destdir="${output}/classes/android-extensions/android-extensions-compiler" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false">
<withKotlin modulename="kotlin-android-extensions-compiler">
<compilerarg value="-version"/>
</withKotlin>
<skip pattern="kotlin/Metadata"/>
<src>
<pathelement path="plugins/android-extensions/android-extensions-compiler/src"/>
</src>
<classpath>
<pathelement path="${idea.sdk}/core/intellij-core.jar"/>
<pathelement path="${kotlin-home}/lib/kotlin-compiler.jar"/>
</classpath>
</javac2>
<jar destfile="${kotlin-home}/lib/android-extensions-compiler.jar">
<fileset dir="${output}/classes/android-extensions/android-extensions-compiler"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<fileset dir="${basedir}/plugins/android-extensions/android-extensions-compiler/src" includes="META-INF/services/**"/>
</jar>
</target>
<target name="allopen-compiler-plugin">
<cleandir dir="${output}/classes/allopen-compiler-plugin"/>
<javac2 destdir="${output}/classes/allopen-compiler-plugin" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false">
<withKotlin modulename="allopen">
<compilerarg value="-version"/>
</withKotlin>
<skip pattern="kotlin/Metadata"/>
<src>
<pathelement path="plugins/allopen/allopen-cli/src"/>
</src>
<classpath>
<pathelement path="${idea.sdk}/core/intellij-core.jar"/>
<pathelement path="${kotlin-home}/lib/kotlin-compiler.jar"/>
</classpath>
</javac2>
<jar destfile="${kotlin-home}/lib/allopen-compiler-plugin.jar">
<fileset dir="${output}/classes/allopen-compiler-plugin"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<fileset dir="${basedir}/plugins/allopen/allopen-cli/src" includes="META-INF/services/**"/>
</jar>
</target>
<target name="noarg-compiler-plugin">
<cleandir dir="${output}/classes/noarg-compiler-plugin"/>
<javac2 destdir="${output}/classes/noarg-compiler-plugin" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false">
<withKotlin modulename="noarg">
<compilerarg value="-version"/>
</withKotlin>
<skip pattern="kotlin/Metadata"/>
<src>
<pathelement path="plugins/noarg/noarg-cli/src"/>
</src>
<classpath>
<pathelement path="${idea.sdk}/core/intellij-core.jar"/>
<pathelement path="${kotlin-home}/lib/kotlin-compiler.jar"/>
</classpath>
</javac2>
<jar destfile="${kotlin-home}/lib/noarg-compiler-plugin.jar">
<fileset dir="${output}/classes/noarg-compiler-plugin"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<fileset dir="${basedir}/plugins/noarg/noarg-cli/src" includes="META-INF/services/**"/>
</jar>
</target>
<target name="sam-with-receiver-compiler-plugin">
<cleandir dir="${output}/classes/sam-with-receiver-compiler-plugin"/>
<javac2 destdir="${output}/classes/sam-with-receiver-compiler-plugin" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false">
<withKotlin modulename="noarg">
<compilerarg value="-version"/>
</withKotlin>
<skip pattern="kotlin/Metadata"/>
<src>
<pathelement path="plugins/sam-with-receiver/sam-with-receiver-cli/src"/>
</src>
<classpath>
<pathelement path="${idea.sdk}/core/intellij-core.jar"/>
<pathelement path="${kotlin-home}/lib/kotlin-compiler.jar"/>
</classpath>
</javac2>
<jar destfile="${kotlin-home}/lib/sam-with-receiver-compiler-plugin.jar">
<fileset dir="${output}/classes/sam-with-receiver-compiler-plugin"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<fileset dir="${basedir}/plugins/sam-with-receiver/sam-with-receiver-cli/src" includes="META-INF/services/**"/>
</jar>
</target>
<target name="annotation-processing-under-jdk8">
<property environment="env"/>
<condition property="jdk18" value="${env.JDK_18}" else="${env.JAVA_HOME}">
<isset property="env.JDK_18" />
</condition>
<java classname="org.apache.tools.ant.launch.Launcher"
fork="true"
failonerror="true"
timeout="4000000"
taskname="startAnt"
jvm="${jdk18}/bin/java">
<env key="JAVA_HOME" value="${jdk18}"/>
<classpath>
<pathelement location="${ant.home}/lib/ant-launcher.jar"/>
</classpath>
<arg line="-f" />
<arg line="build.xml" />
<arg line="annotation-processing" />
</java>
</target>
<target name="annotation-processing">
<cleandir dir="${output}/classes/annotation-processing"/>
<property environment="env"/>
<javac2 destdir="${output}/classes/annotation-processing" debug="true" debuglevel="lines,vars,source"
includeAntRuntime="false" source="${java.target}" target="${java.target}">
<withKotlin modulename="annotation-processing">
<compilerarg value="-version"/>
</withKotlin>
<skip pattern="kotlin/Metadata"/>
<src>
<pathelement path="plugins/kapt3/src"/>
</src>
<classpath>
<!-- JAVA_HOME is set in annotation-processing-under-jdk8 -->
<pathelement path="${env.JAVA_HOME}/lib/tools.jar"/>
<pathelement path="${idea.sdk}/core/intellij-core.jar"/>
<pathelement path="${kotlin-home}/lib/kotlin-compiler.jar"/>
<pathelement path="${bootstrap.runtime}"/>
<pathelement path="${bootstrap.reflect}"/>
<pathelement path="${bootstrap.script.runtime}"/>
</classpath>
</javac2>
<jar destfile="${kotlin-home}/lib/kotlin-annotation-processing.jar">
<fileset dir="${output}/classes/annotation-processing"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<fileset dir="${basedir}/plugins/kapt3/src" includes="META-INF/services/**"/>
</jar>
</target>
<target name="ant-tools">
<cleandir dir="${output}/classes/ant"/>
<javac2 destdir="${output}/classes/ant" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
source="${java.target}" target="${java.target}">
<withKotlin modulename="kotlin-ant-tools">
<compilerarg value="-version"/>
</withKotlin>
<skip pattern="kotlin/Metadata"/>
<src>
<dirset dir="${basedir}/ant">
<include name="src"/>
</dirset>
</src>
<compilerarg value="-Xlint:all"/>
<classpath>
<pathelement location="${dependencies}/ant-1.8/lib/ant.jar"/>
<pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
</classpath>
</javac2>
<jar destfile="${kotlin-home}/lib/kotlin-ant.jar">
<fileset dir="${output}/classes/ant"/>
<fileset dir="${basedir}/ant/src" includes="**/*.xml"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.compiler.ant.task}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
<attribute name="Class-Path" value="${compiler.manifest.class.path} kotlin-preloader.jar"/>
</manifest>
</jar>
</target>
<macrodef name="new-kotlinc">
<attribute name="output"/>
<attribute name="moduleName"/>
<attribute name="additionalOptions" default=""/>
<element name="src"/>
<element name="class-path"/>
<sequential>
<cleandir dir="@{output}"/>
<dirset dir="${basedir}" id="src.dirset">
<src/>
</dirset>
<path id="classpath.path">
<class-path/>
</path>
<!-- Source paths separated by space (to pass to "arg line" below) -->
<local name="src.line"/>
<pathconvert property="src.line" refid="src.dirset" pathsep=" "/>
<java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true" maxmemory="${max.heap.size.for.forked.jvm}">
<classpath>
<pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
</classpath>
<assertions>
<enable/>
</assertions>
<arg value="-cp"/>
<arg value="${kotlin-home}/lib/kotlin-compiler.jar"/>
<arg value="org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"/>
<arg line="${src.line}"/>
<arg value="-d"/>
<arg value="@{output}"/>
<arg value="-no-stdlib"/>
<arg value="-version"/>
<arg line="@{additionalOptions}"/>
<arg value="-classpath"/>
<arg value="${toString:classpath.path}"/>
<arg value="-module-name"/>
<arg value="@{moduleName}"/>
<arg value="-Xallow-kotlin-package"/>
</java>