/
build.sbt
154 lines (133 loc) · 4.51 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
import sbt.Keys._
import sbtcrossproject.{crossProject, CrossType}
import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
val scalaV = "2.12.6"
//val scalaV = "2.11.8"
val projectName = "thor"
val projectVersion = "2019.3.19"
resolvers += Resolver.sonatypeRepo("snapshots")
val projectMainClass = "org.seekloud.thor.Boot"
val clientMainClass = "org.seekloud.thor.ClientBoot"
def commonSettings = Seq(
version := projectVersion,
scalaVersion := scalaV,
scalacOptions ++= Seq(
//"-deprecation",
"-feature"
)
)
lazy val shared = (crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure) in file("shared"))
.settings(name := "shared")
.settings(commonSettings: _*)
lazy val sharedJvm = shared.jvm
lazy val sharedJs = shared.js
// Scala-Js frontend
lazy val frontend = (project in file("frontend"))
.enablePlugins(ScalaJSPlugin)
.settings(name := "frontend")
.settings(commonSettings: _*)
.settings(
inConfig(Compile)(
Seq(
fullOptJS,
fastOptJS,
packageJSDependencies,
packageMinifiedJSDependencies
).map(f => (crossTarget in f) ~= (_ / "sjsout"))
))
.settings(skip in packageJSDependencies := false)
.settings(
scalaJSUseMainModuleInitializer := false,
// mainClass := Some("org.seekloud.virgour.front.Main"),
libraryDependencies ++= Seq(
"io.circe" %%% "circe-core" % "0.8.0",
"io.circe" %%% "circe-generic" % "0.8.0",
"io.circe" %%% "circe-parser" % "0.8.0",
"org.scala-js" %%% "scalajs-dom" % "0.9.2",
"org.seekloud" %%% "byteobject" % "0.1.1",
"in.nvilla" %%% "monadic-html" % "0.4.0-RC1" withSources(),
"com.github.japgolly.scalacss" %%% "core" % "0.5.5" withSources(),
"io.suzaku" %%% "diode" % "1.1.2",
//"com.lihaoyi" %%% "upickle" % upickleV,
"com.lihaoyi" %%% "scalatags" % "0.6.5",
"org.seekloud" %%% "byteobject" % "0.1.1"
//"org.scala-js" %%% "scalajs-java-time" % scalaJsJavaTime
//"com.lihaoyi" %%% "utest" % "0.3.0" % "test"
)
)
.dependsOn(sharedJs)
// Akka Http based backend
lazy val backend = (project in file("backend")).enablePlugins(PackPlugin)
.settings(commonSettings: _*)
.settings(
mainClass in reStart := Some(projectMainClass),
javaOptions in reStart += "-Xmx2g"
)
.settings(name := "backend")
.settings(
//pack
// If you need to specify main classes manually, use packSettings and packMain
//packSettings,
// [Optional] Creating `hello` command that calls org.mydomain.Hello#main(Array[String])
packMain := Map("thor" -> projectMainClass),
packJvmOpts := Map("thor" -> Seq("-Xmx512m", "-Xms64m")),
packExtraClasspath := Map("thor" -> Seq("."))
)
.settings(
libraryDependencies ++= Dependencies.backendDependencies ++ Dependencies.grpcSeq
)
.settings {
(resourceGenerators in Compile) += Def.task {
val fastJsOut = (fastOptJS in Compile in frontend).value.data
val fastJsSourceMap = fastJsOut.getParentFile / (fastJsOut.getName + ".map")
Seq(
fastJsOut,
fastJsSourceMap
)
}.taskValue
}
// .settings(
// (resourceGenerators in Compile) += Def.task {
// val fullJsOut = (fullOptJS in Compile in frontend).value.data
// val fullJsSourceMap = fullJsOut.getParentFile / (fullJsOut.getName + ".map")
// Seq(
// fullJsOut,
// fullJsSourceMap
// )
// }.taskValue)
.settings((resourceGenerators in Compile) += Def.task {
Seq(
(packageJSDependencies in Compile in frontend).value
//(packageMinifiedJSDependencies in Compile in frontend).value
)
}.taskValue)
.settings(
(resourceDirectories in Compile) += (crossTarget in frontend).value,
watchSources ++= (watchSources in frontend).value
)
.dependsOn(sharedJvm)
lazy val client = project.in(file("client")).enablePlugins(PackPlugin)
.settings(commonSettings: _*)
.settings(name := "client")
.settings(
mainClass in reStart := Some(clientMainClass),
javaOptions in reStart += "-Xmx2g"
)
.settings(
packMain := Map("thor" -> clientMainClass),
packJvmOpts := Map("thor" -> Seq("-Xmx2048m", "-Xms128m")),
packExtraClasspath := Map("thor" -> Seq("."))
)
.settings(
libraryDependencies ++= Dependencies.backendDependencies ++ Dependencies.grpcSeq
)
.settings(
PB.targets in Compile := Seq(
scalapb.gen() -> (sourceManaged in Compile).value
))
.dependsOn(sharedJvm)
lazy val root = (project in file("."))
.aggregate(frontend, backend)
.settings(
name := projectName,
)