forked from JetBrains/intellij-scala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
371 lines (318 loc) · 13.5 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
import java.io.File
import Common._
import com.dancingrobot84.sbtidea.tasks.{UpdateIdea => updateIdeaTask}
import sbt.Keys.{`package` => pack}
// Global build settings
resolvers in ThisBuild ++=
BintrayJetbrains.allResolvers :+
Resolver.typesafeIvyRepo("releases")
resolvers in ThisBuild += Resolver.sonatypeRepo("snapshots")
lazy val sdkDirectory = SettingKey[File]("sdk-directory", "Path to SDK directory where unmanagedJars and IDEA are located")
sdkDirectory in ThisBuild := baseDirectory.in(ThisBuild).value / "SDK"
ideaBuild in ThisBuild := Versions.ideaVersion
ideaDownloadDirectory in ThisBuild := sdkDirectory.value / "ideaSDK"
onLoad in Global := ((s: State) => { "updateIdea" :: s}) compose (onLoad in Global).value
addCommandAlias("downloadIdea", "updateIdea")
addCommandAlias("packagePluginCommunity", "pluginPackagerCommunity/package")
addCommandAlias("packagePluginCommunityZip", "pluginCompressorCommunity/package")
// Main projects
lazy val scalaCommunity: sbt.Project =
newProject("scalaCommunity", file("."))
.dependsOn(jpsShared, 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(
"copyright",
"gradle",
"Groovy",
"IntelliLang",
"java-i18n",
"android",
"maven",
"junit",
"properties"
),
ideaInternalPluginsJars :=
ideaInternalPluginsJars.value
.filterNot(cp => cp.data.getName.contains("lucene-core") || cp.data.getName.contains("junit-jupiter-api"))
,
Keys.aggregate.in(updateIdea) := false,
test in Test := test.in(Test).dependsOn(setUpTestEnvironment).value,
testOnly in Test := testOnly.in(Test).dependsOn(setUpTestEnvironment).evaluated,
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)
)
)
lazy val jpsPlugin =
newProject("jpsPlugin", file("jps-plugin"))
.dependsOn(jpsShared)
.enablePlugins(SbtIdeaPlugin)
.settings(
libraryDependencies ++=
Seq(Dependencies.nailgun) ++
DependencyGroups.sbtBundled
)
lazy val jpsShared =
newProject("jpsShared", file("jpsShared"))
.enablePlugins(SbtIdeaPlugin)
.settings(libraryDependencies += Dependencies.nailgun)
lazy val scalaRunner =
newProject("scalaRunner", file("ScalaRunner"))
.settings(
libraryDependencies ++= DependencyGroups.scalaRunner,
// 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 runners =
newProject("runners", file("Runners"))
.dependsOn(scalaRunner)
.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("nailgunRunners", file("NailgunRunners"))
.dependsOn(scalaRunner)
.settings(libraryDependencies += Dependencies.nailgun)
lazy val decompiler =
newProject("decompiler", file("decompiler"))
.settings(commonTestSettings(packagedPluginDir):_*)
.settings(libraryDependencies ++= DependencyGroups.decompiler)
lazy val macroAnnotations =
newProject("macroAnnotations", file("macroAnnotations"))
.settings(Seq(
addCompilerPlugin(Dependencies.macroParadise),
libraryDependencies ++= Seq(Dependencies.scalaReflect, Dependencies.scalaCompiler)
): _*)
// Utility projects
lazy val ideaRunner =
newProject("ideaRunner", file("idea-runner"))
.dependsOn(Seq(jpsShared, scalaRunner, runners, scalaCommunity, jpsPlugin, nailgunRunners, decompiler).map(_ % Provided): _*)
.settings(
autoScalaLibrary := false,
unmanagedJars in Compile := ideaMainJars.in(scalaCommunity).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=${System.getProperty("user.home")}/.IdeaData/IDEA-14/scala/system",
s"-Didea.config.path=${System.getProperty("user.home")}/.IdeaData/IDEA-14/scala/config",
"-Dapple.laf.useScreenMenuBar=true",
s"-Dplugin.path=${baseDirectory.value.getParentFile}/out/plugin/Scala",
"-Didea.ProcessCanceledException=disabled"
),
products in Compile := {
(products in Compile).value :+ (pack in pluginPackagerCommunity).value
}
)
lazy val sbtRuntimeDependencies = project
.settings(
libraryDependencies := DependencyGroups.sbtRuntime,
managedScalaInstance := false,
conflictManager := ConflictManager.all,
conflictWarning := ConflictWarning.disable,
resolvers += sbt.Classpaths.sbtPluginReleases
)
lazy val testDownloader =
newProject("testJarsDownloader")
.settings(
conflictManager := ConflictManager.all,
conflictWarning := ConflictWarning.disable,
resolvers ++= Seq(
"Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases",
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
),
libraryDependencies ++= DependencyGroups.testDownloader,
libraryDependencies ++= DependencyGroups.mockSbtDownloader,
libraryDependencies ++= DependencyGroups.testScalaLibraryDownloader,
dependencyOverrides ++= Set(
"com.chuusai" % "shapeless_2.11" % "2.0.0"
),
update := update.dependsOn(update.in(sbtLaunchTestDownloader)).value,
ideSkipProject := true
)
lazy val sbtLaunchTestDownloader =
newProject("sbtLaunchTestDownloader")
.settings(
autoScalaLibrary := false,
conflictManager := ConflictManager.all,
libraryDependencies ++= DependencyGroups.sbtLaunchTestDownloader,
ideSkipProject := true
)
lazy val jmhBenchmarks =
newProject("jmhBenchmarks")
.dependsOn(scalaCommunity % "test->test")
.enablePlugins(JmhPlugin)
// Testing keys and settings
import TestCategory._
addCommandAlias("runPerfOptTests", s"testOnly -- --include-categories=$perfOptTests")
addCommandAlias("runSlowTests", s"testOnly -- --include-categories=$slowTests")
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=$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 setUpTestEnvironment = taskKey[Unit]("Set up proper environment for running tests")
setUpTestEnvironment in ThisBuild := {
update.in(testDownloader).value
}
lazy val cleanUpTestEnvironment = taskKey[Unit]("Clean up IDEA test system and config directories")
cleanUpTestEnvironment in ThisBuild := {
IO.delete(testSystemDir)
IO.delete(testConfigDir)
}
concurrentRestrictions in Global := Seq(
Tags.limit(Tags.Test, 1)
)
// Packaging projects
lazy val packagedPluginDir = settingKey[File]("Path to packaged, but not yet compressed plugin")
packagedPluginDir in ThisBuild := baseDirectory.in(ThisBuild).value / "out" / "plugin" / "Scala"
lazy val iLoopWrapperPath = settingKey[File]("Path to repl interface sources")
iLoopWrapperPath := baseDirectory.in(jpsPlugin).value / "resources" / "ILoopWrapperImpl.scala"
lazy val pluginPackagerCommunity =
newProject("pluginPackagerCommunity")
.settings(
artifactPath := packagedPluginDir.value,
dependencyClasspath :=
dependencyClasspath.in(scalaCommunity, Compile).value ++
dependencyClasspath.in(jpsPlugin, Compile).value ++
dependencyClasspath.in(runners, Compile).value ++
dependencyClasspath.in(sbtRuntimeDependencies, Compile).value
,
mappings := {
import Packaging.PackageEntry._
import Dependencies._
val crossLibraries = (
List(Dependencies.scalaParserCombinators, Dependencies.scalaXml) ++
DependencyGroups.scalaCommunity
).distinct
val jps = Seq(
Artifact(pack.in(jpsPlugin, Compile).value,
"lib/jps/scala-jps-plugin.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"),
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(jpsPlugin).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(scalaCommunity, Compile).value,
"lib/scala-plugin.jar"),
Artifact(pack.in(decompiler, Compile).value,
"lib/scalap.jar"),
Artifact(pack.in(jpsShared, Compile).value,
"lib/jpsShared.jar"),
Artifact(pack.in(nailgunRunners, Compile).value,
"lib/scala-nailgun-runner.jar"),
MergedArtifact(Seq(
pack.in(runners, Compile).value,
pack.in(scalaRunner, Compile).value),
"lib/scala-plugin-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"
)
}
Packaging.convertEntriesToMappings(
jps ++ lib ++ launcher,
dependencyClasspath.value
)
},
pack := {
Packaging.packagePlugin(mappings.value, artifactPath.value)
artifactPath.value
}
)
lazy val pluginCompressorCommunity =
newProject("pluginCompressorCommunity")
.settings(
artifactPath := baseDirectory.in(ThisBuild).value / "out" / "scala-plugin.zip",
pack := {
Packaging.compressPackagedPlugin(pack.in(pluginPackagerCommunity).value, artifactPath.value)
artifactPath.value
}
)
lazy val repackagedZinc =
newProject("repackagedZinc")
.settings(
assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false),
libraryDependencies += Dependencies.zinc
)
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 / "out" / "plugin" / "Scala" / "lib" / "jps" / "repl-interface-sources.jar")
}