-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
178 lines (140 loc) · 6.81 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
import java.io.{FileInputStream, FileOutputStream}
import java.util.zip.GZIPOutputStream
import scala.io.Source
enablePlugins(GitVersioning)
name := "Boinc-Webmanager"
ThisBuild / scalaVersion := "2.13.6"
ThisBuild / scalacOptions ++= Seq(
"-unchecked",
"-deprecation",
"-feature",
)
git.gitTagToVersionNumber := { tag: String =>
if(tag matches "[0-9]+\\..*") Some(tag)
else None
}
val http4sVersion = "1.0.0-M29"
val uPickleVersion = "1.4.1"
lazy val root = project.in(file(".")).
aggregate(clientJS, serverJVM).
settings(
publish := {},
publishLocal := {}
)
lazy val shared = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.settings(
libraryDependencies ++= Seq(
"com.lihaoyi" %% "upickle" % uPickleVersion,
)
)
lazy val sharedJVM = shared.jvm
lazy val sharedJS = shared.js
lazy val gzip = taskKey[Unit]("GZip managed resources")
lazy val serverJVM = (project in file ("jvm"))
.enablePlugins(BuildInfoPlugin)
.enablePlugins(JavaServerAppPackaging)
.disablePlugins(ScalaJSPlugin)
.dependsOn(sharedJVM, cssRenderer)
.settings(
name := "Boinc-Webmanager_server",
Compile / mainClass := Some("at.happywetter.boinc.WebServer"),
buildInfoKeys := Seq[BuildInfoKey](version, scalaVersion, sbtVersion, git.gitCurrentBranch),
buildInfoPackage := "at.happywetter.boinc",
buildInfoOptions += BuildInfoOption.BuildTime,
(Compile / packageBin) := ((Compile / packageBin) dependsOn gzip).value,
Compile / packageBin / mappings ++= Seq(
((Compile / resourceManaged).value / "web-root" / "boinc-webmanager_client-jsdeps.min.js") -> "web-root/boinc-webmanager_client-jsdeps.min.js",
((Compile / resourceManaged).value / "web-root" / "boinc-webmanager_client-opt.js") -> "web-root/boinc-webmanager_client-opt.js",
((Compile / resourceManaged).value / "web-root" / "boinc-webmanager_client-jsdeps.min.js.gz") -> "web-root/boinc-webmanager_client-jsdeps.min.js.gz",
((Compile / resourceManaged).value / "web-root" / "boinc-webmanager_client-opt.js.gz") -> "web-root/boinc-webmanager_client-opt.js.gz",
((Compile / resourceManaged).value / "web-root" / "boinc-webmanager_client-opt.js.map") -> "web-root/boinc-webmanager_client-opt.js.map",
((Compile / resourceManaged).value / "web-root" / "boinc-webmanager_client-opt.js.map.gz") -> "web-root/boinc-webmanager_client-opt.js.map.gz",
),
libraryDependencies ++= Seq(
"ch.qos.logback" % "logback-classic" % "1.2.3",
"ch.qos.logback" % "logback-core" % "1.2.3",
"org.typelevel" %% "log4cats-slf4j" % "2.1.1",
"org.http4s" %% "http4s-dsl" % http4sVersion,
"org.http4s" %% "http4s-blaze-server" % http4sVersion,
"com.github.pureconfig" %% "pureconfig" % "0.16.0",
"org.scala-lang.modules" %% "scala-xml" % "2.0.1",
"com.lihaoyi" %% "scalatags" % "0.9.4",
"org.scalaj" %% "scalaj-http" % "2.4.2",
"org.webjars" % "swagger-ui" % "3.51.2",
"org.jsoup" % "jsoup" % "1.14.2",
"com.auth0" % "java-jwt" % "3.18.1",
"com.h2database" % "h2" % "1.4.200",
"io.getquill" %% "quill-jdbc" % "3.10.0",
"com.lihaoyi" %% "upack" % uPickleVersion,
"com.lihaoyi" %% "upickle" % uPickleVersion,
// Resources for the client:
"org.webjars" % "font-awesome" % "5.15.1",
"org.webjars.bower" % "nprogress" % "0.2.0",
"org.webjars.npm" % "flag-icon-css" % "3.5.0",
"org.webjars.npm" % "purecss" % "2.0.3"
),
gzip := {
val logger = sLog.value
Seq(
"boinc-webmanager_client-jsdeps.min.js",
"boinc-webmanager_client-opt.js",
"boinc-webmanager_client-opt.js.map"
).foreach { file =>
logger.info(s"gzipping managed resource: ${(Compile / resourceManaged).value / "web-root" / file}")
val in = new FileInputStream((Compile / resourceManaged).value / "web-root" / file)
val out = new FileOutputStream((Compile / resourceManaged).value / "web-root" / (file + ".gz"))
val gzipOut = new GZIPOutputStream(out, 4096)
val buffer = new Array[Byte](4096)
Iterator
.continually(in.read(buffer))
.takeWhile(_ != -1)
.foreach(read => gzipOut.write(buffer,0,read))
gzipOut.finish()
gzipOut.close()
out.close()
in.close()
}
}
)
lazy val clientJS = (project in file ("js"))
.enablePlugins(ScalaJSPlugin)
.enablePlugins(BuildInfoPlugin)
.enablePlugins(JSDependenciesPlugin)
.dependsOn(sharedJS, clientCssJS)
.settings(
name := "Boinc-Webmanager_client",
Compile / mainClass := Some("at.happywetter.boinc.web.Main"),
buildInfoKeys := Seq[BuildInfoKey](version, scalaVersion, sbtVersion, git.gitCurrentBranch),
buildInfoPackage := "at.happywetter.boinc",
buildInfoOptions += BuildInfoOption.BuildTime,
// Publish fullOpt + dependencies directly to managed resource directory of the server
Compile / fullOptJS / crossTarget := (serverJVM / Compile / resourceManaged).value / "web-root",
Compile / packageMinifiedJSDependencies / crossTarget := (serverJVM / Compile / resourceManaged).value / "web-root",
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "1.2.0",
"io.github.cquiroz" %%% "scala-java-time" % "2.2.2",
"com.lihaoyi" %%% "upack" % uPickleVersion,
"com.lihaoyi" %%% "upickle" % uPickleVersion,
"in.nvilla" %%% "monadic-html" % "0.4.1",
),
resolvers += "WebJars-BinTray" at "https://dl.bintray.com/webjars/maven",
jsDependencies ++= Seq(
"org.webjars.bower" % "navigo" % "7.0.0" / "navigo.js" commonJSName "Navigo" minified "navigo.min.js",
"org.webjars.bower" % "nprogress" % "0.2.0" / "nprogress.js" commonJSName "NProgress",
"org.webjars.bower" % "chart.js" % "2.8.0" / "Chart.js" commonJSName "ChartJS" minified "Chart.min.js",
// Polyfill Dependencies needed for IE / Edge to be able to run it
"org.webjars.npm" % "text-encoding" % "0.6.4" / "encoding.js",
ProvidedJS / "polyfill-nodelist.js"
)
)
lazy val clientCSS = (crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure) in file("css"))
lazy val clientCssJVM = clientCSS.jvm
lazy val clientCssJS = clientCSS.js
lazy val cssRenderer = (project in file("css-renderer"))
.dependsOn(clientCssJVM)
.settings(
libraryDependencies ++= Seq(
"com.github.japgolly.scalacss" %% "core" % "0.7.0",
),
)