forked from JetBrains/intellij-scala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
449 lines (391 loc) · 16.7 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
import java.io.File
import Common._
import com.dancingrobot84.sbtidea.tasks.{UpdateIdea => updateIdeaTask}
import sbt.Keys.{`package` => pack}
import sbtide.Keys.ideSkipProject
// Global build settings
resolvers in ThisBuild ++=
BintrayJetbrains.allResolvers :+
Resolver.typesafeIvyRepo("releases")
resolvers in ThisBuild += Resolver.sonatypeRepo("snapshots")
ideaBuild in ThisBuild := Versions.ideaVersion
ideaDownloadDirectory in ThisBuild := homePrefix / ".ScalaPluginIC" / "sdk"
testConfigDir in ThisBuild := homePrefix / ".ScalaPluginIC" / "test-config"
testSystemDir in ThisBuild := homePrefix / ".ScalaPluginIC" / "test-system"
onLoad in Global := ((s: State) => {
"updateIdea" :: s
}) compose (onLoad in Global).value
addCommandAlias("downloadIdea", "updateIdea")
addCommandAlias("packagePluginCommunity", "pluginPackagerCommunity/package")
addCommandAlias("packagePluginCommunityZip", "show pluginCompressorCommunity/package")
// Main projects
lazy val scalaCommunity: sbt.Project =
newProject("scalaCommunity", file("."))
.dependsOn(
scalaImpl % "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")
.aggregate(
scalaImpl,
androidIntegration,
copyrightIntegration,
gradleIntegration,
intellilangIntegration,
mavenIntegration,
propertiesIntegration)
.settings(
aggregate.in(updateIdea) := false,
ideExcludedDirectories := Seq(baseDirectory.value / "target")
)
lazy val scalaImpl: sbt.Project =
newProject("scala-impl", file("scala/scala-impl"))
.dependsOn(compilerShared, decompiler % "test->test;compile->compile", runners % "test->test;compile->compile", macroAnnotations)
.enablePlugins(SbtIdeaPlugin, BuildInfoPlugin)
.settings(commonTestSettings(packagedPluginDir): _*)
.settings(
ideExcludedDirectories := Seq(baseDirectory.value / "testdata" / "projects"),
javacOptions in Global ++= Seq("-source", "1.8", "-target", "1.8"),
scalacOptions in Global ++= Seq("-target:jvm-1.8", "-deprecation"),
//scalacOptions in Global += "-Xmacro-settings:analyze-caches",
libraryDependencies ++= DependencyGroups.scalaCommunity,
unmanagedJars in Compile += file(System.getProperty("java.home")).getParentFile / "lib" / "tools.jar",
addCompilerPlugin(Dependencies.macroParadise),
ideaInternalPlugins := Seq(
"java-i18n",
"android",
"smali", // required by Android
"gradle", // requierd by Android
"Groovy", // requierd by Gradle
"properties", // required by Gradle
"maven", // TODO remove after extracting the SBT module (which depends on Maven)
"junit"
),
ideaInternalPluginsJars :=
ideaInternalPluginsJars.value.filterNot(cp => cp.data.getName.contains("junit-jupiter-api"))
,
Keys.aggregate.in(updateIdea) := false,
buildInfoPackage := "org.jetbrains.plugins.scala.buildinfo",
buildInfoKeys := Seq(
name, version, scalaVersion, sbtVersion,
BuildInfoKey.constant("sbtLatestVersion", Versions.sbtVersion),
BuildInfoKey.constant("sbtStructureVersion", Versions.sbtStructureVersion),
BuildInfoKey.constant("sbtIdeaShellVersion", Versions.sbtIdeaShellVersion),
BuildInfoKey.constant("sbtLatest_0_13", Versions.Sbt.latest_0_13)
),
fullClasspath in Test := deduplicatedClasspath((fullClasspath in Test).value, communityFullClasspath.value)
)
lazy val compilerJps =
newProject("compiler-jps", file("scala/compiler-jps"))
.dependsOn(compilerShared)
.enablePlugins(SbtIdeaPlugin)
.settings(
libraryDependencies ++=
Seq(Dependencies.nailgun) ++
DependencyGroups.sbtBundled
)
lazy val compilerShared =
newProject("compiler-shared", file("scala/compiler-shared"))
.enablePlugins(SbtIdeaPlugin)
.settings(libraryDependencies += Dependencies.nailgun)
lazy val runners =
newProject("runners", file("scala/runners"))
.settings(
libraryDependencies ++= DependencyGroups.runners,
// 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 nailgunRunners =
newProject("nailgun", file("scala/nailgun"))
.dependsOn(runners)
.settings(libraryDependencies += Dependencies.nailgun)
lazy val decompiler =
newProject("decompiler", file("scala/decompiler"))
.settings(commonTestSettings(packagedPluginDir): _*)
.settings(libraryDependencies ++= DependencyGroups.decompiler)
lazy val macroAnnotations =
newProject("macros", file("scala/macros"))
.settings(Seq(
addCompilerPlugin(Dependencies.macroParadise),
libraryDependencies ++= Seq(Dependencies.scalaReflect, Dependencies.scalaCompiler)
): _*)
// Integration with other IDEA plugins
lazy val androidIntegration =
newProject("android", file("scala/integration/android"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.enablePlugins(SbtIdeaPlugin)
.settings(
ideaInternalPlugins := Seq(
"android",
"smali", // required by Android
"gradle", // required by Android
"groovy", // required by Gradle
"properties") // required by Gradle
)
lazy val copyrightIntegration =
newProject("copyright", file("scala/integration/copyright"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.enablePlugins(SbtIdeaPlugin)
.settings(
ideaInternalPlugins := Seq(
"copyright"
)
)
lazy val gradleIntegration =
newProject("gradle", file("scala/integration/gradle"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.enablePlugins(SbtIdeaPlugin)
.settings(
ideaInternalPlugins := Seq(
"gradle",
"groovy", // required by Gradle
"properties") // required by Gradle
)
lazy val intellilangIntegration =
newProject("intellilang", file("scala/integration/intellilang"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.enablePlugins(SbtIdeaPlugin)
.settings(
ideaInternalPlugins := Seq(
"IntelliLang"
)
)
lazy val mavenIntegration =
newProject("maven", file("scala/integration/maven"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.enablePlugins(SbtIdeaPlugin)
.settings(
ideaInternalPlugins := Seq("maven")
)
lazy val propertiesIntegration =
newProject("properties", file("scala/integration/properties"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.enablePlugins(SbtIdeaPlugin)
.settings(
ideaInternalPlugins := Seq(
"properties"
)
)
// Utility projects
lazy val ideaRunner =
newProject("idea-runner", file("target/tools/idea-runner"))
.dependsOn(Seq(compilerShared, runners, scalaCommunity, compilerJps, nailgunRunners, decompiler).map(_ % Provided): _*)
.settings(
autoScalaLibrary := false,
unmanagedJars in Compile := ideaMainJars.in(scalaImpl).value,
unmanagedJars in Compile += file(System.getProperty("java.home")).getParentFile / "lib" / "tools.jar",
// run configuration
fork in run := true,
mainClass in(Compile, run) := Some("com.intellij.idea.Main"),
javaOptions in run ++= Seq(
"-Xmx800m",
"-XX:ReservedCodeCacheSize=64m",
"-XX:MaxPermSize=250m",
"-XX:+HeapDumpOnOutOfMemoryError",
"-ea",
"-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005",
"-Didea.is.internal=true",
"-Didea.debug.mode=true",
s"-Didea.system.path=${homePrefix.getCanonicalPath}/.ScalaPluginIC/system",
s"-Didea.config.path=${homePrefix.getCanonicalPath}/.ScalaPluginIC/config",
"-Dapple.laf.useScreenMenuBar=true",
s"-Dplugin.path=${packagedPluginDir.value}",
"-Didea.ProcessCanceledException=disabled"
),
products in Compile := {
(products in Compile).value :+ (pack in pluginPackagerCommunity).value
}
)
lazy val sbtRuntimeDependencies =
(project in file("target/tools/sbt-runtime-dependencies"))
.settings(
libraryDependencies := DependencyGroups.sbtRuntime,
managedScalaInstance := false,
conflictManager := ConflictManager.all,
conflictWarning := ConflictWarning.disable,
resolvers += sbt.Classpaths.sbtPluginReleases,
ideSkipProject := true
)
//lazy val jmhBenchmarks =
// newProject("benchmarks", file("scala/benchmarks"))
// .dependsOn(scalaImpl % "test->test")
// .enablePlugins(JmhPlugin)
// Testing keys and settings
import Common.TestCategory._
addCommandAlias("runPerfOptTests", s"testOnly -- --include-categories=$perfOptTests")
addCommandAlias("runSlowTests", s"testOnly -- --include-categories=$slowTests")
addCommandAlias("runDebuggerTests", s"testOnly -- --include-categories=$debuggerTests")
addCommandAlias("runHighlightingTests", s"testOnly -- --include-categories=$highlightingTests")
addCommandAlias("runScalacTests", s"testOnly -- --include-categories=$scalacTests")
addCommandAlias("runTypeInferenceTests", s"testOnly org.jetbrains.plugins.scala.lang.typeInference.*")
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=$highlightingTests"
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")
lazy val cleanUpTestEnvironment = taskKey[Unit]("Clean up IDEA test system and config directories")
cleanUpTestEnvironment in ThisBuild := {
IO.delete(testSystemDir.value)
IO.delete(testConfigDir.value)
}
concurrentRestrictions in Global := Seq(
Tags.limit(Tags.Test, 1)
)
communityFullClasspath in ThisBuild :=
deduplicatedClasspath(fullClasspath.in(scalaCommunity, Test).value, fullClasspath.in(scalaCommunity, Compile).value)
// Packaging projects
lazy val packagedPluginDir = settingKey[File]("Path to packaged, but not yet compressed plugin")
packagedPluginDir in ThisBuild := baseDirectory.in(ThisBuild).value / "target" / "plugin" / "Scala"
lazy val iLoopWrapperPath = settingKey[File]("Path to repl interface sources")
iLoopWrapperPath := baseDirectory.in(compilerJps).value / "resources" / "ILoopWrapperImpl.scala"
//packages output of several modules to a single jar
lazy val scalaPluginJarPackager =
newProject("scalaPluginJarPackager", file("target/tools/scalaPluginJarPackager"))
.settings(
products in Compile :=
products.in(scalaImpl, Compile).value ++
products.in(androidIntegration, Compile).value ++
products.in(copyrightIntegration, Compile).value ++
products.in(gradleIntegration, Compile).value ++
products.in(intellilangIntegration, Compile).value ++
products.in(mavenIntegration, Compile).value ++
products.in(propertiesIntegration, Compile).value,
ideSkipProject := true
)
lazy val pluginPackagerCommunity =
newProject("pluginPackagerCommunity", file("target/tools/packager"))
.settings(
artifactPath := packagedPluginDir.value,
dependencyClasspath :=
dependencyClasspath.in(scalaCommunity, Compile).value ++
dependencyClasspath.in(compilerJps, Compile).value ++
dependencyClasspath.in(runners, Compile).value ++
dependencyClasspath.in(sbtRuntimeDependencies, Compile).value
,
mappings := {
import Dependencies._
import Packaging.PackageEntry._
val crossLibraries = (
List(Dependencies.scalaParserCombinators, Dependencies.scalaXml) ++
DependencyGroups.scalaCommunity
).distinct
val jps = Seq(
Artifact(pack.in(compilerJps, Compile).value,
"lib/jps/compiler-jps.jar"),
Library(nailgun,
"lib/jps/nailgun.jar"),
Library(Dependencies.compilerBridgeSources_2_10,
"lib/jps/compiler-interface-sources-2.10.jar"),
Library(Dependencies.compilerBridgeSources_2_11,
"lib/jps/compiler-interface-sources-2.11.jar"),
Library(Dependencies.compilerBridgeSources_2_13,
"lib/jps/compiler-interface-sources-2.13.jar"),
Artifact((assembly in repackagedZinc).value,
"lib/jps/incremental-compiler.jar"),
Library(Dependencies.zincInterface,
"lib/jps/compiler-interface.jar"),
Library(sbtInterface,
"lib/jps/sbt-interface.jar"),
Artifact(Packaging.putInTempJar(baseDirectory.in(compilerJps).value / "resources" / "ILoopWrapperImpl.scala"),
"lib/jps/repl-interface-sources.jar")
)
val launcher = Seq(
Library(sbtStructureExtractor_012,
"launcher/sbt-structure-0.12.jar"),
Library(sbtStructureExtractor_013,
"launcher/sbt-structure-0.13.jar"),
Library(sbtStructureExtractor_100,
"launcher/sbt-structure-1.0.jar"),
Library(sbtLaunch,
"launcher/sbt-launch.jar")
)
val lib = Seq(
Artifact(pack.in(scalaPluginJarPackager, Compile).value,
"lib/scala-plugin.jar"),
Artifact(pack.in(decompiler, Compile).value,
"lib/scalap.jar"),
Artifact(pack.in(compilerShared, Compile).value,
"lib/compiler-shared.jar"),
Artifact(pack.in(nailgunRunners, Compile).value,
"lib/scala-nailgun-runner.jar"),
Artifact(pack.in(runners, Compile).value,
"lib/runners.jar"),
AllOrganisation("org.scalameta", "lib/scalameta120.jar"),
Library(fastparse,
"lib/fastparse.jar"),
Library(scalaLibrary,
"lib/scala-library.jar"),
Library(bcel,
"lib/bcel.jar")
) ++
crossLibraries.map { lib =>
Library(
lib.copy(name = Packaging.crossName(lib, scalaVersion.value)),
s"lib/${lib.name}.jar"
)
}
val repo = {
val localRepo = target.value / "repo"
LocalRepoPackager.localPluginRepo(
localRepo,
Seq(
(Dependencies.sbtStructureExtractor.name, Versions.sbtStructureVersion),
("sbt-idea-shell", Versions.sbtIdeaShellVersion)))
Seq(Directory(localRepo,"repo/"))
}
Packaging.convertEntriesToMappings(
jps ++ lib ++ launcher ++ repo,
dependencyClasspath.value
)
},
pack := {
Packaging.packagePlugin(mappings.value, artifactPath.value)
artifactPath.value
},
ideSkipProject := true
)
lazy val pluginCompressorCommunity =
newProject("pluginCompressorCommunity", file("target/tools/compressor"))
.settings(
artifactPath := baseDirectory.in(ThisBuild).value / "target" / "scala-plugin.zip",
pack := {
Packaging.compressPackagedPlugin(pack.in(pluginPackagerCommunity).value, artifactPath.value)
artifactPath.value
},
ideSkipProject := true
)
lazy val repackagedZinc =
newProject("repackagedZinc", file("target/tools/zinc"))
.settings(
assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false),
libraryDependencies += Dependencies.zinc,
ideSkipProject := true
)
updateIdea := {
val baseDir = ideaBaseDirectory.value
val build = ideaBuild.in(ThisBuild).value
try {
updateIdeaTask(baseDir, IdeaEdition.Community, build, downloadSources = true, Seq.empty, streams.value)
} catch {
case e: sbt.TranslatedException if e.getCause.isInstanceOf[java.io.FileNotFoundException] =>
val newBuild = build.split('.').init.mkString(".") + "-EAP-CANDIDATE-SNAPSHOT"
streams.value.log.warn(s"Failed to download IDEA $build, trying $newBuild")
IO.deleteIfEmpty(Set(baseDir))
updateIdeaTask(baseDir, IdeaEdition.Community, newBuild, downloadSources = true, Seq.empty, streams.value)
}
}
lazy val packILoopWrapper = taskKey[Unit]("Packs in repl-interface-sources.jar repl interface for worksheet repl mode")
packILoopWrapper := {
val fn = iLoopWrapperPath.value
IO.zip(Seq((fn, fn.getName)),
baseDirectory.in(BuildRef(file(".").toURI)).value / "target" / "plugin" / "Scala" / "lib" / "jps" / "repl-interface-sources.jar")
}