-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.sbt
228 lines (185 loc) · 7.15 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
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
name := "aplus"
organization := "fr.gouv.beta"
version := "1.0-SNAPSHOT"
lazy val root = (project in file("."))
.enablePlugins(PlayScala)
.enablePlugins(BuildInfoPlugin)
.settings(
buildInfoKeys := Seq[BuildInfoKey](
"gitHeadCommit" -> git.gitHeadCommit.value,
"gitHeadCommitDate" -> git.gitHeadCommitDate.value
),
buildInfoPackage := "constants",
// Test with Firefox
// Note that sbt does not forward system properties from the cli to the tests
Test / javaOptions += ("-Dwebdriver.gecko.driver=" + scala.sys.env("GECKO_DRIVER"))
)
.dependsOn(macrosProject)
inThisBuild(
List(
scalaVersion := "3.3.4",
// The following setting are for scalafix
semanticdbEnabled := true, // enable SemanticDB
semanticdbVersion := scalafixSemanticdb.revision // use Scalafix compatible version
)
)
// Options ref https://docs.scala-lang.org/scala3/guides/migration/options-intro.html
// Note: the Play sbt plugin adds some options
// https://github.com/playframework/playframework/blob/4c2d76095c2f6a5cab7be3e8f6017c4a4dd2a99f/dev-mode/sbt-plugin/src/main/scala/play/sbt/PlaySettings.scala#L89
scalacOptions ++= Seq(
"-feature",
// "-deprecation", // Added by Play
// "-unchecked", // Added by Play
// Note: To show all possible warns use "-W", for Wconf filters, use "-Wconf:help"
// Silence warns generated by Play codes generators
// https://github.com/playframework/playframework/issues/6302
// - first one is due to -Wnonunit-statement with routes generator
"-Wconf:src=routes/.*&msg=unused value:s",
// - second one is due to -Wunused:imports with twirl
"-Wconf:src=twirl/.*&msg=unused import:s",
// Silence specs2 warnings from -Wnonunit-statement
"-Wconf:src=aplus/test/.*&msg=unused value:s",
// Sets warnings as errors on the CI
if (insideCI.value) "-Wconf:any:error" else "-Wconf:any:warning",
// Recommended for cats-effect
// https://typelevel.org/cats-effect/docs/getting-started
"-Wnonunit-statement",
"-Wunused:imports",
"-Wunused:privates",
"-Wunused:locals",
// "-Wunused:explicits", // TODO: lot of warnings, enable later
"-Wunused:implicits",
"-Wunused:nowarn",
"-Wvalue-discard",
)
val anormVersion = "2.8.1"
lazy val anormDependency = "org.playframework.anorm" %% "anorm" % anormVersion
lazy val anormDependencies = Seq(
anormDependency,
"org.playframework.anorm" %% "anorm-postgres" % anormVersion,
)
libraryDependencies ++= Seq(
ws,
jdbc,
evolutions,
)
pipelineStages := Seq(digest, gzip)
libraryDependencies += guice
val fs2Version = "3.11.0"
libraryDependencies ++= Seq(
"org.postgresql" % "postgresql" % "42.7.5",
"org.playframework" %% "play-mailer" % "10.1.0",
"org.playframework" %% "play-json" % "3.0.4",
"com.sun.mail" % "javax.mail" % "1.6.2",
"com.github.tototoshi" %% "scala-csv" % "2.0.0",
ws,
"com.lihaoyi" %% "scalatags" % "0.13.1",
"org.typelevel" %% "cats-core" % "2.13.0",
"org.typelevel" %% "cats-effect" % "3.5.7",
"co.fs2" %% "fs2-core" % fs2Version,
"co.fs2" %% "fs2-io" % fs2Version,
"io.laserdisc" %% "fs2-aws-s3" % "6.2.0",
// Needs the C library to be installed
"de.mkammerer" % "argon2-jvm-nolibs" % "2.11",
)
libraryDependencies ++= anormDependencies
// UI
libraryDependencies ++= Seq(
"org.webjars" %% "webjars-play" % "3.0.2",
"org.webjars.bower" % "material-design-lite" % "1.3.0",
"org.webjars" % "material-design-icons" % "4.0.0",
"org.webjars.npm" % "roboto-fontface" % "0.10.0",
"org.webjars" % "font-awesome" % "6.7.1",
)
// Crash
libraryDependencies += "io.sentry" % "sentry-logback" % "7.20.1"
// Sync with Play and scala-steward pin
// https://github.com/playframework/playframework/blob/4c2d76095c2f6a5cab7be3e8f6017c4a4dd2a99f/project/Dependencies.scala#L20
val specs2Version = "4.20.9"
// Test
libraryDependencies ++= Seq(
specs2 % Test, // Play Plugin
"org.specs2" %% "specs2-scalacheck" % specs2Version % Test,
"org.scalacheck" %% "scalacheck" % "1.18.1" % Test,
"org.typelevel" %% "cats-effect-testing-specs2" % "1.6.0" % Test,
)
// Sync with scala-steward pin
val jacksonVersion = "2.14.3"
val jacksonDatabindVersion = "2.14.3"
val jacksonOverrides = Seq(
"com.fasterxml.jackson.core" % "jackson-core",
"com.fasterxml.jackson.core" % "jackson-annotations",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jdk8",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310"
).map(_ % jacksonVersion)
val jacksonDatabindOverrides = Seq(
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonDatabindVersion
)
val akkaSerializationJacksonOverrides = Seq(
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-cbor",
"com.fasterxml.jackson.module" % "jackson-module-parameter-names",
"com.fasterxml.jackson.module" %% "jackson-module-scala",
).map(_ % jacksonVersion)
libraryDependencies ++= jacksonDatabindOverrides ++ jacksonOverrides ++ akkaSerializationJacksonOverrides
// Adds additional packages into Twirl
TwirlKeys.templateImports += "constants.Constants"
TwirlKeys.templateImports += "_root_.helper.TwirlImports._"
TwirlKeys.templateImports += "views.MainInfos"
// Adds additional packages into conf/routes
// play.sbt.routes.RoutesKeys.routesImport += "fr.gouv.beta.binders._"
// See https://github.com/sbt/sbt/issues/6997
ThisBuild / libraryDependencySchemes ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
)
/////////////////////////////////////
// Macros //
/////////////////////////////////////
lazy val macrosProject = (project in file("macros"))
.settings(
libraryDependencies ++= Seq(
anormDependency,
)
)
/////////////////////////////////////
// Task and Hook for the TS build //
/////////////////////////////////////
/** This task will run `npm install` and `npm run build` in the typescript/ directory. This will
* generate the JS production bundle in public/generate-js/index.js
*/
lazy val npmBuild = taskKey[Unit]("Run npm run build.")
npmBuild := {
import scala.sys.process.Process
val tsDirectory = baseDirectory.value
println("Running npm install in directory " + tsDirectory)
Process("npm install", tsDirectory).!
Process("npm run build", tsDirectory).!
}
/** Add a hook to the Play sbt plugin, so `npm run watch` is runned when using the sbt command `run`
*
* See documentation:
* https://www.playframework.com/documentation/2.8.x/sbtCookbook#Hooking-into-Plays-dev-mode
* https://github.com/playframework/playframework/blob/2.8.x/documentation/manual/working/commonGuide/build/code/runhook.sbt
*/
def NpmWatch(base: File) = {
import play.sbt.PlayRunHook
import sbt._
import scala.sys.process.Process
object NpmWatch {
def apply(base: File): PlayRunHook = {
object NpmProcess extends PlayRunHook {
var watchProcess: Option[Process] = None
override def beforeStarted(): Unit =
Process("npm install", base).run
override def afterStarted(): Unit =
watchProcess = Some(Process("npm run watch", base).run)
override def afterStopped(): Unit = {
watchProcess.map(p => p.destroy())
watchProcess = None
}
}
NpmProcess
}
}
NpmWatch(base)
}
PlayKeys.playRunHooks += NpmWatch(baseDirectory.value)