forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
524 lines (435 loc) · 11.1 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
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
import com.typesafe.sbt.packager.Keys.{ bashScriptExtraDefines, scriptClasspath }
import play.sbt.PlayCommands
import play.sbt.PlayInternalKeys.playDependencyClasspath
import play.sbt.routes.RoutesKeys
import BuildSettings.*
import Dependencies.*
lazy val root = Project("lila", file("."))
.enablePlugins(JavaServerAppPackaging, RoutesCompiler)
.dependsOn(api)
.aggregate(api)
.settings(buildSettings)
.settings(scalacOptions ++= Seq("-unchecked", "-deprecation"))
organization := "org.lichess"
Compile / run / fork := true
javaOptions ++= Seq("-Xms64m", "-Xmx512m", "-Dlogger.file=conf/logger.dev.xml")
ThisBuild / usePipelining := false
// shorter prod classpath
scriptClasspath := Seq("*")
Compile / resourceDirectory := baseDirectory.value / "conf"
// the following settings come from the PlayScala plugin, which I removed
shellPrompt := PlayCommands.playPrompt
// all dependencies from outside the project (all dependency jars)
playDependencyClasspath := (Runtime / externalDependencyClasspath).value
// playCommonClassloader := PlayCommands.playCommonClassloaderTask.value
// playCompileEverything := PlayCommands.playCompileEverythingTask.value.asInstanceOf[Seq[Analysis]]
ivyLoggingLevel := UpdateLogging.DownloadOnly
Compile / mainClass := Some("lila.app.Lila")
// Adds the Play application directory to the command line args passed to Play
bashScriptExtraDefines += "addJava \"-Duser.dir=$(realpath \"$(cd \"${app_home}/..\"; pwd -P)\" $(is_cygwin && echo \"fix\"))\"\n"
Compile / RoutesKeys.generateReverseRouter := false
Compile / RoutesKeys.routes / sources ++= {
val dirs = (Compile / unmanagedResourceDirectories).value
(dirs * "routes").get ++ (dirs * "*.routes").get
}
Compile / RoutesKeys.generateReverseRouter := false
Compile / RoutesKeys.generateForwardRouter := true
target := baseDirectory.value / "target"
Compile / sourceDirectory := baseDirectory.value / "app"
Compile / scalaSource := baseDirectory.value / "app"
Universal / sourceDirectory := baseDirectory.value / "dist"
// cats-parse v1.0.0 is the same as v0.3.1, so this is safe
ThisBuild / libraryDependencySchemes ++= Seq(
"org.typelevel" %% "cats-parse" % VersionScheme.Always
)
// format: off
libraryDependencies ++= akka.bundle ++ playWs.bundle ++ macwire.bundle ++ scalalib.bundle ++ chess.bundle ++ Seq(
play.json, play.logback, compression, hasher,
reactivemongo.driver, /* reactivemongo.kamon, */ maxmind, scalatags,
kamon.core, kamon.influxdb, kamon.metrics,
scaffeine, caffeine, lettuce, uaparser, nettyTransport, reactivemongo.shaded
) ++ tests.bundle
// influences the compilation order
// matches https://github.com/ornicar/lila-dep-graphs
lazy val modules = Seq(
// level 1
core, coreI18n,
// level 2
ui, common, tree,
// level 3
db, room, search,
// level 4
memo, rating,
// level 5
game, gathering, study, user, puzzle, analyse,
report, pref, chat, playban, lobby, mailer, oauth,
// level 6
insight, evaluation, storm,
// level 7
// everything else is free from deps; do the big ones first
security, tournament, relay, plan, round,
swiss, insight, fishnet, tutor, mod, challenge, web,
team, forum, streamer, simul, activity, msg, ublog,
notifyModule, clas, perfStat, opening, timeline,
setup, video, fide, title, push,
// and then the smaller ones
pool, lobby, relation, tv, coordinate, feed, history, recap,
shutup, appeal, irc, explorer, learn, event, coach,
practice, evalCache, irwin, bot, racer, cms, i18n,
socket, bookmark, studySearch, gameSearch, forumSearch, teamSearch,
)
lazy val moduleRefs = modules map projectToRef
lazy val moduleCPDeps = moduleRefs map { sbt.ClasspathDependency(_, None) }
lazy val core = module("core",
Seq(),
Seq(scalatags, galimatias) ++ scalalib.bundle ++ reactivemongo.bundle ++ tests.bundle
)
lazy val coreI18n = module("coreI18n",
Seq(),
Seq(scalatags) ++ scalalib.bundle
)
lazy val common = module("common",
Seq(core),
Seq(
kamon.core, scaffeine, apacheText, chess.playJson
) ++ tests.bundle ++ flexmark.bundle
)
lazy val db = module("db",
Seq(common),
Seq(hasher) ++ macwire.bundle
)
lazy val memo = module("memo",
Seq(db),
Seq(scaffeine) ++ playWs.bundle
)
lazy val i18n = module("i18n",
Seq(common, coreI18n),
tests.bundle
).settings(
Compile / resourceGenerators += Def.task {
val outputFile = (Compile / resourceManaged).value / "I18n.ser"
I18n.serialize(
sourceDir = new File("translation/source"),
destDir = new File("translation/dest"),
dbs = "site arena emails learn activity coordinates study class contact appeal patron coach broadcast streamer tfa settings preferences team perfStat search tourname faq lag swiss puzzle puzzleTheme challenge storm ublog insight keyboardMove timeago oauthScope dgt voiceCommands onboarding features".split(' ').toList,
outputFile
)
}.taskValue
)
lazy val rating = module("rating",
Seq(db, ui),
tests.bundle ++ Seq(apacheMath)
).dependsOn(common % "test->test")
lazy val cms = module("cms",
Seq(memo, ui),
Seq()
)
lazy val puzzle = module("puzzle",
Seq(tree, memo, rating),
tests.bundle
)
lazy val storm = module("storm",
Seq(puzzle),
Seq()
)
lazy val racer = module("racer",
Seq(storm, room),
Seq()
)
lazy val video = module("video",
Seq(memo, ui),
macwire.bundle
)
lazy val coach = module("coach",
Seq(memo, rating),
Seq()
)
lazy val streamer = module("streamer",
Seq(ui, memo),
Seq()
)
lazy val coordinate = module("coordinate",
Seq(db, ui),
macwire.bundle
)
lazy val feed = module("feed",
Seq(memo, ui),
Seq()
)
lazy val ublog = module("ublog",
Seq(memo, ui),
Seq(bloomFilter)
)
lazy val evaluation = module("evaluation",
Seq(analyse, game),
tests.bundle
)
lazy val perfStat = module("perfStat",
Seq(memo, rating),
Seq()
)
lazy val history = module("history",
Seq(rating, memo),
Seq()
)
lazy val search = module("search",
Seq(common),
Seq(playWs.ahc, lilaSearch)
)
lazy val chat = module("chat",
Seq(memo, ui),
Seq()
)
lazy val room = module("room",
Seq(common),
Seq(lettuce)
)
lazy val timeline = module("timeline",
Seq(memo, ui),
Seq()
)
lazy val event = module("event",
Seq(memo, ui),
Seq()
)
lazy val mod = module("mod",
Seq(evaluation, report, chat, user),
Seq()
)
lazy val user = module("user",
Seq(rating, memo),
Seq(hasher) ++ tests.bundle ++ playWs.bundle
)
lazy val game = module("game",
Seq(tree, rating, memo),
Seq(compression) ++ tests.bundle ++ Seq(scalacheck, munitCheck, chess.testKit)
)
lazy val gameSearch = module("gameSearch",
Seq(search, ui),
tests.bundle
)
// good dep to game
lazy val tv = module("tv",
Seq(game),
Seq(hasher)
)
lazy val bot = module("bot",
Seq(chat, game),
Seq()
)
lazy val analyse = module("analyse",
Seq(tree, memo, ui),
tests.bundle
).dependsOn(coreI18n % "test->test")
lazy val round = module("round",
Seq(room, game, user, playban, pref, chat),
Seq(hasher, kamon.core, lettuce) ++ tests.bundle
)
lazy val pool = module("pool",
Seq(db, rating),
Seq()
)
lazy val activity = module("activity",
Seq(puzzle),
Seq()
)
lazy val lobby = module("lobby",
Seq(memo, rating),
Seq(lettuce) ++ tests.bundle
)
lazy val setup = module("setup",
Seq(lobby),
Seq()
)
lazy val insight = module("insight",
Seq(analyse, game),
Seq()
)
lazy val tutor = module("tutor",
Seq(insight),
tests.bundle
)
lazy val opening = module("opening",
Seq(memo, ui),
tests.bundle
)
lazy val gathering = module("gathering",
Seq(rating),
tests.bundle
)
lazy val tournament = module("tournament",
Seq(gathering, room, memo),
Seq(lettuce) ++ tests.bundle
).dependsOn(coreI18n % "test->test")
lazy val swiss = module("swiss",
Seq(gathering, room, memo),
Seq(lettuce) ++ tests.bundle
)
lazy val simul = module("simul",
Seq(gathering, room, memo),
Seq(lettuce)
)
lazy val fishnet = module("fishnet",
Seq(analyse),
Seq(lettuce) ++ tests.bundle
)
lazy val irwin = module("irwin",
Seq(analyse, game, report),
Seq()
)
lazy val oauth = module("oauth",
Seq(memo, ui),
Seq()
)
lazy val security = module("security",
Seq(oauth, user, mailer),
Seq(maxmind, hasher, uaparser) ++ tests.bundle
)
lazy val shutup = module("shutup",
Seq(db),
tests.bundle
)
lazy val challenge = module("challenge",
Seq(game, room, oauth),
Seq(lettuce) ++ tests.bundle
)
lazy val fide = module("fide",
Seq(memo, ui),
Seq()
)
lazy val title = module("title",
Seq(memo, ui),
Seq()
)
lazy val study = module("study",
Seq(tree, memo, room, ui),
Seq(lettuce) ++ tests.bundle ++ Seq(scalacheck, munitCheck, chess.testKit)
).dependsOn(common % "test->test")
lazy val relay = module("relay",
Seq(study, game),
tests.bundle
)
lazy val studySearch = module("studySearch",
Seq(study, search),
Seq()
)
lazy val learn = module("learn",
Seq(db),
Seq()
)
lazy val evalCache = module("evalCache",
Seq(tree, memo),
Seq()
)
lazy val practice = module("practice",
Seq(study),
Seq()
)
lazy val playban = module("playban",
Seq(memo),
tests.bundle
)
lazy val push = module("push",
Seq(db),
playWs.bundle ++ Seq(googleOAuth)
)
lazy val irc = module("irc",
Seq(common),
playWs.bundle
)
lazy val mailer = module("mailer",
Seq(memo, coreI18n),
Seq(hasher, play.mailer)
)
lazy val plan = module("plan",
Seq(memo, ui),
tests.bundle
)
lazy val relation = module("relation",
Seq(memo, ui),
Seq()
)
lazy val pref = module("pref",
Seq(memo, ui),
Seq()
)
lazy val msg = module("msg",
Seq(coreI18n, memo),
Seq()
)
lazy val forum = module("forum",
Seq(memo, ui),
Seq()
)
lazy val forumSearch = module("forumSearch",
Seq(search),
Seq()
)
lazy val team = module("team",
Seq(memo, room, ui),
Seq()
)
lazy val teamSearch = module("teamSearch",
Seq(search),
Seq()
)
lazy val clas = module("clas",
Seq(user, puzzle),
Seq(bloomFilter)
)
lazy val bookmark = module("bookmark",
Seq(db),
Seq()
)
lazy val report = module("report",
Seq(ui, memo),
Seq()
)
lazy val appeal = module("appeal",
Seq(memo, ui),
Seq()
)
lazy val explorer = module("explorer",
Seq(game),
Seq()
)
lazy val notifyModule = module("notify",
Seq(memo, ui),
Seq()
)
lazy val recap = module("recap",
Seq(memo, ui, user, game, puzzle),
Seq()
)
lazy val socket = module("socket",
Seq(memo),
Seq(lettuce)
)
lazy val tree = module("tree",
Seq(core),
Seq(chess.playJson)
)
lazy val ui = module("ui",
Seq(core, coreI18n),
Seq()
).enablePlugins(RoutesCompiler).settings(
Compile / RoutesKeys.generateForwardRouter := false,
Compile / RoutesKeys.routes / sources ++= {
val dirs = baseDirectory.value / ".." / ".." / "conf"
(dirs * "routes").get ++ (dirs * "*.routes").get
}
)
lazy val web = module("web",
Seq(ui, memo),
playWs.bundle ++ tests.bundle ++ Seq(
play.logback, play.server, play.netty,
kamon.prometheus,
)
)
lazy val api = module("api",
moduleCPDeps,
Seq(play.api, play.json, hasher, kamon.core, kamon.influxdb, lettuce) ++ tests.bundle ++ flexmark.bundle
).settings(
Runtime / aggregate := false,
Test / aggregate := true // Test <: Runtime
) aggregate (moduleRefs: _*)