forked from rescala-lang/REScala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
389 lines (343 loc) · 12.6 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
import java.nio.file.Files
// shadow sbt-scalajs' crossProject and CrossType from Scala.js 0.6.x
import sbtcrossproject.CrossPlugin.autoImport.{CrossType, crossProject}
import Settings._
import Dependencies._
import Dependencies.{Versions => V}
ThisBuild / incOptions := (ThisBuild / incOptions).value.withLogRecompileOnMacro(false)
cfg.noPublish
lazy val rescalaAggregate = project.in(file(".")).settings(cfg.base).aggregate(
dividiParoli,
documentation,
examples,
fullmv,
microbench,
rescalaJS,
rescalaJVM,
rescalafx,
reswing,
todolist,
universe
)
.settings(cfg.noPublish)
lazy val rescala = crossProject(JSPlatform, JVMPlatform).in(file("Code/Main"))
.settings(
name := "rescala",
cfg.base,
cfg.test,
cfg.bintray,
Resolvers.stg,
libraryDependencies ++= Seq(
scalatestpluscheck.value,
sourcecode.value,
retypecheck.value,
reactiveStreams.value,
scalaOrganization.value % "scala-reflect" % scalaVersion.value % "provided",
catsCollectionsCore.value
) ++ (
jsoniterScalaAll.value ++
// built in serializability of lattice vertices
circeAll.value.map(_ % "provided,test") ++
Seq(
loci.wsAkka.value,
loci.circe.value,
loci.upickle.value,
loci.communication.value,
scalaJavaTime.value,
).map(_ % "test")
)
)
.jvmSettings(
libraryDependencies ++= akkaHttpAll.value.map(_ % "test")
)
.jsSettings(
libraryDependencies ++= Seq(
// for restoration
scalajsDom.value % "provided",
// for rescalatags
scalatags.value % "provided,test",
),
// dom envirnoment
jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv()
)
// .nativeSettings(
// crossScalaVersions := Seq("2.11.8"),
// scalaVersion := "2.11.8")
lazy val rescalaJVM = rescala.jvm
lazy val rescalaJS = rescala.js
//lazy val rescalaNative = rescala.native
lazy val documentation = project.in(file("Documentation/DocumentationProject"))
.settings(cfg.base, cfg.noPublish, scalacOptions += "-Xlint:-unused")
.enablePlugins(TutPlugin)
.dependsOn(rescalaJVM, rescalaJS)
// ===================================================================================== Extensions
lazy val reswing = project.in(file("Code/Extensions/RESwing"))
.settings(name := "reswing", cfg.base, cfg.noPublish, libraryDependencies += scalaSwing.value)
.dependsOn(rescalaJVM)
lazy val rescalafx = project.in(file("Code/Extensions/javafx"))
.dependsOn(rescalaJVM)
.settings(name := "rescalafx", cfg.base, cfg.noPublish, lib.scalafx)
lazy val locidistribution = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
.in(file("Code/Extensions/LociDistribution"))
.dependsOn(rescala % "compile->compile;test->test")
.settings(
name := "loci-distribution",
cfg.base,
cfg.noPublish,
libraryDependencies ++= Seq(
loci.communication.value,
loci.circe.value,
loci.upickle.value
)
)
lazy val locidistributionJS = locidistribution.js
lazy val locidistributionJVM = locidistribution.jvm
// ===================================================================================== Examples
lazy val examples = project.in(file("Code/Examples/examples"))
.dependsOn(rescalaJVM, reswing)
.settings(
name := "rescala-examples",
cfg.base,
cfg.noPublish,
libraryDependencies ++= Seq(
scalaXml.value,
scalaSwing.value
)
)
lazy val universe = project.in(file("Code/Examples/Universe"))
.dependsOn(rescalaJVM, fullmv)
.settings(cfg.base, cfg.noPublish, name := "rescala-universe", libraryDependencies += scalaParallelCollections.value)
.enablePlugins(JavaAppPackaging)
lazy val todolist = project.in(file("Code/Examples/Todolist"))
.enablePlugins(ScalaJSPlugin)
.dependsOn(rescalaJS, locidistributionJS)
.settings(
cfg.base,
cfg.noPublish,
name := "todolist",
libraryDependencies ++= circeAll.value ++ Seq(
loci.circe.value,
scalatags.value,
loci.webrtc.value,
),
scalaSource in Compile := baseDirectory.value,
scalaJSUseMainModuleInitializer := true,
)
lazy val dividiParoli = project.in(file("Code/Examples/dividiParoli"))
.dependsOn(rescalaJVM)
.settings(
name := "dividi and paroli",
cfg.base,
cfg.noPublish,
cfg.mappingFilters,
lib.scalafx,
libraryDependencies ++= circeAll.value ++ akkaHttpAll.value ++ Seq(
loci.communication.value,
loci.circe.value,
loci.wsAkka.value,
jline.value,
"org.scalafx" %% "scalafxml-core-sfx8" % "0.5",
"com.jfoenix" % "jfoenix" % "9.0.10",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.2",
"ch.qos.logback" % "logback-classic" % "1.2.3",
"com.typesafe.akka" %% "akka-slf4j" % V.akkaActors,
"com.typesafe.akka" %% "akka-actor" % V.akkaActors,
"com.typesafe.akka" %% "akka-remote" % V.akkaActors,
"com.typesafe.akka" %% "akka-cluster" % V.akkaActors,
"com.typesafe.akka" %% "akka-cluster-metrics" % V.akkaActors,
"com.typesafe.akka" %% "akka-cluster-tools" % V.akkaActors,
"com.typesafe.akka" %% "akka-multi-node-testkit" % V.akkaActors,
),
lib.macroparadise,
cfg.noWarnings,
fork := true
)
lazy val ersirServer = project.in(file("Code/Examples/Ersir/server"))
.settings(
name := "server",
fork := true,
cfg.base,
libraryDependencies ++= Seq(
jsoup.value,
betterFiles.value,
decline.value,
),
vbundleDef,
(Compile / compile) := ((Compile / compile) dependsOn vbundle).value
)
.enablePlugins(JavaServerAppPackaging)
.dependsOn(ersirSharedJVM)
.dependsOn(rescalaJVM)
lazy val ersirWeb = project.in(file("Code/Examples/Ersir/web"))
.enablePlugins(ScalaJSPlugin)
.settings(
name := "web",
cfg.base,
npmDependencies in Compile ++= Seq("mqtt" -> "2.18.2"),
libraryDependencies ++= Seq(
scalajsDom.value,
normalizecss.value,
),
scalaJSUseMainModuleInitializer := true,
webpackBundlingMode := BundlingMode.LibraryOnly()
//scalacOptions += "-P:scalajs:sjsDefinedByDefault"
)
.dependsOn(ersirSharedJS)
.enablePlugins(SbtSassify)
.enablePlugins(ScalaJSBundlerPlugin)
.dependsOn(rescalaJS)
lazy val ersirShared = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure).in(file("Code/Examples/Ersir/shared"))
.settings(
name := "shared",
cfg.base,
libraryDependencies ++= circeAll.value ++ akkaHttpAll.value ++ Seq(
scalatags.value,
loci.communication.value,
loci.wsAkka.value,
scribe.value,
loci.circe.value,
)
)
.dependsOn(rescala)
.dependsOn(locidistribution)
lazy val ersirSharedJVM = ersirShared.jvm
lazy val ersirSharedJS = ersirShared.js
// ===================================================================================== Research
lazy val fullmv = project.in(file("Code/Extensions/Multiversion"))
.settings(cfg.base, name := "rescala-multiversion", cfg.test, cfg.noPublish)
.dependsOn(rescalaJVM % "compile->compile;test->test")
//lazy val distributedFullmv = project.in(file("Code/Extensions/distributed/multiversion"))
// .settings( cfg.base, name := "rescala-distributed-multiversion",
// cfg.test, cfg.noPublish, circe, libraryDependencies ++= Seq(
// loci.communication.value,
// loci.circe.value,
// loci.upickle.value
// ))
// .dependsOn(fullmv, testsJVM % "test->test")
//
//lazy val distributedExamples = project.in(file("Code/Extensions/distributed/examples"))
// .enablePlugins(JmhPlugin)
// .settings(name := "rescala-distributed-examples", cfg.base, cfg.noPublish)
// .dependsOn(distributedFullmv % "compile->test")
// .enablePlugins(JavaAppPackaging)
//
//lazy val distributedBenchmarks = project.in(file("Code/Extensions/distributed/benchmarks"))
// .enablePlugins(JmhPlugin)
// .settings(name := "rescala-distributed-benchmarks", cfg.base, cfg.noPublish, mainClass in Compile := Some("org.openjdk.jmh.Main"),
// TaskKey[Unit]("compileJmh") := Seq(compile in pl.project13.scala.sbt.SbtJmh.JmhKeys.Jmh).dependOn.value)
// .dependsOn(distributedFullmv % "compile->test")
// .enablePlugins(JavaAppPackaging)
lazy val microbench = project.in(file("Code/Microbenchmarks"))
.enablePlugins(JmhPlugin)
.settings(
name := "microbenchmarks",
cfg.base,
cfg.noPublish,
mainClass in Compile := Some("org.openjdk.jmh.Main"),
libraryDependencies ++= circeAll.value :+ upickle.value,
TaskKey[Unit]("compileJmh") := Seq(compile in pl.project13.scala.sbt.SbtJmh.JmhKeys.Jmh).dependOn.value
)
.enablePlugins(JavaAppPackaging)
.dependsOn(fullmv, rescalaJVM)
// ===================================================================================== Settings
lazy val cfg = new {
val base: Def.SettingsDefinition = List(
organization := "de.tuda.stg",
baseScalac,
// scaladoc
autoAPIMappings := true,
Compile / doc / scalacOptions += "-groups",
commonCrossBuildVersions
) ++ scalaVersion_213
val test = List(
testOptions in Test += Tests.Argument("-oICN"),
parallelExecution in Test := true,
libraryDependencies += scalatest.value
)
val noWarnings = scalacOptions += "--no-warnings"
lazy val bintray = Resolvers.bintrayPublish("stg-tud", "rescala-lang", "REScala")
lazy val noPublish = Seq(
publishArtifact := false,
packagedArtifacts := Map.empty,
publish := {},
publishLocal := {}
)
lazy val baseScalac = scalacOptions ++= List(
"-deprecation",
"-encoding",
"UTF-8",
"-unchecked",
"-feature",
"-Xlint",
//"-Xfuture",
"-Xdisable-assertions"
)
val mappingFilters = Seq(
mappings in (Compile, packageBin) ~= { _.filter(!_._1.getName.endsWith(".conf")) },
mappings in (Compile, packageBin) ~= { _.filter(!_._1.getName.endsWith(".xml")) }
)
}
// ================================ dependencies
lazy val lib = new {
// Determine OS version of JavaFX binaries
lazy val osName = System.getProperty("os.name") match {
case n if n.startsWith("Linux") => "linux"
case n if n.startsWith("Mac") => "mac"
case n if n.startsWith("Windows") => "win"
case _ => throw new Exception("Unknown platform!")
}
// Add JavaFX dependencies, should probably match whatever the scalafx version was tested against:
// https://www.scalafx.org/news/releases/
// then again, the announcement for 12.0.2 seems incorrect …
val scalafx = Seq(
libraryDependencies ++= Seq(
"org.scalafx" %% "scalafx" % "15.0.1-R20",
scalaSwing.value,
),
libraryDependencies ++= Seq("base", "controls", "fxml", "graphics", "media", "swing", "web").map(m =>
"org.openjfx" % s"javafx-$m" % "15.0.1" classifier osName
)
// unmanagedJars in Compile += Attributed.blank(file(System.getenv("JAVA_HOME") + "/lib/ext/jfxrt.jar"))
)
def `is 2.12+`(scalaVersion: String): Boolean =
CrossVersion.partialVersion(scalaVersion) collect { case (2, n) => n >= 12 } getOrElse false
def `is 2.13+`(scalaVersion: String): Boolean =
CrossVersion.partialVersion(scalaVersion) collect { case (2, n) => n >= 13 } getOrElse false
val macroparadise = Seq(
scalacOptions ++= {
if (`is 2.13+`(scalaVersion.value))
Seq("-Ymacro-annotations")
else
Seq.empty
},
libraryDependencies ++= {
if (`is 2.13+`(scalaVersion.value))
Seq.empty
else
Seq(compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch))
}
)
}
val vbundle = TaskKey[File]("vbundle", "bundles all the viscel resources")
val vbundleDef = vbundle := {
val jsfiles = (ersirWeb / Compile / fastOptJS / webpack).value
val styles = (ersirWeb / Assets / SassKeys.sassify).value
val bundleTarget = (Universal / target).value.toPath.resolve("stage/resources")
Files.createDirectories(bundleTarget)
Files.createDirectories(bundleTarget.resolve("static"))
def gzipToTarget(f: File): Unit = IO.gzip(f, bundleTarget.resolve(f.name + ".gz").toFile)
jsfiles.foreach { af =>
val jsfile = af.data
gzipToTarget(jsfile)
val map = jsfile.toPath.getParent.resolve(jsfile.name + ".map").toFile
if (map.exists()) gzipToTarget(jsfile.toPath.getParent.resolve(jsfile.name + ".map").toFile)
}
val staticResources = (Compile / resources).value
val resdir = (Compile / resourceDirectory).value
staticResources.filter(_.isFile).foreach { f =>
IO.copyFile(f, bundleTarget.resolve(resdir.relativize(f).get.toPath).toFile)
}
styles.foreach(gzipToTarget)
bundleTarget.toFile
}