-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sbt
84 lines (72 loc) · 2.7 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
enablePlugins(JavaAppPackaging)
enablePlugins(DockerPlugin)
organization := "me.amanj"
name := "greenish"
scalaVersion := "2.13.2"
parallelExecution in ThisBuild := false
scalacOptions ++= Seq(
"-encoding", "utf8",
"-Xfatal-warnings",
"-deprecation",
"-unchecked",
"-feature",
)
val circeVersion = "0.13.0"
val akkaVersion = "2.6.6"
val akkaHttpVersion = "10.1.12"
val typesafeConfigVersion = "1.4.0"
val scalaTestVersion = "3.2.0"
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
"io.circe" %% "circe-parser" % circeVersion,
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion,
"io.circe" %% "circe-generic-extras" % circeVersion,
"com.typesafe" % "config" % typesafeConfigVersion,
"io.prometheus" % "simpleclient" % "0.9.0",
"io.prometheus" % "simpleclient_common" % "0.9.0",
"com.cronutils" % "cron-utils" % "9.1.0",
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % Test,
"org.scalatest" %% "scalatest" % scalaTestVersion % Test,
"com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion % Test,
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % Test,
)
dockerBaseImage := "openjdk:jre"
bashScriptExtraDefines += """addJava "-Dconfig.file=/app/config.yml""""
// JS/JSX compiling
lazy val jsxCompile = taskKey[Seq[File]]("Compile JSX files")
jsxCompile in ThisBuild := Def.task {
val src = (resourceDirectory in Compile).value / "dashboard"
val destDir = (resourceManaged in Compile).value / "dashboard"
val srcFiles = src.listFiles.filter(_.getName.endsWith(".jsx")).toSet
val stream = (jsxCompile / streams).value
val JsxFilter: NameFilter = "*.jsx"
val JsFilter: NameFilter = "*.js"
destDir.mkdirs
var errors = 0
val cachedCompile =
FileFunction.cached(stream.cacheDirectory / "jsx",
FilesInfo.lastModified, FilesInfo.exists) { files =>
stream.log.info("JSX compiler")
import scala.sys.process._
val compiled = srcFiles.map { file =>
val dest = destDir / file.getName.dropRight(1)
val compile =
s"npx babel --minified --compact --out-file $dest --presets react-app/prod $file"
val succeeded = Seq("bash", "-c", compile).!
if(succeeded != 0) {
errors += 1
}
dest
}
(compiled ** JsFilter).get.toSet
}
val files = cachedCompile((srcFiles ** JsxFilter).get.toSet).toSeq
if(errors > 0) {
throw new Error(s"JSX Compilation failed\nThere were $errors issues")
}
files
}.value
resourceGenerators in Compile += jsxCompile.taskValue
compile in Compile := (compile in Compile).dependsOn(jsxCompile).value