-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild.sbt
More file actions
569 lines (531 loc) · 20.2 KB
/
Copy pathbuild.sbt
File metadata and controls
569 lines (531 loc) · 20.2 KB
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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
import Settings.Libraries._
import Settings.LibraryVersions
import Settings.Plugins
import Common._
import AppsCommon._
import sbt.Keys._
import NativePackagerHelper._
import sbtcrossproject.CrossType
import com.typesafe.sbt.packager.docker._
name := "seqexec"
Global / onChangedBuildSource := ReloadOnSourceChanges
Global / semanticdbEnabled := true
ThisBuild / Compile / packageDoc / publishArtifact := false
// Gemini repository
ThisBuild / resolvers += "Gemini Repository".at(
"https://github.com/gemini-hlsw/maven-repo/raw/master/releases"
)
ThisBuild / scalaVersion := "2.13.10"
ThisBuild / crossScalaVersions := Seq("2.13.10")
Global / resolvers ++= Resolver.sonatypeOssRepos("public")
// This key is used to find the JRE dir. It could/should be overridden on a user basis
// Add e.g. a `jres.sbt` file with your particular configuration
ThisBuild / ocsJreDir := Path.userHome / ".jres17"
ThisBuild / evictionErrorLevel := Level.Info
Global / cancelable := true
// Should make CI builds more robust
Global / concurrentRestrictions += Tags.limit(ScalaJSTags.Link, 2)
// Uncomment for local gmp testing
// ThisBuild / resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"
// Settings to use git to define the version of the project
def versionFmt(out: sbtdynver.GitDescribeOutput): String = {
val dirtySuffix = if (out.dirtySuffix.mkString("", "").nonEmpty) {
"-UNCOMMITED"
} else {
""
}
s"-${out.commitSuffix.sha}$dirtySuffix"
}
def fallbackVersion(d: java.util.Date): String = s"HEAD-${sbtdynver.DynVer.timestamp(d)}"
val dateFormatter = java.time.format.DateTimeFormatter.BASIC_ISO_DATE
inThisBuild(
List(
version := dateFormatter.format(
dynverCurrentDate.value.toInstant.atZone(java.time.ZoneId.of("UTC")).toLocalDate
) + dynverGitDescribeOutput.value.mkVersion(versionFmt,
fallbackVersion(dynverCurrentDate.value)
)
)
)
enablePlugins(GitBranchPrompt)
// Custom commands to facilitate web development
val startSeqexecAllCommands = List(
"seqexec_web_server/reStart",
"seqexec_web_client/fastOptJS::startWebpackDevServer",
"~seqexec_web_client/fastOptJS"
)
val restartSeqexecWDSCommands = List(
"seqexec_web_client/fastOptJS::stopWebpackDevServer",
"seqexec_web_client/fastOptJS::startWebpackDevServer",
"~seqexec_web_client/fastOptJS"
)
val stopSeqexecAllCommands = List(
"seqexec_web_server/reStop",
"seqexec_web_client/fastOptJS::stopWebpackDevServer"
)
addCommandAlias("startSeqexecAll", startSeqexecAllCommands.mkString(";", ";", ""))
addCommandAlias("restartSeqexecWDS", restartSeqexecWDSCommands.mkString(";", ";", ""))
addCommandAlias("stopSeqexecAll", stopSeqexecAllCommands.mkString(";", ";", ""))
ThisBuild / resolvers ++= Resolver.sonatypeOssRepos("snapshots")
ThisBuild / updateOptions := updateOptions.value.withLatestSnapshots(false)
publish / skip := true
//////////////
// Projects
//////////////
lazy val ocs2_api = crossProject(JVMPlatform, JSPlatform)
.crossType(CrossType.Pure)
.in(file("modules/ocs2_api"))
.settings(commonSettings)
.settings(
name := "ocs2-api",
libraryDependencies ++= Seq(CatsTime.value) ++
LucumaCore.value
)
.dependsOn(seqexec_model)
// Project for the server side application
lazy val seqexec_web_server = project
.in(file("modules/web/server"))
.enablePlugins(BuildInfoPlugin)
.enablePlugins(GitBranchPrompt)
.settings(commonSettings: _*)
.settings(
addCompilerPlugin(Plugins.kindProjectorPlugin),
libraryDependencies ++= Seq(UnboundId,
JwtCore,
JwtCirce,
Http4sServer,
CommonsHttp,
ScalaMock,
Log4CatsNoop.value
) ++
Http4sClient ++ Http4s ++ PureConfig ++ Logging.value,
// Supports launching the server in the background
reStart / mainClass := Some("seqexec.web.server.http4s.WebServerLauncher"),
Compile / bspEnabled := false
)
.settings(
buildInfoUsePackageAsPath := true,
buildInfoKeys ++= Seq[BuildInfoKey](name, version, buildInfoBuildNumber),
buildInfoOptions += BuildInfoOption.BuildTime,
buildInfoObject := "OcsBuildInfo",
buildInfoPackage := "seqexec.web.server"
)
.dependsOn(seqexec_server)
.dependsOn(seqexec_model.jvm % "compile->compile;test->test")
lazy val seqexec_web_client = project
.in(file("modules/web/client"))
.enablePlugins(ScalaJSPlugin)
.enablePlugins(ScalaJSBundlerPlugin)
.enablePlugins(BuildInfoPlugin)
.enablePlugins(GitBranchPrompt)
.disablePlugins(RevolverPlugin)
// .settings(lucumaScalaJsSettings: _*)
.settings(
// Needed for Monocle macros
scalacOptions += "-Ymacro-annotations",
scalacOptions += "-P:scalajs:nowarnGlobalExecutionContext",
scalacOptions ~= (_.filterNot(
Set(
// By necessity facades will have unused params
"-Wunused:params",
"-Wunused:explicits"
)
)),
// Configurations for webpack
fastOptJS / webpackBundlingMode := BundlingMode.LibraryOnly(),
fullOptJS / webpackBundlingMode := BundlingMode.Application,
webpackResources := (baseDirectory.value / "src" / "webpack") * "*.js",
webpackDevServerPort := 9090,
webpack / version := "4.46.0",
npmExtraArgs := Seq("--legacy-peer-deps"),
startWebpackDevServer / version := "3.11.0",
// Use a different Webpack configuration file for production and create a single bundle without source maps
fullOptJS / webpackConfigFile := Some(
baseDirectory.value / "src" / "webpack" / "prod.webpack.config.js"
),
fastOptJS / webpackConfigFile := Some(
baseDirectory.value / "src" / "webpack" / "dev.webpack.config.js"
),
Test / webpackConfigFile := Some(
baseDirectory.value / "src" / "webpack" / "test.webpack.config.js"
),
webpackEmitSourceMaps := false,
Test / parallelExecution := false,
installJsdom / version := "16.4.0",
Test / requireJsDomEnv := true,
// JS dependencies via npm
Compile / npmDependencies ++= Seq(
"fomantic-ui-less" -> LibraryVersions.fomanticUI,
"prop-types" -> "15.7.2",
"react-virtualized" -> "9.21.1",
"core-js" -> "2.6.11" // Without this, core-js 3 is used, which conflicts with @babel/runtime-corejs2
),
Compile / fastOptJS / scalaJSLinkerConfig ~= { _.withSourceMap(false) },
Compile / fullOptJS / scalaJSLinkerConfig ~= { _.withSourceMap(false) },
// NPM libs for development, mostly to let webpack do its magic
Compile / npmDevDependencies ++= Seq(
"postcss" -> "8.1.1",
"postcss-loader" -> "4.0.3",
"autoprefixer" -> "10.0.1",
"url-loader" -> "4.1.0",
"file-loader" -> "6.0.0",
"css-loader" -> "3.5.3",
"style-loader" -> "1.2.1",
"less" -> "3.9.0",
"less-loader" -> "7.0.1",
"webpack-merge" -> "4.2.2",
"mini-css-extract-plugin" -> "0.8.0",
"webpack-dev-server-status-bar" -> "1.1.0",
"cssnano" -> "4.1.10",
"terser-webpack-plugin" -> "3.0.6",
"html-webpack-plugin" -> "4.3.0",
"css-minimizer-webpack-plugin" -> "1.1.5",
"favicons-webpack-plugin" -> "4.2.0"
),
libraryDependencies ++= Seq(
Cats.value,
Mouse.value,
CatsEffect.value,
ScalaJSDom.value,
JavaTimeJS.value,
ScalaJSReactSemanticUI.value,
ScalaJSReactVirtualized.value,
ScalaJSReactClipboard.value,
ScalaJSReactSortable.value,
ScalaJSReactDraggable.value,
GeminiLocales.value,
LucumaUI.value,
PPrint.value,
TestLibs.value
) ++ MUnit.value ++ ReactScalaJS.value ++ Diode.value ++ Log4CatsLogLevel.value ++ Circe.value
)
.settings(
buildInfoUsePackageAsPath := true,
buildInfoKeys ++= Seq[BuildInfoKey](name, version),
buildInfoObject := "OcsBuildInfo",
buildInfoPackage := "seqexec.web.client"
)
.dependsOn(seqexec_model.js % "compile->compile;test->test")
// List all the modules and their inter dependencies
lazy val seqexec_server = project
.in(file("modules/server"))
.enablePlugins(GitBranchPrompt)
.enablePlugins(BuildInfoPlugin)
.settings(commonSettings: _*)
.settings(
scalacOptions += "-Ymacro-annotations",
addCompilerPlugin(Plugins.kindProjectorPlugin),
addCompilerPlugin(Plugins.betterMonadicForPlugin),
libraryDependencies ++=
Seq(
Http4sCirce,
Squants.value,
// OCS bundles
SpModelCore,
POT,
OpenCSV,
Http4sXml,
Http4sBoopickle,
Log4Cats.value,
Log4CatsNoop.value,
TestLibs.value,
PPrint.value,
ACM,
GiapiScala
) ++ MUnit.value ++ Http4s ++ Http4sClient ++ PureConfig ++ SeqexecOdb ++ Monocle.value ++ WDBAClient ++
Circe.value
)
.settings(
buildInfoUsePackageAsPath := true,
buildInfoKeys ++= Seq[BuildInfoKey](name, version),
buildInfoObject := "OcsBuildInfo",
buildInfoPackage := "seqexec.server"
)
.dependsOn(seqexec_engine % "compile->compile;test->test",
ocs2_api.jvm,
seqexec_model.jvm % "compile->compile;test->test"
)
lazy val authtester = project
.in(file("modules/authtester"))
.dependsOn(seqexec_web_server)
.settings(libraryDependencies += Scopt.value)
.enablePlugins(JavaAppPackaging)
// Unfortunately crossProject doesn't seem to work properly at the module/build.sbt level
// We have to define the project properties at this level
lazy val seqexec_model = crossProject(JVMPlatform, JSPlatform)
.crossType(CrossType.Full)
.in(file("modules/model"))
.enablePlugins(GitBranchPrompt)
.settings(
scalacOptions += "-Ymacro-annotations",
libraryDependencies ++= Seq(
Squants.value,
Mouse.value,
BooPickle.value,
TestLibs.value,
CatsTime.value
) ++ MUnit.value ++ Monocle.value ++ LucumaCore.value
)
.jvmSettings(
commonSettings,
libraryDependencies += Http4sCore
)
// .jsSettings(lucumaScalaJsSettings)
.jsSettings(
// And add a custom one
libraryDependencies += JavaTimeJS.value,
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule))
)
lazy val seqexec_engine = project
.in(file("modules/engine"))
.enablePlugins(GitBranchPrompt)
.dependsOn(seqexec_model.jvm % "compile->compile;test->test")
.settings(commonSettings: _*)
.settings(
addCompilerPlugin(Plugins.kindProjectorPlugin),
scalacOptions += "-Ymacro-annotations",
libraryDependencies ++= Seq(Fs2,
CatsEffect.value,
Log4s.value,
Log4Cats.value
) ++ Monocle.value ++ MUnit.value
)
/**
* Common settings for the Seqexec instances
*/
lazy val seqexecCommonSettings = Seq(
// Main class for launching
Compile / mainClass := Some("seqexec.web.server.http4s.WebServerLauncher"),
// This is important to keep the file generation order correctly
Universal / parallelExecution := false,
// Depend on webpack and add the assets created by webpack
Compile / packageBin / mappings ++= (seqexec_web_client / Compile / fullOptJS / webpack).value
.map(f => f.data -> f.data.getName()),
// Name of the launch script
executableScriptName := "seqexec-server",
// No javadocs
Compile / packageDoc / mappings := Seq(),
// Don't create launchers for Windows
makeBatScripts := Seq.empty,
// Specify a different name for the config file
bashScriptConfigLocation := Some("${app_home}/../conf/launcher.args"),
bashScriptExtraDefines += """addJava "-Dlogback.configurationFile=${app_home}/../conf/logback.xml"""",
// Copy logback.xml to let users customize it on site
Universal / mappings += {
val f = (seqexec_web_server / Compile / resourceDirectory).value / "logback.xml"
f -> ("conf/" + f.getName)
},
// Launch options
Universal / javaOptions ++= Seq(
// -J params will be added as jvm parameters
"-J-Xmx1024m",
"-J-Xms256m",
// Support remote JMX access
"-J-Dcom.sun.management.jmxremote",
"-J-Dcom.sun.management.jmxremote.authenticate=false",
"-J-Dcom.sun.management.jmxremote.port=2407",
"-J-Dcom.sun.management.jmxremote.ssl=false",
// Ensure the local is correctly set
"-J-Duser.language=en",
"-J-Duser.country=US",
// Support remote debugging
"-J-Xdebug",
"-J-Xnoagent",
"-J-XX:+HeapDumpOnOutOfMemoryError",
// Make sure the application exits on OOM
"-J-XX:+ExitOnOutOfMemoryError",
"-J-XX:+CrashOnOutOfMemoryError",
"-J-XX:HeapDumpPath=/tmp",
"-J-Xrunjdwp:transport=dt_socket,address=8457,server=y,suspend=n",
"-java-home ${app_home}/../jre" // This breaks builds without jre
)
) ++ commonSettings
/**
* Settings for Seqexec in Linux
*/
lazy val seqexecLinux = Seq(
// User/Group for execution
Linux / daemonUser := "software",
Linux / daemonGroup := "software",
Universal / maintainer := "Software Group <software@gemini.edu>",
// This lets us build RPMs from snapshot versions
Linux / name := "Seqexec Server",
Linux / version :=
(ThisBuild / version).value.replace("-SNAPSHOT", "").replace("-", "_").replace(" ", "")
)
/**
* Project for the seqexec server app for development
*/
lazy val app_seqexec_server = preventPublication(project.in(file("app/seqexec-server")))
.dependsOn(seqexec_web_server, seqexec_web_client)
.aggregate(seqexec_web_server, seqexec_web_client)
.enablePlugins(JavaServerAppPackaging)
.enablePlugins(GitBranchPrompt)
.settings(seqexecCommonSettings: _*)
.settings(
description := "Seqexec server for local testing",
// Put the jar files in the lib dir
Universal / mappings += {
val jar = (Compile / packageBin).value
jar -> ("lib/" + jar.getName)
},
Universal / mappings := {
// filter out sjs jar files. otherwise it could generate some conflicts
val universalMappings = (Universal / mappings).value
val filtered = universalMappings.filter { case (_, name) =>
!name.contains("_sjs")
}
filtered
},
Universal / mappings += {
val f = (Compile / resourceDirectory).value / "update_smartgcal"
f -> ("bin/" + f.getName)
},
Universal / mappings += {
val f = (Compile / resourceDirectory).value / "seqexec-server.env"
f -> ("systemd/" + f.getName)
},
Universal / mappings += {
val f = (Compile / resourceDirectory).value / "seqexec-server.service"
f -> ("systemd/" + f.getName)
}
)
/**
* Project for the seqexec test server at GS on Linux 64
*/
lazy val app_seqexec_server_gs_test =
preventPublication(project.in(file("app/seqexec-server-gs-test")))
.dependsOn(seqexec_web_server, seqexec_web_client)
.aggregate(seqexec_web_server, seqexec_web_client)
.enablePlugins(LinuxPlugin)
.enablePlugins(JavaServerAppPackaging)
.enablePlugins(SystemdPlugin)
.enablePlugins(GitBranchPrompt)
.settings(seqexecCommonSettings: _*)
.settings(seqexecLinux: _*)
.settings(deployedAppMappings: _*)
.settings(
description := "Seqexec GS test deployment",
applicationConfName := "seqexec",
applicationConfSite := DeploymentSite.GS,
Universal / mappings := {
// filter out sjs jar files. otherwise it could generate some conflicts
val universalMappings = (app_seqexec_server / Universal / mappings).value
val filtered = universalMappings.filter { case (_, name) =>
!name.contains("_sjs")
}
filtered
}
)
.settings(embeddedJreSettingsLinux64: _*)
.dependsOn(seqexec_server)
/**
* Project for the seqexec test server at GN on Linux 64
*/
lazy val app_seqexec_server_gn_test =
preventPublication(project.in(file("app/seqexec-server-gn-test")))
.dependsOn(seqexec_web_server, seqexec_web_client)
.aggregate(seqexec_web_server, seqexec_web_client)
.enablePlugins(LinuxPlugin, RpmPlugin)
.enablePlugins(JavaServerAppPackaging)
.enablePlugins(GitBranchPrompt)
.settings(seqexecCommonSettings: _*)
.settings(seqexecLinux: _*)
.settings(deployedAppMappings: _*)
.settings(
description := "Seqexec GN test deployment",
applicationConfName := "seqexec",
applicationConfSite := DeploymentSite.GN,
Universal / mappings := {
// filter out sjs jar files. otherwise it could generate some conflicts
val universalMappings = (app_seqexec_server / Universal / mappings).value
val filtered = universalMappings.filter { case (_, name) =>
!name.contains("_sjs")
}
filtered
}
)
.settings(embeddedJreSettingsLinux64: _*)
.dependsOn(seqexec_server)
/**
* Project for the seqexec server app for production on Linux 64
*/
lazy val app_seqexec_server_gs = preventPublication(project.in(file("app/seqexec-server-gs")))
.dependsOn(seqexec_web_server, seqexec_web_client)
.aggregate(seqexec_web_server, seqexec_web_client)
.enablePlugins(LinuxPlugin, RpmPlugin)
.enablePlugins(JavaServerAppPackaging)
.enablePlugins(GitBranchPrompt)
.settings(seqexecCommonSettings: _*)
.settings(seqexecLinux: _*)
.settings(deployedAppMappings: _*)
.settings(
description := "Seqexec Gemini South server production",
applicationConfName := "seqexec",
applicationConfSite := DeploymentSite.GS,
Universal / mappings := {
// filter out sjs jar files. otherwise it could generate some conflicts
val universalMappings = (app_seqexec_server / Universal / mappings).value
val filtered = universalMappings.filter { case (_, name) =>
!name.contains("_sjs")
}
filtered
}
)
.settings(embeddedJreSettingsLinux64: _*)
.dependsOn(seqexec_server)
/**
* Project for the GN seqexec server app for production on Linux 64
*/
lazy val app_seqexec_server_gn = preventPublication(project.in(file("app/seqexec-server-gn")))
.dependsOn(seqexec_web_server, seqexec_web_client)
.aggregate(seqexec_web_server, seqexec_web_client)
.enablePlugins(LinuxPlugin, RpmPlugin)
.enablePlugins(JavaServerAppPackaging)
.enablePlugins(GitBranchPrompt)
.settings(seqexecCommonSettings: _*)
.settings(seqexecLinux: _*)
.settings(deployedAppMappings: _*)
.settings(
description := "Seqexec Gemini North server production",
applicationConfName := "seqexec",
applicationConfSite := DeploymentSite.GN,
Universal / mappings := {
// filter out sjs jar files. otherwise it could generate some conflicts
val universalMappings = (app_seqexec_server / Universal / mappings).value
val filtered = universalMappings.filter { case (_, name) =>
!name.contains("_sjs")
}
filtered
}
)
.settings(embeddedJreSettingsLinux64: _*)
.dependsOn(seqexec_server)
/**
* Project for the Igrins2 specific seqexec server app on Linux 64
*/
lazy val app_seqexec_server_igrins2 =
preventPublication(project.in(file("app/seqexec-server-igrins2")))
.dependsOn(seqexec_web_server, seqexec_web_client)
.aggregate(seqexec_web_server, seqexec_web_client)
.enablePlugins(LinuxPlugin, RpmPlugin)
.enablePlugins(JavaServerAppPackaging)
.enablePlugins(GitBranchPrompt)
.settings(seqexecCommonSettings: _*)
.settings(seqexecLinux: _*)
.settings(deployedAppMappings: _*)
.settings(
description := "Seqexec Igrins2 North server production",
applicationConfName := "seqexec",
applicationConfSite := DeploymentSite.GN,
Universal / mappings := {
// filter out sjs jar files. otherwise it could generate some conflicts
val universalMappings = (app_seqexec_server / Universal / mappings).value
val filtered = universalMappings.filter { case (_, name) =>
!name.contains("_sjs")
}
filtered
}
)
.settings(embeddedJreSettingsLinux64: _*)
.dependsOn(seqexec_server)