forked from xeno-by/rsc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
335 lines (311 loc) · 11.1 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
lazy val V = new {
val asm = "6.0"
val scala = computeScalaVersionFromTravisYml("2.12")
val scalafix = computeScalafixVersionFromBinScalafix()
val scalameta = "4.1.6"
val scalametaScalacPlugin = "4.2.5"
val scalatest = "3.0.5"
}
addCommandAlias("ci-fmt", ui.ciFmt)
addCommandAlias("ci-fast", ui.ciFast)
addCommandAlias("ci-slow", ui.ciSlow)
addCommandAlias("ci-scalafix", ui.ciScalafix)
addCommandAlias("ci", ui.ci)
addCommandAlias("cleanAll", ui.cleanAll)
addCommandAlias("compileAll", ui.compileAll)
addCommandAlias("fmtAll", ui.fmtAll)
addCommandAlias("testAll", ui.testAll)
addCommandAlias("benchAll", ui.benchAll)
addCommandAlias("clean", ui.cleanAll)
addCommandAlias("compile", ui.compile)
addCommandAlias("fast", ui.fastTest)
addCommandAlias("slow", ui.slowTest)
addCommandAlias("fest", ui.scalafixTest)
addCommandAlias("test", ui.test)
addCommandAlias("fmt", ui.fmtAll)
addCommandAlias("benchParse", ui.benchParse)
addCommandAlias("benchIndex", ui.benchIndex)
addCommandAlias("benchOutline", ui.benchOutline)
addCommandAlias("benchSemanticdb", ui.benchSemanticdb)
addCommandAlias("benchScalasig", ui.benchScalasig)
addCommandAlias("benchScalac", ui.benchScalac)
addCommandAlias("publish", ui.publish)
addCommandAlias("publishLocal", ui.publishLocal)
addCommandAlias("publishSigned", ui.publishSigned)
addCommandAlias("rewrite", ui.rewrite)
version.in(ThisBuild) := {
val rscVersion = version.in(ThisBuild).value.replace("+", "-")
println(s"[info] Welcome to Rsc $rscVersion")
val expectedJvmVersion = "1.8"
val actualJvmVersion = sys.props("java.specification.version")
if (actualJvmVersion != expectedJvmVersion) {
val error = s"expected $expectedJvmVersion, actual $actualJvmVersion"
sys.error(s"Unsupported JVM: $error")
}
rscVersion
}
lazy val bench = project
.in(file("bench"))
.dependsOn(tests)
.enablePlugins(JmhPlugin)
.settings(commonSettings)
lazy val check = project
.in(file("check"))
.dependsOn(rsc)
.settings(
commonSettings,
publishableSettings,
moduleName := "rsc-check",
scalacOptions += "-Xexperimental",
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3",
libraryDependencies += "com.github.pathikrit" %% "better-files" % "3.8.0",
libraryDependencies += "commons-cli" % "commons-cli" % "1.4",
libraryDependencies += "io.github.java-diff-utils" % "java-diff-utils" % "4.0",
libraryDependencies += "io.github.soc" % "directories" % "10",
libraryDependencies += "org.ow2.asm" % "asm" % V.asm,
libraryDependencies += "org.ow2.asm" % "asm-util" % V.asm,
libraryDependencies += "org.scala-lang" % "scalap" % V.scala,
libraryDependencies += "org.eclipse.jgit" % "org.eclipse.jgit" % "4.6.0.201612231935-r",
libraryDependencies += "org.scala-lang" % "scala-compiler" % V.scala,
libraryDependencies += "org.scalameta" %% "cli" % V.scalameta,
libraryDependencies += "org.scalameta" %% "metacp" % V.scalameta,
libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.25",
libraryDependencies += "org.slf4j" % "log4j-over-slf4j" % "1.7.25"
)
lazy val examplesCore = project
.in(file("examples/core"))
.dependsOn(examplesFunction)
.settings(
commonSettings,
semanticdbSettings,
libraryDependencies += "org.scala-lang" % "scala-reflect" % V.scala,
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4"
)
lazy val examplesDeps1 = project
.in(file("examples/deps1"))
.settings(commonSettings)
lazy val examplesDeps2 = project
.in(file("examples/deps2"))
.dependsOn(examplesDeps1)
.settings(commonSettings)
lazy val examplesDeps3 = project
.in(file("examples/deps3"))
.dependsOn(examplesDeps2)
.settings(commonSettings)
lazy val examplesError = project
.in(file("examples/error"))
.dependsOn(examplesErrordeps)
.settings(commonSettings)
lazy val examplesErrordeps = project
.in(file("examples/errordeps"))
.settings(commonSettings)
lazy val examplesFunction = project
.in(file("examples/function"))
.settings(commonSettings)
lazy val examplesOriginalCore = project
.in(file("examples/original/core"))
.dependsOn(examplesFunction)
.settings(
commonSettings,
semanticdbSettings,
libraryDependencies += "org.scala-lang" % "scala-reflect" % V.scala,
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4"
)
lazy val examplesSemantic = project
.in(file("examples/semantic"))
.dependsOn(examplesDeps3)
.settings(commonSettings)
lazy val rsc = project
.in(file("rsc"))
.dependsOn(scalasig)
.settings(
commonSettings,
publishableSettings,
libraryDependencies += "org.scalameta" %% "semanticdb" % V.scalameta,
libraryDependencies += "com.lihaoyi" %% "fastparse" % "1.0.0",
mainClass := Some("rsc.cli.Main")
)
lazy val scalafixInput = project
.in(file("scalafix/input"))
.settings(
commonSettings,
semanticdbSettings,
libraryDependencies += "com.twitter" %% "bijection-core" % "0.9.5"
)
lazy val scalafixOutput = project
.in(file("scalafix/output"))
.settings(
commonSettings,
semanticdbSettings,
libraryDependencies += "com.twitter" %% "bijection-core" % "0.9.5"
)
lazy val scalafixRules = project
.in(file("scalafix/rules"))
.dependsOn(rsc)
.settings(
commonSettings,
publishableSettings,
moduleName := "rsc-rules",
libraryDependencies += "ch.epfl.scala" %% "scalafix-core" % V.scalafix
)
lazy val scalafixTests = project
.in(file("scalafix/tests"))
.dependsOn(scalafixInput, scalafixRules)
.enablePlugins(ScalafixTestkitPlugin)
.settings(
commonSettings,
libraryDependencies += "ch.epfl.scala" % "scalafix-testkit" % V.scalafix % Test cross CrossVersion.full,
scalafixTestkitOutputSourceDirectories :=
sourceDirectories.in(scalafixOutput, Compile).value ++
sourceDirectories.in(examplesCore, Compile).value,
scalafixTestkitInputSourceDirectories :=
sourceDirectories.in(scalafixInput, Compile).value ++
sourceDirectories.in(examplesOriginalCore, Compile).value,
scalafixTestkitInputClasspath :=
fullClasspath.in(scalafixInput, Compile).value ++
fullClasspath.in(examplesOriginalCore, Compile).value
)
lazy val scalasig = project
.in(file("scalasig/scalasig"))
.settings(
commonSettings,
publishableSettings,
libraryDependencies += "org.ow2.asm" % "asm" % V.asm,
libraryDependencies += "org.ow2.asm" % "asm-tree" % V.asm
)
lazy val scalap = project
.in(file("scalasig/scalap"))
.dependsOn(scalasig)
.settings(
commonSettings,
publishableSettings,
libraryDependencies += "org.scalameta" %% "cli" % V.scalameta,
mainClass := Some("scala.meta.cli.Scalap")
)
lazy val tests = project
.in(file("tests"))
.dependsOn(check, rsc, scalap)
.enablePlugins(BuildInfoPlugin)
.configs(Fast, Slow)
.settings(
commonSettings,
libraryDependencies += "org.scalatest" %% "scalatest" % V.scalatest,
libraryDependencies += "org.scalatest" %% "scalatest" % V.scalatest % "test",
buildInfoUsePackageAsPath := true,
buildInfoKeys := Seq(
"sourceRoot" -> (baseDirectory in ThisBuild).value,
BuildInfoKey.map(dependencyClasspath.in(examplesCore, Compile)) {
case (k, v) => "coreClasspath" -> v.map(_.data)
},
BuildInfoKey.map(dependencyClasspath.in(examplesErrordeps, Compile)) {
case (k, v) => "errorClasspath" -> v.map(_.data)
},
BuildInfoKey.map(dependencyClasspath.in(examplesFunction, Compile)) {
case (k, v) => "functionClasspath" -> v.map(_.data)
},
BuildInfoKey.map(dependencyClasspath.in(examplesDeps1, Compile)) {
case (k, v) => "depsClasspath" -> v.map(_.data)
},
BuildInfoKey.map(dependencyClasspath.in(examplesSemantic, Compile)) {
case (k, v) => "semanticClasspath" -> v.map(_.data)
}
),
buildInfoPackage := "rsc.tests",
testOptions.in(Test) += Tests.Argument("-l", "org.scalatest.tags.Slow"),
inConfig(Fast)(Defaults.testTasks),
inConfig(Slow)(Defaults.testTasks),
testOptions.in(Slow) -= Tests.Argument("-l", "org.scalatest.tags.Slow"),
testOptions.in(Slow) += Tests.Argument("-n", "org.scalatest.tags.Slow")
)
lazy val commonSettings = Seq(
organization := "com.twitter",
scalaVersion := V.scala,
crossScalaVersions := Seq(V.scala),
scalacOptions ++= Seq("-Ypatmat-exhaust-depth", "off"),
scalacOptions += "-deprecation",
scalacOptions += "-unchecked",
scalacOptions += "-feature",
scalacOptions += "-Ywarn-unused-import",
scalacOptions ++= { if (isCI) List("-Xfatal-warnings") else Nil },
scalacOptions in (Compile, console) := Nil,
fork in run := true,
fork in Test := true,
javaOptions += "-Xmx4G",
baseDirectory in run := (baseDirectory in ThisBuild).value,
baseDirectory in Test := (baseDirectory in ThisBuild).value,
cancelable := true,
resolvers += Opts.resolver.sonatypeReleases,
resolvers += Opts.resolver.sonatypeSnapshots
)
lazy val publishableSettings = Seq(
publishTo := Some {
val prop = sys.props("repository")
if (prop != null) "adhoc" at prop
else if (version.value.endsWith("SNAPSHOT")) Opts.resolver.sonatypeSnapshots
else Opts.resolver.sonatypeStaging
},
credentials ++= {
val prop = sys.props("credentials")
if (prop != null) List(new FileCredentials(file(prop)))
else Nil
},
publishArtifact.in(Compile) := true,
publishArtifact.in(Test) := false,
publishMavenStyle := true,
pomIncludeRepository := { x =>
false
},
licenses += "Apache v2" -> url("https://github.com/twitter/rsc/blob/master/LICENSE.md"),
pomExtra := (
<url>https://github.com/twitter/rsc</url>
<inceptionYear>2017</inceptionYear>
<scm>
<url>git://github.com/twitter/rsc.git</url>
<connection>scm:git:git://github.com/twitter/rsc.git</connection>
</scm>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/twitter/rsc/issues</url>
</issueManagement>
<developers>
<developer>
<id>xeno-by</id>
<name>Eugene Burmako</name>
<url>https://github.com/xeno-by</url>
</developer>
<developer>
<id>ShaneDelmore</id>
<name>Shane Delmore</name>
<url>https://github.com/ShaneDelmore</url>
</developer>
<developer>
<id>maxov</id>
<name>Max Ovsiankin</name>
<url>https://github.com/maxov</url>
</developer>
<developer>
<id>WiWa</id>
<name>Win Wang</name>
<url>https://github.com/WiWa</url>
</developer>
<developer>
<id>sundresh</id>
<name>Sameer Sundresh</name>
<url>https://github.com/sundresh</url>
</developer>
</developers>
)
)
lazy val semanticdbSettings = Def.settings(
scalacOptions -= "-deprecation",
scalacOptions -= "-unchecked",
scalacOptions -= "-feature",
scalacOptions -= "-Ywarn-unused-import",
scalacOptions -= "-Xfatal-warnings",
addCompilerPlugin(
"org.scalameta" %% "semanticdb-scalac" % V.scalametaScalacPlugin cross CrossVersion.full),
scalacOptions += "-Yrangepos",
scalacOptions += "-P:semanticdb:text:off",
scalacOptions += "-P:semanticdb:symbols:all",
scalacOptions += "-P:semanticdb:synthetics:on"
)