forked from JetBrains/intellij-scala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
289 lines (254 loc) · 12.3 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
import Common._
import Dependencies.sbtStructureExtractor
import org.jetbrains.sbtidea.tasks.packaging.ShadePattern
import sbtide.Keys.ideSkipProject
// Global build settings
ideaPluginName in ThisBuild := "Scala"
ideaBuild in ThisBuild := Versions.ideaVersion
resolvers in ThisBuild ++=
BintrayJetbrains.allResolvers :+
Resolver.typesafeIvyRepo("releases") :+
Resolver.sonatypeRepo("snapshots")
// Main projects
lazy val scalaCommunity: sbt.Project =
newProject("scalaCommunity", file("."))
.dependsOn(
bsp % "test->test;compile->compile",
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",
javaDecompilerIntegration)
.settings(
ideExcludedDirectories := Seq(baseDirectory.value / "target"),
packageAdditionalProjects := Seq(compilerJps, repackagedZinc, decompiler, compilerShared, nailgunRunners, runners, sbtRuntimeDependencies),
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 scalaImpl: sbt.Project =
newProject("scala-impl", file("scala/scala-impl"))
.dependsOn(compilerShared, decompiler % "test->test;compile->compile", runners % "test->test;compile->compile", macroAnnotations)
.enablePlugins(BuildInfoPlugin)
.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,
addCompilerPlugin(Dependencies.macroParadise),
ideaInternalPlugins := Seq(
"IntelliLang",
"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")),
packageMethod := PackagingMethod.MergeIntoOther(scalaCommunity),
packageLibraryMappings ++= Seq(
"org.scalameta" %% ".*" % ".*" -> Some("lib/scalameta.jar"),
"com.trueaccord.scalapb" %% "scalapb-runtime" % ".*" -> None,
"com.google.protobuf" % "protobuf-java" % ".*" -> None,
"com.trueaccord.lenses" %% "lenses" % ".*" -> None,
"com.lihaoyi" %% "fastparse-utils" % ".*" -> None,
"commons-lang" % "commons-lang" % ".*" -> None,
Dependencies.scalaXml -> Some("lib/scala-xml.jar"),
Dependencies.scalaReflect -> Some("lib/scala-reflect.jar"),
Dependencies.scalaLibrary -> None
),
packageFileMappings += baseDirectory.in(compilerJps).value / "resources" / "ILoopWrapperImpl.scala" ->
"lib/jps/repl-interface-sources.jar",
buildInfoPackage := "org.jetbrains.plugins.scala.buildinfo",
buildInfoKeys := Seq(
name, version, scalaVersion, sbtVersion,
BuildInfoKey.constant("sbtStructureVersion", Versions.sbtStructureVersion),
BuildInfoKey.constant("sbtIdeaShellVersion", Versions.sbtIdeaShellVersion),
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)
)
)
lazy val compilerJps =
newProject("compiler-jps", file("scala/compiler-jps"))
.dependsOn(compilerShared, repackagedZinc)
.settings(
packageMethod := PackagingMethod.Standalone("lib/jps/compiler-jps.jar", static = true),
libraryDependencies ++= Dependencies.nailgun :: Dependencies.zincInterface :: Nil,
packageLibraryMappings ++= Dependencies.nailgun -> Some("lib/jps/nailgun.jar") ::
Dependencies.zincInterface -> Some("lib/jps/compiler-interface.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(
libraryDependencies += Dependencies.nailgun,
packageLibraryMappings += Dependencies.nailgun -> Some("lib/jps/nailgun.jar"),
packageMethod := PackagingMethod.Standalone("lib/compiler-shared.jar", static = true)
)
lazy val runners =
newProject("runners", file("scala/runners"))
.settings(
packageMethod := PackagingMethod.Standalone(static = true),
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,
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", bspDeps)
lazy val bspDeps =
newProject("bspDeps", file("target/tools/bspDeps"))
.settings(
packageAssembleLibraries := true,
libraryDependencies ++= DependencyGroups.bsp,
packageMethod := PackagingMethod.DepsOnly("lib/bsp-deps.jar")
)
// Integration with other IDEA plugins
lazy val androidIntegration =
newProject("android", file("scala/integration/android"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.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")
.settings(
ideaInternalPlugins := Seq("copyright")
)
lazy val gradleIntegration =
newProject("gradle", file("scala/integration/gradle"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.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")
.settings(
ideaInternalPlugins := Seq("IntelliLang")
)
lazy val mavenIntegration =
newProject("maven", file("scala/integration/maven"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.settings(
ideaInternalPlugins := Seq("maven")
)
lazy val propertiesIntegration =
newProject("properties", file("scala/integration/properties"))
.dependsOn(scalaImpl % "test->test;compile->compile")
.settings(
ideaInternalPlugins := Seq("properties")
)
lazy val javaDecompilerIntegration =
newProject("java-decompiler", file("scala/integration/java-decompiler"))
.dependsOn(scalaImpl % Compile)
.settings(
ideaInternalPlugins := Seq("java-decompiler")
)
// Utility projects
val localRepoArtifacts =
(sbtStructureExtractor.name, Versions.sbtStructureVersion) ::
("sbt-idea-shell", Versions.sbtIdeaShellVersion) :: Nil
val localRepoPaths = LocalRepoPackager.localPluginRepoPaths(localRepoArtifacts)
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,
packageMethod := PackagingMethod.Skip(),
packageLibraryMappings ++= Seq(
Dependencies.sbtLaunch -> Some("launcher/sbt-launch.jar"),
Dependencies.sbtInterface -> Some("lib/jps/sbt-interface.jar"),
Dependencies.zincInterface -> Some("lib/jps/compiler-interface.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"),
Dependencies.sbtStructureExtractor_100 -> Some("launcher/sbt-structure-1.0.jar"),
Dependencies.sbtStructureExtractor_013 -> Some("launcher/sbt-structure-0.13.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._
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")
communityFullClasspath in ThisBuild :=
deduplicatedClasspath(fullClasspath.in(scalaCommunity, Test).value, fullClasspath.in(scalaCommunity, Compile).value)