-
Notifications
You must be signed in to change notification settings - Fork 399
/
build.sbt
991 lines (898 loc) · 42.2 KB
/
build.sbt
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
import Common.*
import CompilationCache.compilationCacheSettings
import Dependencies.provided
import DynamicDependenciesFetcher.*
import LocalRepoPackager.{localRepoDependencies, localRepoUpdate, relativeJarPath, sbtDep}
import org.jetbrains.sbtidea.Keys.*
import org.jetbrains.sbtidea.PluginJars
import java.nio.file.Path
// Global build settings
(ThisBuild / intellijPluginName) := "Scala"
(ThisBuild / intellijBuild) := Versions.intellijVersion
(ThisBuild / intellijPlatform) := (Global / intellijPlatform).??(IntelliJPlatform.IdeaCommunity).value
ThisBuild / resolvers := {
// not exactly sure why "releases" and "staging" would ever need to be enabled
// Resolver.sonatypeOssRepos("releases") ++
// Resolver.sonatypeOssRepos("staging") ++
// enable if you need to resolve SNAPSHOT versions of open source libraries
// Resolver.sonatypeOssRepos("snapshots") ++
// enable if you need to resolve Scala 2.12, 2.13 RC versions
// Seq(
// "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/"
// ) ++
Seq(
"JetBrains Maven Central" at "https://cache-redirector.jetbrains.com/maven-central"
)
}
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
(Global / javacOptions) := globalJavacOptions
(Global / scalacOptions) := globalScalacOptions
// Muted lint warnings for keys used by the IDE, but not by sbt (coming from sbt-ide-settings)
Global / excludeLintKeys ++= Set(idePackagePrefix, ideSkipProject, ideExcludedDirectories, ideaConfigOptions)
val definedTestsScopeFilter: ScopeFilter =
ScopeFilter(inDependencies(scalaCommunity, includeRoot = false), inConfigurations(Test))
// Main projects
lazy val scalaCommunity: sbt.Project =
newProject("scalaCommunity", file("."))
.dependsOn(
bsp % "test->test;compile->compile",
codeInsight % "test->test;compile->compile",
conversion % "test->test;compile->compile",
uast % "test->test;compile->compile",
worksheet % "test->test;compile->compile",
scalaImpl % "test->test;compile->compile",
structureView % "test->test;compile->compile",
sbtImpl % "test->test;compile->compile",
compilerIntegration % "test->test;compile->compile",
debugger % "test->test;compile->compile",
testingSupport % "test->test;compile->compile",
devKitIntegration % "test->test;compile->compile",
gradleIntegration % "test->test;compile->compile",
intelliLangIntegration % "test->test;compile->compile",
mavenIntegration % "test->test;compile->compile",
junitIntegration % "test->test;compile->compile",
propertiesIntegration % "test->test;compile->compile",
mlCompletionIntegration % "test->test;compile->compile",
featuresTrainerIntegration % "test->test;compile->compile",
textAnalysis % "test->test;compile->compile",
scalaLanguageUtils % "test->test;compile->compile",
scalaLanguageUtilsRt % "test->test;compile->compile",
pluginXml,
scalaCli % "test->test;compile->compile"
)
.settings(MainProjectSettings)
.settings(
packageAdditionalProjects := Seq(
jps,
compilerJps,
repackagedZinc,
worksheetReplInterfaceImpls,
compileServer,
scalaCompilerPlugin,
nailgunRunners,
copyrightIntegration,
javaDecompilerIntegration,
runtimeDependencies
),
// all sub-project tests need to be run within main project's classpath
Test / definedTests := definedTests.all(definedTestsScopeFilter).value.flatten,
cleanAll := Common.cleanAllTask(None).value
)
lazy val pluginXml = newProject("pluginXml", file("pluginXml"))
.settings(NoSourceDirectories)
.settings(
packageMethod := PackagingMethod.Standalone(),
packageFileMappings += {
val patchedVersionFile: File = Common.patchPluginXML(baseDirectory.value / "resources" / "META-INF" / "plugin.xml")
streams.value.log.info(s"patched version in file: ${patchedVersionFile.getPath}")
patchedVersionFile -> "lib/pluginXml.jar!/META-INF/plugin.xml"
},
)
lazy val scalaApi = newProject(
"scala-api",
file("scala/scala-api")
).settings(
idePackagePrefix := Some("org.jetbrains.plugins.scala"),
)
lazy val workspaceEntities = newProjectWithKotlin("workspace-entities", file("sbt/sbt-impl/workspace-entities"))
.settings(
Compile / unmanagedSourceDirectories ++= Seq(baseDirectory.value/"gen"),
scalaVersion := Versions.scala3Version,
Compile / scalacOptions := globalScala3ScalacOptions
)
lazy val sbtApi =
newProject("sbt-api", file("sbt/sbt-api"))
.dependsOn(scalaApi, compilerShared, workspaceEntities)
.enablePlugins(BuildInfoPlugin)
.settings(
buildInfoPackage := "org.jetbrains.sbt.buildinfo",
buildInfoKeys := Seq(
"sbtStructureVersion" -> Versions.sbtStructureVersion,
"sbtIdeaShellVersion" -> Versions.sbtIdeaShellVersion,
"sbtIdeaCompilerIndicesVersion" -> Versions.compilerIndicesVersion,
"sbtLatest_0_13" -> Versions.Sbt.latest_0_13,
"sbtLatest_1_0" -> Versions.Sbt.latest_1_0,
"sbtLatestVersion" -> Versions.sbtVersion,
"sbtStructurePath_0_13" -> relativeJarPath(sbtDep("org.jetbrains.scala", "sbt-structure-extractor", Versions.sbtStructureVersion, "0.13")),
"sbtStructurePath_1_2" -> relativeJarPath(sbtDep("org.jetbrains.scala", "sbt-structure-extractor", Versions.sbtStructureVersion, "1.2")),
"sbtStructurePath_1_3" -> relativeJarPath(sbtDep("org.jetbrains.scala", "sbt-structure-extractor", Versions.sbtStructureVersion, "1.3"))
),
buildInfoOptions += BuildInfoOption.ConstantValue
)
lazy val codeInsight = newProject(
"codeInsight",
file("scala/codeInsight")
).dependsOn(
scalaImpl % "test->test;compile->compile"
)
lazy val conversion = newProject(
"conversion",
file("scala/conversion")
).dependsOn(
codeInsight % "test->test;compile->compile"
)
lazy val uast = newProject(
"uast",
file("scala/uast")
).dependsOn(
scalaImpl % "test->test;compile->compile",
).settings(
intellijPlugins += "JUnit".toPlugin
)
lazy val worksheet =
newProject("worksheet", file("scala/worksheet"))
.dependsOn(
bsp,
compilerIntegration % "test->test;compile->compile",
worksheetReplInterface % "test->test;compile->compile",
repl % "test->test;compile->compile", //do we indeed need this dependency on Scala REPL? can we get rid of it?
)
lazy val worksheetReplInterface =
Project("worksheet-repl-interface", file("scala/worksheet-repl-interface"))
.settings(projectDirectoriesSettings)
.settings(
name := "worksheet-repl-interface",
organization := "JetBrains",
// NOTE: we might continue NOT using Scala in scalatestFinders just in case
// in some future we will decide again to extract the library, so as it can be used even without scala jar
scalaVersion := Versions.scalaVersion,
crossPaths := false, // disable using the Scala version in output paths and artifacts
autoScalaLibrary := false, // removes Scala dependency
(Compile / javacOptions) := outOfIDEAProcessJavacOptions, // can run in the compile server
(Compile / scalacOptions) := Seq.empty, // scala is disabled anyway, set empty options to move to a separate compiler profile (in IntelliJ model)
packageMethod := PackagingMethod.Standalone("lib/repl-interface.jar", static = true),
intellijMainJars := Seq.empty,
intellijTestJars := Seq.empty,
intellijPlugins := Seq.empty
)
.settings(compilationCacheSettings)
lazy val worksheetReplInterfaceImpls: Project =
newProject("worksheet-repl-interface-impls", file("scala/worksheet-repl-interface-impls"))
.settings(NoSourceDirectories)
.settings(
(Compile / javacOptions) := outOfIDEAProcessJavacOptions,
(Compile / scalacOptions) := outOfIDEAProcessScalacOptions,
crossPaths := false,
packageMethod := PackagingMethod.Standalone("worksheet-repl-interface/impls.jar", static = true),
packageAdditionalProjects := Seq(
worksheetReplInterfaceImpl_2_12,
worksheetReplInterfaceImpl_2_12_13,
worksheetReplInterfaceImpl_2_13_0,
worksheetReplInterfaceImpl_2_13,
worksheetReplInterfaceImpl_2_13_12,
worksheetReplInterfaceImpl_3_0_0,
worksheetReplInterfaceImpl_3_1_2,
worksheetReplInterfaceImpl_3_3_0
)
)
def worksheetReplInterfaceImplCommonSettings(scalaVer: String): Seq[Setting[?]] = Seq(
scalaVersion := scalaVer,
crossPaths := false,
// protobuf-java is excluded to avoid showing outdated vulnerable dependencies, and it is also not necessary for
// compiling the worksheet repl interfaces
libraryDependencies += {
if (scalaVer.startsWith("3."))
"org.scala-lang" %% "scala3-compiler" % scalaVer % Provided exclude("com.google.protobuf", "protobuf-java")
else
"org.scala-lang" % "scala-compiler" % scalaVer % Provided
},
// override the Scala 2.13 library dependency in the Scala 3 worksheet repl interfaces
// this avoids showing outdated vulnerable dependencies
dependencyOverrides := {
if (scalaVer.startsWith("3.")) Seq("org.scala-lang" % "scala-library" % Versions.scalaVersion)
else Seq.empty
},
(Compile / javacOptions) := outOfIDEAProcessJavacOptions,
(Compile / scalacOptions) := Seq("-release", "8"),
packageMethod := PackagingMethod.MergeIntoOther(worksheetReplInterfaceImpls),
intellijMainJars := Seq.empty,
intellijTestJars := Seq.empty,
intellijPlugins := Seq.empty
)
lazy val worksheetReplInterfaceImpl_2_12: Project =
newProject("worksheet-repl-interface-impl_2_12", file("scala/worksheet-repl-interface-impls/impl_2_12"))
.dependsOn(worksheetReplInterface)
.settings(
worksheetReplInterfaceImplCommonSettings("2.12.12"),
(Compile / scalacOptions) := Seq("-target:jvm-1.8") // Old version of Scala 2.12 does not have the modern compiler flags
)
.settings(
libraryDependencies ++= Seq(
compilerPlugin("com.github.ghik" % "silencer-plugin" % "1.7.1" cross CrossVersion.full),
"com.github.ghik" % "silencer-lib" % "1.7.1" % Provided cross CrossVersion.full
),
(Compile / scalacOptions) += "-deprecation",
// This is a workaround for manually enabling the `silencer-plugin` scalac compiler plugin. For some reason,
// automatic enabling doesn't work (the scalacOption "-Xplugin:" was not added).
// The silencer plugin is needed because this subproject is compiled using Scala 2.12.12 which did not have
// support for `@scala.annotation.nowarn`.
autoCompilerPlugins := false,
ivyConfigurations += Configurations.CompilerPlugin,
(Compile / scalacOptions) ++= Classpaths.autoPlugins(update.value, Seq.empty, isDotty = false)
)
lazy val worksheetReplInterfaceImpl_2_12_13: Project =
newProject("worksheet-repl-interface-impl_2_12_13", file("scala/worksheet-repl-interface-impls/impl_2_12_13"))
.dependsOn(worksheetReplInterface)
.settings(
worksheetReplInterfaceImplCommonSettings("2.12.18"),
(Compile / scalacOptions) += "-deprecation"
)
lazy val worksheetReplInterfaceImpl_2_13_0: Project =
newProject("worksheet-repl-interface-impl_2_13_0", file("scala/worksheet-repl-interface-impls/impl_2_13_0"))
.dependsOn(worksheetReplInterface)
.settings(worksheetReplInterfaceImplCommonSettings("2.13.0"))
lazy val worksheetReplInterfaceImpl_2_13: Project =
newProject("worksheet-repl-interface-impl_2_13", file("scala/worksheet-repl-interface-impls/impl_2_13"))
.dependsOn(worksheetReplInterface)
.settings(worksheetReplInterfaceImplCommonSettings("2.13.11"))
lazy val worksheetReplInterfaceImpl_2_13_12: Project =
newProject("worksheet-repl-interface-impl_2_13_12", file("scala/worksheet-repl-interface-impls/impl_2_13_12"))
.dependsOn(worksheetReplInterface)
.settings(worksheetReplInterfaceImplCommonSettings("2.13.12"))
lazy val worksheetReplInterfaceImpl_3_0_0: Project =
newProject("worksheet-repl-interface-impl_3_0_0", file("scala/worksheet-repl-interface-impls/impl_3_0_0"))
.dependsOn(worksheetReplInterface)
.settings(worksheetReplInterfaceImplCommonSettings("3.1.1"))
lazy val worksheetReplInterfaceImpl_3_1_2: Project =
newProject("worksheet-repl-interface-impl_3_1_2", file("scala/worksheet-repl-interface-impls/impl_3_1_2"))
.dependsOn(worksheetReplInterface)
.settings(worksheetReplInterfaceImplCommonSettings("3.2.2"))
lazy val worksheetReplInterfaceImpl_3_3_0: Project =
newProject("worksheet-repl-interface-impl_3_3_0", file("scala/worksheet-repl-interface-impls/impl_3_3_0"))
.dependsOn(worksheetReplInterface)
.settings(worksheetReplInterfaceImplCommonSettings("3.3.1"))
lazy val structureView = newProject("structure-view", file("scala/structure-view"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.settings(
scalaVersion := Versions.scala3Version,
Compile / scalacOptions := globalScala3ScalacOptions,
)
lazy val repl = newProject("repl", file("scala/repl"))
.dependsOn(
scalaImpl % "test->test;compile->compile",
structureView % "test->test;compile->compile",
)
.settings(
scalaVersion := Versions.scala3Version,
Compile / scalacOptions := globalScala3ScalacOptions,
packageMethod := PackagingMethod.MergeIntoOther(scalaCommunity)
)
lazy val tastyReader = Project("tasty-reader", file("scala/tasty-reader"))
.dependsOn(scalaLanguageUtils)
.dependsOn(scalaLanguageUtilsRt)
.settings(projectDirectoriesSettings)
.settings(
name := "tasty-reader",
organization := "JetBrains",
idePackagePrefix := Some("org.jetbrains.plugins.scala.tasty.reader"),
intellijMainJars := Seq.empty,
intellijTestJars := Seq.empty,
scalaVersion := Versions.scala3Version,
libraryDependencies += Dependencies.tastyCore,
(Compile / scalacOptions) := Seq("-deprecation"),
(Test / unmanagedResourceDirectories) += baseDirectory.value / "testdata",
libraryDependencies ++= Seq(
Dependencies.junit % Test,
Dependencies.junitInterface % Test,
)
)
.settings(compilationCacheSettings)
lazy val packageSearchClient: sbt.Project =
newProjectWithKotlin("package-search-client", file("scala/package-search-client"))
.settings(
scalaVersion := Versions.scala3Version,
Compile / scalacOptions := globalScala3ScalacOptions,
resolvers += DependencyResolvers.PackageSearch,
libraryDependencies += Dependencies.packageSearchClientJvm,
)
lazy val scalaImpl: sbt.Project =
newProject("scala-impl", file("scala/scala-impl"))
.dependsOn(
compilerShared,
scalaApi,
scalaLanguageUtils,
sbtApi,
decompiler % "test->test;compile->compile",
tastyReader % "test->test;compile->compile",
scalatestFinders,
runners,
testRunners,
packageSearchClient % "test->test;compile->compile",
)
.settings(
ideExcludedDirectories := Seq(
baseDirectory.value / "target",
baseDirectory.value / "testdata" / "projectsForHighlightingTests" / ".ivy_cache",
baseDirectory.value / "testdata" / "projectsForHighlightingTests" / ".coursier_cache",
//NOTE: when updating, please also update `org.jetbrains.scalateamcity.common.Caching.highlightingPatterns`
baseDirectory.value / "testdata" / "projectsForHighlightingTests" / "downloaded",
),
//scalacOptions in Global += "-Xmacro-settings:analyze-caches",
libraryDependencies ++= DependencyGroups.scalaCommunity,
libraryDependencies ++= Seq(
//for ExternalSystemTestCase and ExternalSystemImportingTestCase
Dependencies.intellijExternalSystemTestFramework % Test,
//for PlatformTestUtil.newPerformanceTest
Dependencies.intellijIdeMetricsBenchmark % Test,
Dependencies.intellijIdeMetricsCollector % Test,
Dependencies.intellijIdeUtilCommon % Test,
),
// for dependency version completion/inspections
libraryDependencies += Dependencies.coursierApi,
resolvers += Versions.intellijRepository_ForManagedIntellijDependencies,
intellijPlugins += "JUnit".toPlugin,
intellijPluginJars := intellijPluginJars.value.map { case PluginJars(descriptor, root, cp) =>
PluginJars(descriptor, root, cp.filterNot(_.getName.contains("junit-jupiter-api")))
},
packageLibraryMappings := Seq(
// "com.thesamet.scalapb" %% "scalapb-runtime" % ".*" -> None,
// "com.thesamet.scalapb" %% "lenses" % ".*" -> None,
Dependencies.scalaXml -> Some("lib/scala-xml.jar"),
Dependencies.scalaReflect -> Some("lib/scala-reflect.jar"),
Dependencies.scalaLibrary -> None,
Dependencies.scala3Library -> None,
)
)
/**
* Utilities which only depend on the Scala standard library and do not depend on other libraries or IntelliJ SDK
*/
lazy val scalaLanguageUtils: sbt.Project =
newPlainScalaProject("scala-utils-language", file("scala/scala-utils-language"))
.settings(
packageMethod := PackagingMethod.MergeIntoOther(scalaCommunity)
)
/**
* Same as [[scalaLanguageUtils]], but utilities from this module can be used form both IntelliJ IDEA process and JPS process.
* Keep this module as small as possible with no other dependencies
*/
lazy val scalaLanguageUtilsRt: sbt.Project =
newPlainScalaProject("scala-utils-language-rt", file("scala/scala-utils-language-rt"))
.settings(
Compile / javacOptions := outOfIDEAProcessJavacOptions,
Compile / scalacOptions := outOfIDEAProcessScalacOptions,
packageMethod := PackagingMethod.Standalone("lib/utils_rt.jar", static = true),
)
lazy val sbtImpl =
newProject("sbt-impl", file("sbt/sbt-impl"))
.dependsOn(sbtApi, scalaImpl % "test->test;compile->compile")
.settings(
intellijPlugins += "org.jetbrains.idea.maven".toPlugin
)
lazy val compilerIntegration =
newProject("compiler-integration", file("scala/compiler-integration"))
.dependsOn(
scalaImpl % "test->test;compile->compile",
codeInsight % "test->test;compile->compile",
sbtImpl % "test->test;compile->compile",
jps,
bsp,
gradleIntegration % "test->test"
)
.settings(
intellijPlugins ++= Seq(
"com.intellij.gradle",
"org.jetbrains.idea.maven"
).map(_.toPlugin), // Used only in tests
libraryDependencies += Dependencies.intellijMavenTestFramework % Test
)
lazy val debugger =
newProject("debugger", file("scala/debugger"))
.dependsOn(
scalaImpl % "test->test;compile->compile",
compilerIntegration % "test->test;compile->compile"
)
lazy val compileServer =
newPlainScalaProject("compile-server", file("scala/compile-server"))
.dependsOn(compilerShared, repackagedZinc, worksheetReplInterface)
.settings(
Compile / javacOptions := outOfIDEAProcessJavacOptions,
Compile / scalacOptions := outOfIDEAProcessScalacOptions,
packageMethod := PackagingMethod.Standalone("lib/jps/compile-server.jar", static = true),
libraryDependencies += Dependencies.nailgun,
packageLibraryMappings += Dependencies.nailgun -> Some("lib/jps/nailgun.jar"),
//Manually build classpath for the jps module because the code from this module
//will be executed in JPS process which has a separate classpath.
//NOTE: this classpath is only required to properly compile the module
//(in order we do not accidentally use any classes which are not available in JPS process)<br>
//At runtime the classpath will be constructed in by Platform.
Compile / unmanagedJars ++= Common.jpsClasspath.value
)
lazy val scalaCompilerPlugin: sbt.Project =
newPlainScalaProject("compiler-plugin", file("scala/compiler-plugin"))
.settings(
scalaVersion := Versions.scala3Version,
Compile / scalacOptions := globalScala3ScalacOptions,
libraryDependencies ++= Seq(Dependencies.scala3Compiler),
packageMethod := PackagingMethod.Standalone("lib/jps/compiler-plugin.jar"),
)
lazy val compilerJps =
newPlainScalaProject("compiler-jps", file("scala/compiler-jps"))
.dependsOn(jps, compileServer)
.settings(
(Compile / javacOptions) := outOfIDEAProcessJavacOptions,
(Compile / scalacOptions) := outOfIDEAProcessScalacOptions,
packageMethod := PackagingMethod.Standalone("lib/jps/compiler-jps.jar", static = true),
libraryDependencies ++= Seq(Dependencies.scalaParallelCollections),
packageLibraryMappings ++= Seq(
Dependencies.scalaParallelCollections -> Some("lib/jps/scala-parallel-collections.jar")
),
//Manually build classpath for the jps module because the code from this module
//will be executed in JPS process which has a separate classpath.
//NOTE: this classpath is only required to properly compile the module
//(in order we do not accidentally use any classes which are not available in JPS process)<br>
//At runtime the classpath will be constructed in by Platform.
Compile / unmanagedJars ++= Common.jpsClasspath.value
)
lazy val repackagedZinc =
newProject("repackagedZinc", file("target/tools/zinc"))
.settings(NoSourceDirectories)
.settings(
packageOutputDir := baseDirectory.value / "plugin",
packageAssembleLibraries := true,
shadePatterns += ShadePattern("com.google.protobuf.**", "zinc.protobuf.@1"),
packageMethod := PackagingMethod.DepsOnly("lib/jps/incremental-compiler.jar"),
libraryDependencies ++= Seq(Dependencies.zinc, Dependencies.compilerInterface, Dependencies.sbtInterface),
// We package and ship these jars separately. They are also transitive dependencies of `zinc`.
// These mappings ensure that the transitive dependencies are not packaged into the assembled
// `incremental-compiler.jar`, which leads to a bloated classpath with repeated classes.
packageLibraryMappings ++= Seq(
Dependencies.compilerInterface -> None,
Dependencies.sbtInterface -> None
)
)
lazy val compilerShared =
newPlainScalaProject("compiler-shared", file("scala/compiler-shared"))
.dependsOn(scalaLanguageUtilsRt)
.settings(
(Compile / javacOptions) := outOfIDEAProcessJavacOptions,
(Compile / scalacOptions) := outOfIDEAProcessScalacOptions,
packageMethod := PackagingMethod.Standalone("lib/compiler-shared.jar", static = true),
Compile / unmanagedJars ++= Common.compilerSharedClasspath.value
)
lazy val jps =
newPlainScalaProject("jps", file("scala/jps"))
.settings(
Compile / javacOptions := outOfIDEAProcessJavacOptions,
Compile / scalacOptions := outOfIDEAProcessScalacOptions,
packageMethod := PackagingMethod.Standalone("lib/scala-jps.jar", static = true),
libraryDependencies += Dependencies.compilerIndicesProtocol,
packageLibraryMappings += Dependencies.compilerIndicesProtocol -> Some(s"lib/scala-compiler-indices-protocol_2.13-${Versions.compilerIndicesVersion}.jar"),
//Manually build classpath for the jps module because the code from this module
//will be executed in JPS process which has a separate classpath.
//NOTE: this classpath is only required to properly compile the module
//(in order we do not accidentally use any classes which are not available in JPS process)<br>
//At runtime the classpath will be constructed in by Platform.
Compile / unmanagedJars ++= Common.jpsClasspath.value
)
lazy val runners: Project =
newProject("runners", file("scala/runners"))
.settings(
(Compile / javacOptions) := outOfIDEAProcessJavacOptions,
(Compile / scalacOptions) := outOfIDEAProcessScalacOptions,
packageMethod := PackagingMethod.Standalone(static = true),
packageAdditionalProjects ++= Seq(testRunners, testRunners_spec2_2x)
)
lazy val testingSupport =
newProject("testing-support", file("scala/test-integration/testing-support"))
.dependsOn(
scalaImpl % "test->test;compile->compile",
sbtImpl % "test->test;compile->compile",
bsp,
structureView % "test->test;compile->compile",
compilerIntegration % "test->test;compile->compile"
)
.settings(
intellijPlugins += "JUnit".toPlugin
)
lazy val testRunners: Project =
newProject("test-runners", file("scala/test-integration/test-runners"))
.settings(
(Compile / javacOptions) := outOfIDEAProcessJavacOptions,
(Compile / scalacOptions) := outOfIDEAProcessScalacOptions,
packageMethod := PackagingMethod.MergeIntoOther(runners),
libraryDependencies ++= DependencyGroups.testRunners
)
lazy val testRunners_spec2_2x: Project =
newProject("test-runners-spec2_2x", file("scala/test-integration/test-runners-spec2_2x"))
.dependsOn(testRunners)
.settings(
(Compile / javacOptions) := outOfIDEAProcessJavacOptions,
(Compile / scalacOptions) := outOfIDEAProcessScalacOptions,
packageMethod := PackagingMethod.MergeIntoOther(runners),
libraryDependencies ++= Seq(provided.specs2_2x)
)
lazy val scalatestFindersRootDir = file("scala/test-integration/scalatest-finders")
lazy val scalatestFinders = Project("scalatest-finders", scalatestFindersRootDir)
.settings(
name := "scalatest-finders",
organization := "JetBrains",
scalaVersion := Versions.scalaVersion,
// NOTE: we might continue NOT using Scala in scalatestFinders just in case
// in some future we will decide again to extract the library, so as it can be used even without scala jar
crossPaths := false, // disable using the Scala version in output paths and artifacts
autoScalaLibrary := false, // removes Scala dependency,
scalacOptions := Seq(), // scala is disabled anyway, set empty options to move to a separate compiler profile (in IntelliJ model)
javacOptions := globalJavacOptions, // finders are run in IDEA process, so using JDK 17
packageMethod := PackagingMethod.Standalone("lib/scalatest-finders-patched.jar"),
intellijMainJars := Nil,
intellijTestJars := Nil,
)
.settings(compilationCacheSettings)
lazy val scalatestFindersTestSettings = Seq(
scalacOptions := Seq("-deprecation")
)
val scalatestLatest_2 = "2.2.6"
val scalatestLatest_3_0 = "3.0.9"
val scalatestLatest_3_2 = "3.2.16"
lazy val scalatestFindersTests_2 = Project("scalatest-finders-tests-2", scalatestFindersRootDir / "tests-2")
.dependsOn(scalatestFinders)
.settings(
name := "scalatest-finders-tests-2",
organization := "JetBrains",
scalatestFindersTestSettings,
scalaVersion := "2.11.12",
libraryDependencies := Seq("org.scalatest" %% "scalatest" % scalatestLatest_2 % Test),
intellijMainJars := Nil,
intellijTestJars := Nil
)
.settings(compilationCacheSettings)
lazy val scalatestFindersTests_3_0 = Project("scalatest-finders-tests-3_0", scalatestFindersRootDir / "tests-3_0")
.dependsOn(scalatestFinders)
.settings(
name := "scalatest-finders-tests-3_0",
organization := "JetBrains",
scalatestFindersTestSettings,
scalaVersion := "2.12.17",
libraryDependencies := Seq("org.scalatest" %% "scalatest" % scalatestLatest_3_0 % Test),
intellijMainJars := Nil,
intellijTestJars := Nil,
)
.settings(compilationCacheSettings)
lazy val scalatestFindersTests_3_2 = Project("scalatest-finders-tests-3_2", scalatestFindersRootDir / "tests-3_2")
.dependsOn(scalatestFinders)
.settings(
name := "scalatest-finders-tests-3_2",
organization := "JetBrains",
scalatestFindersTestSettings,
scalaVersion := Versions.scalaVersion,
libraryDependencies := Seq("org.scalatest" %% "scalatest" % scalatestLatest_3_2 % Test),
intellijMainJars := Nil,
intellijTestJars := Nil,
)
.settings(compilationCacheSettings)
lazy val nailgunRunners =
newProject("nailgun", file("scala/nailgun"))
.settings(
(Compile / javacOptions) := outOfIDEAProcessJavacOptions,
(Compile / scalacOptions) := outOfIDEAProcessScalacOptions,
libraryDependencies += Dependencies.nailgun,
packageLibraryMappings += Dependencies.nailgun -> Some("lib/jps/nailgun.jar"),
packageMethod := PackagingMethod.Standalone("lib/scala-nailgun-runner.jar", static = true)
)
lazy val decompiler =
newProject("decompiler", file("scala/decompiler"))
.dependsOn(scalaLanguageUtils)
.settings(
libraryDependencies ++= DependencyGroups.decompiler,
packageMethod := PackagingMethod.Standalone("lib/scalap.jar")
)
lazy val bsp =
newProject("bsp", file("bsp"))
.enablePlugins(BuildInfoPlugin)
.dependsOn(
scalaImpl % "test->test;compile->compile",
sbtImpl % "test->test;compile->compile"
)
.settings(
libraryDependencies ++= DependencyGroups.bsp,
intellijPlugins += "JUnit".toPlugin,
intellijPlugins += "org.jetbrains.plugins.terminal".toPlugin,
buildInfoPackage := "org.jetbrains.bsp.buildinfo",
buildInfoKeys := Seq("bloopVersion" -> Versions.bloopVersion),
buildInfoOptions += BuildInfoOption.ConstantValue
)
lazy val scalaCli =
newProject("scala-cli", file("scala-cli"))
.dependsOn(
scalaImpl % "test->test;compile->compile",
bsp % "test->test;compile->compile",
)
// Integration with other IDEA plugins
//TODO: rename the module module and maybe base packages (check external usages)
// it actually doesn't have anything related to actual devkit integration, it doesn't depend on anything from it
// it's similar to DevKit plugin in it's purpose, but it's different.
// It just contains some internal actions required for Scala Plugin development (or other Scala-based plugins using sbt-idea-plugin)
lazy val devKitIntegration =
newProject("devKit", file("scala/integration/devKit"))
.dependsOn(scalaImpl, sbtImpl)
lazy val copyrightIntegration =
newProject("copyright", file("scala/integration/copyright"))
.dependsOn(scalaImpl)
.settings(
intellijPlugins += "com.intellij.copyright".toPlugin,
packageMethod := PackagingMethod.MergeIntoOther(scalaCommunity)
)
lazy val gradleIntegration =
newProject("gradle", file("scala/integration/gradle"))
.dependsOn(scalaImpl % "test->test;compile->compile", sbtImpl % "test->test")
.settings(
intellijPlugins ++= Seq(
"com.intellij.gradle", // required by Android
"org.intellij.groovy", // required by Gradle
"com.intellij.properties").map(_.toPlugin) // required by Gradle
)
lazy val intelliLangIntegration = newProject(
"intelliLang",
file("scala/integration/intellilang")
).dependsOn(
scalaImpl % "test->test;compile->compile"
).settings(
// addCompilerPlugin(Dependencies.macroParadise),
intellijPlugins += "org.intellij.intelliLang".toPlugin
)
lazy val mavenIntegration =
newProject("maven", file("scala/integration/maven"))
.dependsOn(
scalaImpl % "test->test;compile->compile",
testingSupport,
sbtImpl % "test->test"
)
.settings(
intellijPlugins += "org.jetbrains.idea.maven".toPlugin,
libraryDependencies += Dependencies.intellijMavenTestFramework % Test,
resolvers += Versions.intellijRepository_ForManagedIntellijDependencies
)
lazy val junitIntegration =
newProject("junit", file("scala/integration/junit"))
.dependsOn(sbtImpl % "compile->compile")
.settings(
intellijPlugins += "JUnit".toPlugin
)
lazy val propertiesIntegration =
newProject("properties", file("scala/integration/properties"))
.dependsOn(scalaImpl % "test->test;compile->compile", sbtImpl)
.settings(
intellijPlugins ++= Seq(
"com.intellij.properties".toPlugin,
"com.intellij.java-i18n".toPlugin,
)
)
lazy val javaDecompilerIntegration =
newProject("java-decompiler", file("scala/integration/java-decompiler"))
.dependsOn(scalaImpl)
.settings(
intellijPlugins += "org.jetbrains.java.decompiler".toPlugin,
packageMethod := PackagingMethod.MergeIntoOther(scalaCommunity)
)
lazy val mlCompletionIntegration =
newProject("ml-completion", file("scala/integration/ml-completion"))
.dependsOn(scalaImpl, sbtImpl)
.settings(
intellijPlugins += "com.intellij.completion.ml.ranking".toPlugin,
resolvers += DependencyResolvers.IntelliJDependencies,
libraryDependencies += "org.jetbrains.intellij.deps.completion" % "completion-ranking-scala" % "0.4.1"
)
//Integration with:
// - Build-in spellchecker (see com.intellij.spellchecker package)
// - Grazie plugin (more advanced spell + grammar checker)
lazy val textAnalysis =
newProject("textAnalysis", file("scala/integration/textAnalysis"))
.dependsOn(
scalaImpl % "test->test;compile->compile",
intelliLangIntegration //uses logic related to parsing interpolated strings
)
.settings(
scalaVersion := Versions.scala3Version,
Compile / scalacOptions := globalScala3ScalacOptions,
intellijPlugins ++= Seq(
"tanvd.grazi".toPlugin,
"org.intellij.intelliLang".toPlugin //required for intelliLangIntegration
),
//Language packs needed at runtime to run tests
libraryDependencies ++= Seq(
//languagetool-core is available in the platform, exclude it to avoid some strange runtime errors in tests
("org.languagetool" % "language-ru" % Versions.LanguageToolVersion % Runtime).exclude("org.languagetool", "languagetool-core"),
("org.languagetool" % "language-de" % Versions.LanguageToolVersion % Runtime).exclude("org.languagetool", "languagetool-core"),
("org.languagetool" % "language-it" % Versions.LanguageToolVersion % Runtime).exclude("org.languagetool", "languagetool-core"),
)
)
lazy val featuresTrainerIntegration =
newProject("features-trainer", file("scala/integration/features-trainer"))
.dependsOn(
scalaImpl % "test->test;compile->compile",
)
.settings(
scalaVersion := Versions.scala3Version,
Compile / scalacOptions := globalScala3ScalacOptions,
intellijPlugins += "training".toPlugin,
)
// SCL-20376 - The package search plugin will be replaced by a new one, requiring a rewrite of the integration code.
//lazy val packageSearchIntegration =
// newProject("packagesearch", file("scala/integration/packagesearch"))
// .dependsOn(scalaImpl, sbtImpl)
// .settings(
// // The packageSearch plugin is no longer distributed with IDEA. It will soon be available on the plugin
// // marketplace once more and this workaround will be unnecessary.
// // TODO: use `intellijVersion_ForManagedIntellijDependencies` as version once the plugin is published properly
// libraryDependencies += "com.jetbrains.intellij.packageSearch" % "package-search" % "232.6095-EAP-CANDIDATE-SNAPSHOT" % Provided notTransitive(),
// resolvers += MavenRepository("intellij-repository-snapshots", "https://www.jetbrains.com/intellij-repository/snapshots"),
// packageMethod := PackagingMethod.MergeIntoOther(scalaCommunity)
// )
// Utility projects
lazy val runtimeDependencies = project.in(file("target/tools/runtime-dependencies"))
.enablePlugins(DynamicDependenciesFetcher, LocalRepoPackager)
.settings(NoSourceDirectories)
.settings(
name := "runtimeDependencies",
organization := "JetBrains",
scalaVersion := Versions.scalaVersion,
autoScalaLibrary := false,
resolvers += Classpaths.sbtPluginReleases,
ideSkipProject := true,
packageMethod := PackagingMethod.DepsOnly(),
dynamicDependencies := Seq(
binaryDep("org.scala-sbt", "sbt-launch", Versions.sbtVersion) -> "launcher/sbt-launch.jar",
binaryDep("org.scala-sbt", "util-interface", Versions.sbtVersion) -> "lib/jps/sbt-interface.jar",
binaryDep("org.scala-sbt", "compiler-interface", Versions.zincVersion) -> "lib/jps/compiler-interface.jar",
sourceDep("org.scala-sbt", "compiler-bridge", "2.10", Versions.zincVersion) -> "lib/jps/compiler-bridge-sources_2.10.jar",
sourceDep("org.scala-sbt", "compiler-bridge", "2.11", Versions.zincVersion) -> "lib/jps/compiler-bridge-sources_2.11.jar",
sourceDep("org.scala-sbt", "compiler-bridge", "2.13", Versions.zincVersion) -> "lib/jps/compiler-bridge-sources_2.13.jar",
binaryDep("org.scala-lang", "scala3-sbt-bridge", "3.0.2") -> "lib/jps/scala3-sbt-bridge_3.0.jar",
binaryDep("org.scala-lang", "scala3-sbt-bridge", "3.1.3") -> "lib/jps/scala3-sbt-bridge_3.1.jar",
binaryDep("org.scala-lang", "scala3-sbt-bridge", "3.2.2") -> "lib/jps/scala3-sbt-bridge_3.2.jar",
binaryDep("org.scala-lang", "scala3-sbt-bridge", "3.3.1") -> "lib/jps/scala3-sbt-bridge_3.3.1.jar",
binaryDep("org.scala-lang", "scala3-sbt-bridge", "3.3.3") -> "lib/jps/scala3-sbt-bridge_3.3.jar",
binaryDep("org.scala-lang", "scala3-sbt-bridge", "3.4.0") -> "lib/jps/scala3-sbt-bridge_3.4.jar",
binaryDep("org.scala-sbt.rt", "java9-rt-export", Versions.java9rtExportVersion) -> "java9-rt-export/java9-rt-export.jar",
),
localRepoDependencies := List(
sbtDep("org.jetbrains.scala", "sbt-structure-extractor", Versions.sbtStructureVersion, Versions.Sbt.binary_0_13),
sbtDep("org.jetbrains.scala", "sbt-structure-extractor", Versions.sbtStructureVersion, Versions.Sbt.structure_extractor_binary_1_2),
sbtDep("org.jetbrains.scala", "sbt-structure-extractor", Versions.sbtStructureVersion, Versions.Sbt.structure_extractor_binary_1_3),
sbtDep("org.jetbrains.scala", "sbt-idea-shell", Versions.sbtIdeaShellVersion, Versions.Sbt.binary_0_13),
sbtDep("org.jetbrains.scala", "sbt-idea-shell", Versions.sbtIdeaShellVersion, Versions.Sbt.binary_1_0)
// SCL-22858 compiler bytecode indices are disabled in sbt shell
// sbtDep("org.jetbrains.scala", "sbt-idea-compiler-indices", Versions.compilerIndicesVersion, Versions.Sbt.binary_0_13),
// sbtDep("org.jetbrains.scala", "sbt-idea-compiler-indices", Versions.compilerIndicesVersion, Versions.Sbt.binary_1_0)
),
update := {
dynamicDependenciesUpdate.value
localRepoUpdate.value
update.value
},
packageFileMappings ++= {
localRepoUpdate.value.map { case (src, trg) =>
val targetPath = Path.of("repo").resolve(trg)
src.toFile -> targetPath.toString
} ++
dynamicDependenciesUpdate.value.map { case (src, trg) =>
src.toFile -> trg.toString
}
}
)
.settings(compilationCacheSettings)
//lazy val jmhBenchmarks =
// newProject("benchmarks", file("scala/benchmarks"))
// .dependsOn(scalaImpl % "test->test")
// .enablePlugins(JmhPlugin)
////////////////////////////////////////////
//
// Testing keys and settings
//
////////////////////////////////////////////
import Common.TestCategory.*
def runInputTask(key: InputKey[?], input: String, inState: State, resultState: State): State = {
val extracted = Project.extract(inState)
try {
extracted.runInputTask(key, input, inState)
resultState
} catch {
case _: Exception => resultState.fail
}
}
lazy val runTestCategory = Command.single("runTestCategory") { (state, category) =>
val state1 = Command.process(
s"""set Seq(
| Test / testFrameworks := Seq(TestFrameworks.JUnit),
| Test / testOptions := Seq(Tests.Argument(TestFrameworks.JUnit, "-v", "-s", "-a", "+c", "+q", "--include-categories=$category", "--exclude-categories=$flakyTests"))
|)""".stripMargin,
state,
_ => ()
)
runInputTask(Test / testOnly, "", state1, state)
state
}
def runTestsInTC(category: String): String = s"runTestCategory $category"
addCommandAlias("runFileSetTests", runTestsInTC(fileSetTests))
addCommandAlias("runCompilationTests", runTestsInTC(compilationTests))
addCommandAlias("runCompilerHighlightingTests", runTestsInTC(compilerHighlightingTests))
addCommandAlias("runCompletionTests", runTestsInTC(completionTests))
addCommandAlias("runEditorTests", runTestsInTC(editorTests))
addCommandAlias("runSlowTests", runTestsInTC(slowTests))
addCommandAlias("runDebuggerTests", runTestsInTC(debuggerTests))
addCommandAlias("runDebuggerEvaluationTests", runTestsInTC(debuggerEvaluationTests))
addCommandAlias("runScalacTests", runTestsInTC(scalacTests))
addCommandAlias("runTypeInferenceTests", runTestsInTC(typecheckerTests))
addCommandAlias("runTestingSupportTests", runTestsInTC(testingSupportTests))
addCommandAlias("runWorksheetEvaluationTests", runTestsInTC(worksheetEvaluationTests))
addCommandAlias("runHighlightingTests", runTestsInTC(highlightingTests))
addCommandAlias("runNightlyTests", runTestsInTC(randomTypingTests))
lazy val runFlakyTests = Command.command("runFlakyTests") { state =>
val state1 = Command.process(
s"""set Seq(
| Test / testFrameworks := Seq(TestFrameworks.JUnit),
| Test / testOptions := Seq(Tests.Argument(TestFrameworks.JUnit, "-v", "-s", "-a", "+c", "+q", "--include-categories=$flakyTests"))
|)""".stripMargin,
state,
_ => ()
)
runInputTask(Test / testOnly, "", state1, state)
}
//it's run during "Package" step on TC
addCommandAlias("runBundleSortingTests", runTestsInTC(bundleSortingTests))
lazy val runFastTestsCommand = Command.single("runFastTestsCommand") { (state, glob) =>
val categoriesToExclude = List(
fileSetTests,
compilationTests,
compilerHighlightingTests,
completionTests,
editorTests,
slowTests,
debuggerTests,
debuggerEvaluationTests,
scalacTests,
typecheckerTests,
testingSupportTests,
highlightingTests,
worksheetEvaluationTests,
randomTypingTests,
flakyTests
)
val state1 = Command.process(
s"""set Seq(
| Test / testFrameworks := Seq(TestFrameworks.JUnit),
| Test / testOptions := Seq(Tests.Argument(TestFrameworks.JUnit, "-v", "-s", "-a", "+c", "+q", "--exclude-categories=${categoriesToExclude.mkString(",")}"))
|)""".stripMargin,
state,
_ => ()
)
runInputTask(Test / testOnly, s" $glob", state1, state)
}
addCommandAlias("runFastTests", "runFastTestsCommand *")
// subsets of tests to split the complete test run into smaller chunks
addCommandAlias("runFastTestsComIntelliJ", "runFastTestsCommand com.intellij.*")
addCommandAlias("runFastTestsOrgJetbrains", "runFastTestsCommand org.jetbrains.*")
addCommandAlias("runFastTestsScala", "runFastTestsCommand scala.*")
lazy val runJUnit5Tests = Command.command("runJUnit5Tests") { state =>
val testFrameworkFqn = "com.github.sbt.junit.jupiter.sbt.Import.jupiterTestFramework"
val state1 = Command.process(
s"""set Seq(
| Test / testFrameworks := Seq($testFrameworkFqn),
| Test / testOptions := Seq(Tests.Argument($testFrameworkFqn, "-v", "-s", "-a", "+c", "+q"))
|)""".stripMargin,
state,
_ => ()
)
runInputTask(Test / testOnly, "", state1, state)
}
Global / commands ++= Seq(runTestCategory, runFlakyTests, runFastTestsCommand, runJUnit5Tests)