forked from JetBrains/intellij-scala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
461 lines (407 loc) · 18.8 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
import Common._
import Dependencies.{provided, sbtStructureExtractor}
import org.jetbrains.sbtidea.Keys._
import sbtide.Keys.ideSkipProject
// Global build settings
intellijPluginName in ThisBuild := "Scala"
intellijBuild in ThisBuild := Versions.intellijVersion
intellijPlatform in ThisBuild := IntelliJPlatform.IdeaCommunity
resolvers in ThisBuild ++=
BintrayJetbrains.allResolvers :+
Resolver.typesafeIvyRepo("releases") :+
Resolver.sonatypeRepo("snapshots")
javacOptions in Global := globalJavacOptions
scalacOptions in Global := globalScalacOptions
// Main projects
lazy val scalaCommunity: sbt.Project =
newProject("scalaCommunity", file("."))
.dependsOn(
bsp % "test->test;compile->compile",
codeInsight % "test->test;compile->compile",
dfa % "test->test;compile->compile",
conversion % "test->test;compile->compile",
uast % "test->test;compile->compile",
worksheet % "test->test;compile->compile",
scalaImpl % "test->test;compile->compile",
devKitIntegration % "test->test;compile->compile",
androidIntegration % "test->test;compile->compile",
copyrightIntegration % "test->test;compile->compile",
gradleIntegration % "test->test;compile->compile",
intelliLangIntegration % "test->test;compile->compile",
mavenIntegration % "test->test;compile->compile",
propertiesIntegration % "test->test;compile->compile",
javaDecompilerIntegration
)
.settings(
ideExcludedDirectories := Seq(baseDirectory.value / "target"),
packageAdditionalProjects := Seq(
scalaApi,
compilerJps,
/*worksheetReplReporters,*/
repackagedZinc,
decompiler,
compilerShared,
nailgunRunners,
runners,
runtimeDependencies,
),
packageLibraryMappings := Dependencies.scalaLibrary -> Some("lib/scala-library.jar") :: Nil,
definedTests in Test := { // all sub-project tests need to be run within main project's classpath
definedTests.all(ScopeFilter(inDependencies(scalaCommunity, includeRoot = false), inConfigurations(Test))).value.flatten }
)
lazy val scalaApi = newProject(
"scala-api",
file("scala/scala-api")
)
lazy val codeInsight = newProject(
"codeInsight",
file("scala/codeInsight")
).dependsOn(
scalaImpl % "test->test;compile->compile"
)
lazy val dfa = newProject(
"dfa",
file("scala/dfa")
).settings(
testFrameworks in Test += TestFrameworks.ScalaTest,
libraryDependencies ++= DependencyGroups.dfa,
scalacOptions ++= Seq(
"-deprecation",
"-unchecked",
"-feature",
"-Xlint",
"-Xfatal-warnings"
),
// the internet says this is smart thing to do
scalacOptions in (Compile, console) ~= {
_.filterNot(Set("-Xlint"))
}
)
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"
)
lazy val worksheet =
newProject("worksheet", file("scala/worksheet"))
.dependsOn(
scalaImpl % "test->test;compile->compile",
worksheetReplReporters % "test->test;compile->compile"
)
lazy val worksheetReplReporters =
newProject("worksheet_repl_reporters", file("scala/worksheet_repl_reporters"))
.settings(
packageMethod := PackagingMethod.Standalone("lib/repl-reporters.jar", static = true)
)
lazy val tastyProvided = newProject("tasty-provided", file("tasty/provided"))
.settings(scalaVersion := Versions.scalaVersion, packageMethod := PackagingMethod.Skip())
lazy val tastyCompile = newProject("tasty-compile", file("tasty/compile"))
.dependsOn(tastyProvided % Provided)
.settings(scalaVersion := Versions.scalaVersion, packageMethod := PackagingMethod.Standalone("lib/tasty-compile.jar"))
lazy val tastyRuntime = newProject("tasty-runtime", file("tasty/runtime"))
.dependsOn(tastyCompile % "compile-internal", tastyProvided % Provided)
.settings(scalaVersion := Versions.scalaVersion, packageMethod := PackagingMethod.Standalone("lib/tasty/tasty-runtime.jar"))
lazy val tastyExample = newProject("tasty-example", file("tasty/example"))
.dependsOn(tastyCompile, tastyProvided % Provided)
.settings(scalaVersion := Versions.scalaVersion, libraryDependencies += "ch.epfl.lamp" % "dotty-library_0.27" % "0.27.0-RC1" % Runtime)
// TODO Remove this synthetic module, package the Runtime dependency automatically.
lazy val dottyLibraryJar = newProject("dotty-library-jar", file("target/tools/dotty-library-jar"))
.settings(libraryDependencies += "ch.epfl.lamp" % "dotty-library_0.27" % "0.27.0-RC1", packageMethod := PackagingMethod.DepsOnly("lib"))
lazy val scalaImpl: sbt.Project =
newProject("scala-impl", file("scala/scala-impl"))
.dependsOn(
compilerShared,
worksheetReplReporters,
scalaApi,
macroAnnotations,
decompiler % "test->test;compile->compile",
runners % "test->test;compile->compile",
testRunners % "test->test;compile->compile",
tastyCompile,
tastyProvided % Provided
)
.aggregate(tastyRuntime)
.enablePlugins(BuildInfoPlugin)
.settings(
ideExcludedDirectories := Seq(baseDirectory.value / "testdata" / "projects"),
//scalacOptions in Global += "-Xmacro-settings:analyze-caches",
libraryDependencies ++= DependencyGroups.scalaCommunity :+
"ch.epfl.lamp" % "dotty-library_0.27" % "0.27.0-RC1" % Runtime, // TODO Runtime dependencies must be packaged automatically.
// addCompilerPlugin(Dependencies.macroParadise),
intellijPlugins := Seq(
"org.intellij.intelliLang",
"com.intellij.java-i18n",
"org.jetbrains.android",
"com.intellij.stats.completion", // required for ml completion testing
"com.android.tools.idea.smali", // required by Android
"com.intellij.gradle", // required by Android
"org.intellij.groovy", // required by Gradle
"org.jetbrains.idea.maven", // TODO remove after extracting the SBT module (which depends on Maven)
"JUnit"
).map(_.toPlugin),
intellijPluginJars :=
intellijPluginJars.value.filterNot(cp => cp.data.getName.contains("junit-jupiter-api")),
packageMethod := PackagingMethod.MergeIntoOther(scalaCommunity),
packageAdditionalProjects := Seq(tastyRuntime, dottyLibraryJar),
packageLibraryMappings ++= Seq(
"org.scalameta" %% ".*" % ".*" -> Some("lib/scalameta.jar"),
"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
),
packageFileMappings ++= Seq(
baseDirectory.in(compilerJps).value / "resources" / "ILoopWrapper212Impl.scala" -> "lib/jps/repl-interface-sources.jar",
baseDirectory.in(compilerJps).value / "resources" / "ILoopWrapper213_0Impl.scala" -> "lib/jps/repl-interface-sources.jar",
baseDirectory.in(compilerJps).value / "resources" / "ILoopWrapper213Impl.scala" -> "lib/jps/repl-interface-sources.jar",
baseDirectory.in(compilerJps).value / "resources" / "ILoopWrapper3Impl.scala" -> "lib/jps/repl-interface-sources.jar"
),
buildInfoPackage := "org.jetbrains.plugins.scala.buildinfo",
buildInfoKeys := Seq(
name, version, scalaVersion, sbtVersion,
BuildInfoKey.constant("bloopVersion", Versions.bloopVersion),
BuildInfoKey.constant("sbtStructureVersion", Versions.sbtStructureVersion),
BuildInfoKey.constant("sbtIdeaShellVersion", Versions.sbtIdeaShellVersion),
BuildInfoKey.constant("sbtIdeaCompilerIndicesVersion", Versions.compilerIndicesVersion),
BuildInfoKey.constant("sbtLatest_0_12", Versions.Sbt.latest_0_12),
BuildInfoKey.constant("sbtLatest_0_13", Versions.Sbt.latest_0_13),
BuildInfoKey.constant("sbtLatest_1_0", Versions.Sbt.latest_1_0),
BuildInfoKey.constant("sbtLatestVersion", Versions.sbtVersion),
BuildInfoKey.constant("sbtStructurePath_0_13",
LocalRepoPackager.relativeJarPath013("org.jetbrains", "sbt-structure-extractor", Versions.sbtStructureVersion)),
BuildInfoKey.constant("sbtStructurePath_1_0",
LocalRepoPackager.relativeJarPath1("org.jetbrains", "sbt-structure-extractor", Versions.sbtStructureVersion))
)
)
lazy val compilerJps =
newProject("compiler-jps", file("scala/compiler-jps"))
.dependsOn(compilerShared, repackagedZinc, worksheetReplReporters)
.settings(
javacOptions in Compile := jpsJavacOptions,
scalacOptions in Compile := jpsScalacOptions,
packageMethod := PackagingMethod.Standalone("lib/jps/compiler-jps.jar", static = true),
libraryDependencies ++= Seq(Dependencies.nailgun,
Dependencies.zincInterface,
Dependencies.scalaParallelCollections),
packageLibraryMappings ++= Dependencies.nailgun -> Some("lib/jps/nailgun.jar") ::
Dependencies.zincInterface -> Some("lib/jps/compiler-interface.jar") ::
Dependencies.scalaParallelCollections -> Some("lib/jps/scala-parallel-collections.jar") :: Nil
)
lazy val repackagedZinc =
newProject("repackagedZinc", file("target/tools/zinc"))
.settings(
packageOutputDir := baseDirectory.value / "plugin",
packageAssembleLibraries := true,
shadePatterns += ShadePattern("com.google.protobuf.**", "zinc.protobuf.@1"),
packageMethod := PackagingMethod.DepsOnly("lib/jps/incremental-compiler.jar"),
libraryDependencies += Dependencies.zinc)
lazy val compilerShared =
newProject("compiler-shared", file("scala/compiler-shared"))
.settings(
javacOptions in Compile := jpsJavacOptions,
scalacOptions in Compile := jpsScalacOptions,
libraryDependencies ++= Seq(Dependencies.nailgun, Dependencies.compilerIndicesProtocol, Dependencies.zincInterface),
packageLibraryMappings ++= Seq(
Dependencies.nailgun -> Some("lib/jps/nailgun.jar"),
Dependencies.compilerIndicesProtocol -> Some("lib/scala-compiler-indices-protocol_2.12-0.1.1.jar")
),
packageMethod := PackagingMethod.Standalone("lib/compiler-shared.jar", static = true)
)
lazy val runners: Project =
newProject("runners", file("scala/runners"))
.settings(
packageMethod := PackagingMethod.Standalone(static = true),
packageAdditionalProjects ++= Seq(testRunners, testRunners_spec2_2x)
// WORKAROUND fixes build error in sbt 0.13.12+ analogously to https://github.com/scala/scala/pull/5386/
// ivyScala ~= (_ map (_ copy (overrideScalaVersion = false)))
)
lazy val testRunners: Project =
newProject("testRunners", file("scala/testRunners"))
.settings(
packageMethod := PackagingMethod.MergeIntoOther(runners),
libraryDependencies ++= DependencyGroups.testRunners
)
lazy val testRunners_spec2_2x: Project =
newProject("testRunners_spec2_2x", file("scala/testRunners_spec2_2x"))
.dependsOn(testRunners)
.settings(
packageMethod := PackagingMethod.MergeIntoOther(runners),
libraryDependencies ++= Seq(provided.specs2_2x)
)
lazy val nailgunRunners =
newProject("nailgun", file("scala/nailgun"))
.settings(
javacOptions in Compile := jpsJavacOptions,
scalacOptions in Compile := jpsScalacOptions,
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"))
.settings(
libraryDependencies ++= DependencyGroups.decompiler,
packageMethod := PackagingMethod.Standalone("lib/scalap.jar")
)
lazy val macroAnnotations =
newProject("macros", file("scala/macros"))
.settings(
// addCompilerPlugin(Dependencies.macroParadise),
libraryDependencies ++= Seq(Dependencies.scalaReflect, Dependencies.scalaCompiler),
packageMethod := PackagingMethod.Skip()
)
lazy val bsp =
newProject("bsp", file("bsp"))
.dependsOn(
scalaImpl % "test->test;compile->compile",
worksheet % "test->test;compile->compile"
)
.settings(
libraryDependencies ++= DependencyGroups.bsp,
intellijMainJars := Seq.empty
)
// Integration with other IDEA plugins
lazy val devKitIntegration = newProject(
"devKit",
file("scala/integration/devKit"))
.dependsOn(scalaImpl)
.settings(
intellijPlugins += "DevKit".toPlugin
)
lazy val androidIntegration =
newProject("android", file("scala/integration/android"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.settings(
intellijPlugins ++= Seq(
"org.jetbrains.android",
"com.android.tools.idea.smali", // required by Android
"com.intellij.gradle", // required by Android
"org.intellij.groovy", // required by Gradle
"com.intellij.properties").map(_.toPlugin) // required by Gradle
)
lazy val copyrightIntegration =
newProject("copyright", file("scala/integration/copyright"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.settings(
intellijPlugins += "com.intellij.copyright".toPlugin
)
lazy val gradleIntegration =
newProject("gradle", file("scala/integration/gradle"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.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")
.settings(
intellijPlugins += "org.jetbrains.idea.maven".toPlugin
)
lazy val propertiesIntegration =
newProject("properties", file("scala/integration/properties"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.settings(
intellijPlugins += "com.intellij.properties".toPlugin
)
lazy val javaDecompilerIntegration =
newProject("java-decompiler", file("scala/integration/java-decompiler"))
.dependsOn(scalaApi % Compile)
.settings(
intellijPlugins += "org.jetbrains.java.decompiler".toPlugin
)
// Utility projects
val localRepoArtifacts =
("org.jetbrains", sbtStructureExtractor.name, Versions.sbtStructureVersion) ::
("org.jetbrains", "sbt-idea-shell", Versions.sbtIdeaShellVersion) ::
("org.jetbrains.scala" ,"sbt-idea-compiler-indices", Versions.compilerIndicesVersion) :: Nil
val localRepoPaths = LocalRepoPackager.localPluginRepoPaths(localRepoArtifacts)
lazy val runtimeDependencies =
(project in file("target/tools/runtime-dependencies"))
.settings(
scalaVersion := Versions.scalaVersion,
libraryDependencies := DependencyGroups.runtime,
managedScalaInstance := true,
conflictManager := ConflictManager.all,
conflictWarning := ConflictWarning.disable,
resolvers += sbt.Classpaths.sbtPluginReleases,
ideSkipProject := true,
packageMethod := PackagingMethod.DepsOnly(),
packageLibraryMappings := Seq(
"org.scala-lang.modules" % "scala-.*" % ".*" -> None,
// Dependencies.bloopLauncher -> Some("launcher/bloop-launcher.jar"),
Dependencies.sbtLaunch -> Some("launcher/sbt-launch.jar"),
Dependencies.sbtInterface -> Some("lib/jps/sbt-interface.jar"),
Dependencies.zincInterface -> Some("lib/jps/compiler-interface.jar"),
Dependencies.dottySbtBridge -> Some("lib/jps/dotty-sbt-bridge.jar"),
Dependencies.compilerBridgeSources_2_13 -> Some("lib/jps/compiler-interface-sources-2.13.jar"),
Dependencies.compilerBridgeSources_2_11 -> Some("lib/jps/compiler-interface-sources-2.11.jar"),
Dependencies.compilerBridgeSources_2_10 -> Some("lib/jps/compiler-interface-sources-2.10.jar")
),
update := {
LocalRepoPackager.localPluginRepo(target.value / "repo", localRepoPaths)
update.value
},
packageFileMappings ++= {
val repoBase = target.value / "repo"
localRepoPaths.map { path =>
repoBase / path -> s"repo/$path"
}
}
)
lazy val ideaRunner = createRunnerProject(scalaCommunity, "idea-runner")
//lazy val jmhBenchmarks =
// newProject("benchmarks", file("scala/benchmarks"))
// .dependsOn(scalaImpl % "test->test")
// .enablePlugins(JmhPlugin)
// Testing keys and settings
import Common.TestCategory._
def testOnlyCategory(category: String): String =
s"testOnly -- --include-categories=$category --exclude-categories=$flakyTests"
addCommandAlias("runPerfOptTests", testOnlyCategory(perfOptTests))
addCommandAlias("runSlowTests", testOnlyCategory(debuggerTests))
addCommandAlias("runDebuggerTests", testOnlyCategory(debuggerTests))
addCommandAlias("runHighlightingTests", testOnlyCategory(highlightingTests))
addCommandAlias("runScalacTests", testOnlyCategory(scalacTests))
addCommandAlias("runTypeInferenceTests", testOnlyCategory(typecheckerTests))
addCommandAlias("runTestingSupportTests", testOnlyCategory(testingSupportTests))
addCommandAlias("runWorksheetEvaluationTests", testOnlyCategory(worksheetEvaluationTests))
addCommandAlias("runFlakyTests", s"testOnly -- --include-categories=$flakyTests")
val fastTestOptions = "-v -s -a +c +q " +
s"--exclude-categories=$slowTests " +
s"--exclude-categories=$debuggerTests " +
s"--exclude-categories=$perfOptTests " +
s"--exclude-categories=$scalacTests " +
s"--exclude-categories=$typecheckerTests " +
s"--exclude-categories=$testingSupportTests " +
s"--exclude-categories=$highlightingTests " +
s"--exclude-categories=$worksheetEvaluationTests " +
s"--exclude-categories=$flakyTests "
addCommandAlias("runFastTests", s"testOnly -- $fastTestOptions")
// subsets of tests to split the complete test run into smaller chunks
addCommandAlias("runFastTestsComIntelliJ", s"testOnly com.intellij.* -- $fastTestOptions")
addCommandAlias("runFastTestsOrgJetbrains", s"testOnly org.jetbrains.* -- $fastTestOptions")
addCommandAlias("runFastTestsScala", s"testOnly scala.* -- $fastTestOptions")
// run dfa tests directly in that module
addCommandAlias("runDfaTests", "dfa/test")
communityFullClasspath in ThisBuild :=
deduplicatedClasspath(fullClasspath.in(scalaCommunity, Test).value, fullClasspath.in(scalaCommunity, Compile).value)