-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
148 lines (125 loc) · 3.77 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
import sbtassembly.AssemblyPlugin.autoImport.assembly
val V = new {
val Scala = "3.3.1"
val jakon = "0.5.9"
}
val projectName = "jakonExample"
val projectVersion = "1.0.0"
scalaVersion := V.Scala
organization := "cz.kamenitxan"
name := projectName
version := projectVersion
ThisBuild / resolvers += Resolver.mavenLocal
ThisBuild / resolvers += "Artifactory" at "https://nexus.kamenitxan.eu/repository/jakon/"
val Dependencies = new {
lazy val frontend = Seq(
)
lazy val backend = Seq(
libraryDependencies ++=
Seq(
"cz.kamenitxan" %% "jakon" % V.jakon changing() excludeAll (
ExclusionRule(organization = "com.sun.mail", name = "smtp"),
ExclusionRule(organization = "javax.mail", name = "javax.mail-api")
),
"org.scalatest" %% "scalatest" % "3.2.17" % "test",
"org.seleniumhq.selenium" % "htmlunit3-driver" % "4.13.0" % "test"
)
)
lazy val tests = Def.settings(
)
}
lazy val root = (project in file(".")).aggregate(frontend, backend)
lazy val frontend = (project in file("modules/frontend"))
.enablePlugins(ScalaJSPlugin)
.settings(scalaJSUseMainModuleInitializer := false)
.settings(
Dependencies.frontend,
Dependencies.tests,
//Test / jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv()
)
.settings(
commonBuildSettings,
name := projectName + "-fe"
)
lazy val backend = (project in file("modules/backend"))
.settings(Dependencies.backend)
.settings(Dependencies.tests)
.settings(commonBuildSettings)
.enablePlugins(JavaAppPackaging)
.enablePlugins(DockerPlugin)
.settings(
name := projectName,
Compile / mainClass := Some("example.Main"),
Test / fork := true,
Universal / mappings += {
val appJs = (frontend / Compile / fullOptJS).value.data
appJs -> "lib/prod.js"
},
Universal / javaOptions ++= Seq(
"--port 8080",
"--mode prod"
),
Docker / packageName := "tauroadmin-example"
)
lazy val commonBuildSettings: Seq[Def.Setting[?]] = Seq(
scalaVersion := V.Scala,
organization := "cz.kamenitxan",
name := projectName,
version := V.jakon,
startYear := Some(2015)
)
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0"
ThisBuild / semanticdbEnabled := false
ThisBuild / scalacOptions += "-deprecation"
ThisBuild / assembly / assemblyMergeStrategy := {
case PathList("module-info.class") => MergeStrategy.discard
case x if x.endsWith("module-info.class") => MergeStrategy.discard
case x if x.endsWith("BuildInfo$.class") => MergeStrategy.discard
case x if x.endsWith("log4j2.xml") => MergeStrategy.first
case x =>
val oldStrategy = (ThisBuild / assemblyMergeStrategy).value
oldStrategy(x)
}
Test / fork := true
Test / testForkedParallel := false
Test / parallelExecution:= false
Test / logBuffered := false
lazy val fastOptCompileCopy = taskKey[Unit]("")
val jsPath = "modules/backend/src/main/resources"
fastOptCompileCopy := {
val source = (frontend / Compile / fastOptJS).value.data
IO.copyFile(
source,
baseDirectory.value / jsPath / "dev.js"
)
}
lazy val fullOptCompileCopy = taskKey[Unit]("")
fullOptCompileCopy := {
val source = (frontend / Compile / fullOptJS).value.data
IO.copyFile(
source,
baseDirectory.value / jsPath / "prod.js"
)
}
addCommandAlias("runDev", ";fastOptCompileCopy; backend/reStart --mode dev")
addCommandAlias("runProd", ";fullOptCompileCopy; backend/reStart --mode prod")
val scalafixRules = Seq(
"OrganizeImports",
"DisableSyntax",
"LeakingImplicitClassVal",
"NoValInForComprehension"
).mkString(" ")
val CICommands = Seq(
"clean",
"backend/compile",
"backend/test",
"frontend/compile",
"frontend/fastOptJS",
"frontend/test",
s"scalafix --check $scalafixRules"
).mkString(";")
val PrepareCICommands = Seq(
s"scalafix $scalafixRules"
).mkString(";")
addCommandAlias("ci", CICommands)
addCommandAlias("preCI", PrepareCICommands)