-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
564 lines (509 loc) · 18 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
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
import sbt._
lazy val root =
Project(id = "store-backend", base = file("."))
.settings(commonSettings)
.aggregate(
`store-server`
)
lazy val `store-server` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.settings(
mainClass := Some("store.server.StoreServerApp")
)
.aggregate(
`service-user`,
`service-order`,
`service-product`,
`store-config`,
`store-db`,
`store-json`,
`store-http`,
`store-core`,
`store-effects`
)
.dependsOn(
`service-user`,
`service-order`,
`service-product`,
`store-config`,
`store-db`,
`store-json`,
`store-http`,
`store-core`,
`store-effects`
)
lazy val `service-order` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.aggregate(
`algebra-order`,
`algebra-http-sec`,
`store-config`,
`store-db`,
`store-json`,
`store-http`,
`store-core`,
`store-effects`
)
.dependsOn(
`algebra-order`,
`algebra-http-sec`,
`store-config`,
`store-db`,
`store-json`,
`store-http`,
`store-core`,
`store-effects`
)
lazy val `service-user` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.aggregate(
`algebra-auth`,
`algebra-http-sec`,
`store-config`,
`store-json`,
`store-http`,
`store-core`,
`store-effects`
)
.dependsOn(
`algebra-auth`,
`algebra-http-sec`,
`store-config`,
`store-json`,
`store-http`,
`store-core`,
`store-effects`
)
lazy val `service-product` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.aggregate(
`algebra-product`,
`algebra-http-sec`,
`store-config`,
`store-db`,
`store-json`,
`store-http`,
`store-core`,
`store-effects`
)
.dependsOn(
`algebra-product`,
`algebra-http-sec`,
`store-config`,
`store-db`,
`store-json`,
`store-http`,
`store-core`,
`store-effects`
)
lazy val `algebra-order` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.aggregate(
`algebra-product`,
`algebra-email`,
`store-config`,
`store-db`,
`store-core`,
`store-effects`
)
.dependsOn(
`algebra-product`,
`algebra-email`,
`store-config`,
`store-db`,
`store-core`,
`store-effects`
)
lazy val `algebra-product` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.aggregate(
`algebra-content`,
`store-config`,
`store-db`,
`store-core`,
`store-effects`
)
.dependsOn(
`algebra-content`,
`store-config`,
`store-db`,
`store-core`,
`store-effects`
)
lazy val `algebra-content` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.settings(
libraryDependencies ++= Seq(
betterFiles,
amazonSDKS3,
scrimage
)
)
.aggregate(
`store-db`,
`store-config`,
`store-core`,
`store-effects`
)
.dependsOn(
`store-db`,
`store-config`,
`store-core`,
`store-effects`
)
lazy val `algebra-email` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.settings(
libraryDependencies ++= Seq(
javaxMail
)
)
.aggregate(
`store-config`,
`store-core`,
`store-effects`
)
.dependsOn(
`store-config`,
`store-core`,
`store-effects`
)
lazy val `algebra-http-sec` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.dependsOn(
`algebra-auth`,
`store-config`,
`store-effects`,
`store-core`,
`store-http`,
)
.aggregate(
`algebra-auth`,
`store-config`,
`store-effects`,
`store-core`,
`store-http`,
)
lazy val `algebra-auth` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.settings(
libraryDependencies ++= tsec
)
.aggregate(
`store-config`,
`store-core`,
`store-effects`
)
.dependsOn(
`store-config`,
`store-core`,
`store-effects`
)
lazy val `store-db` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.settings(
libraryDependencies ++= Seq(
doobieHikari,
doobiePostgres,
flyway
)
)
.dependsOn(
`store-config`,
`store-core`,
`store-effects`
)
lazy val `store-http` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.settings(
libraryDependencies ++= Seq(
http4sBlazeServer,
http4sCirce,
http4sDSL,
)
)
.dependsOn(
`store-json`,
`store-core`,
`store-effects`,
)
lazy val `store-json` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.settings(
libraryDependencies ++= Seq(
circeCore,
circeGeneric,
circeGenericExtras,
bmcJson,
)
)
.dependsOn(
`store-core`,
`store-effects`
)
lazy val `store-core` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.settings(
libraryDependencies ++= Seq(
log4cats,
logbackClassic,
linebacker,
shapeless
) ++ tsec
)
.dependsOn(
`store-effects`
)
lazy val `store-config` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.settings(
libraryDependencies ++= Seq(
pureConfig
)
)
.dependsOn(
`store-effects`
)
lazy val `store-effects` = project
.settings(commonSettings)
.settings(sbtAssemblySettings)
.settings(
libraryDependencies ++= Seq(
catsEffect,
catsCore,
bmcEffects,
monix,
fs2,
)
)
//=============================================================================
//=============================================================================
def commonSettings: Seq[Setting[_]] = Seq(
scalaVersion := "2.12.6",
/*
* Eliminates useless, unintuitive, and sometimes broken additions of `withFilter`
* when using generator arrows in for comprehensions. e.g.
*
* Vanila scala:
* {{{
* for {
* x: Int <- readIntIO
* //
* } yield ()
* // instead of being `readIntIO.flatMap(x: Int => ...)`, it's something like .withFilter {case x: Int}, which is tantamount to
* // a runtime instanceof check. Absolutely horrible, and ridiculous, and unintuitive, and contrary to the often-
* // parroted mantra of "a for is just sugar for flatMap and map
* }}}
*
* https://github.com/oleg-py/better-monadic-for
*/
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.2.4"),
scalacOptions ++= customScalaCompileFlags,
/**
* This is here to eliminate eviction warnings from SBT.
* The eco-system is mid-upgrade, so not all dependencies
* depend on this newest cats, and cats-effect.
*
* See more on binary compatability:
* https://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html
*
* It is an important issue that you need to keep track of if
* you build apps on the JVM.
*/
dependencyOverrides += "org.typelevel" %% "cats-core" % "1.1.0",
dependencyOverrides += "org.typelevel" %% "cats-effect" % "0.10.1",
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
)
def sbtAssemblySettings: Seq[Setting[_]] = {
import sbtassembly.MergeStrategy
import sbtassembly.PathList
baseAssemblySettings ++
Seq(
// Skip tests during while running the assembly task
test in assembly := {},
assemblyMergeStrategy in assembly := {
case PathList("application.conf", _ @_*) => MergeStrategy.concat
case "application.conf" => MergeStrategy.concat
case PathList("reference.conf", _ @_*) => MergeStrategy.concat
case "reference.conf" => MergeStrategy.concat
case x => (assemblyMergeStrategy in assembly).value(x)
},
// Output path of sbt assembly
assemblyOutputPath in assembly := file("target/store-backend.jar"),
//this is to avoid propagation of the assembly task to all subprojects.
//changing this makes assembly incredibly slow
aggregate in assembly := false
)
}
/**
* tpolecat's glorious compile flag list:
* https://tpolecat.github.io/2017/04/25/scalac-flags.html
*/
def customScalaCompileFlags: Seq[String] = Seq(
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-encoding",
"utf-8", // Specify character encoding used by source files.
"-Yrangepos",
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-language:existentials", // Existential types (besides wildcard types) can be written and inferred
"-language:higherKinds", // Allow higher-kinded types
"-language:implicitConversions", // Allow definition of implicit functions called views
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
"-Xfuture", // Turn on future language features.
"-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver.
"-Xlint:by-name-right-associative", // By-name parameter of right associative operator.
"-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error.
"-Xlint:delayedinit-select", // Selecting member of DelayedInit.
"-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element.
"-Xlint:inaccessible", // Warn about inaccessible types in method signatures.
"-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`.
"-Xlint:missing-interpolator", // A string literal appears to be missing an interpolator id.
"-Xlint:nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
"-Xlint:nullary-unit", // Warn when nullary methods return Unit.
"-Xlint:option-implicit", // Option.apply used implicit view.
"-Xlint:package-object-classes", // Class or object defined in package object.
"-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds.
"-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field.
"-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component.
"-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope.
"-Xlint:unsound-match", // Pattern match may not be typesafe.
"-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver.
"-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined.
"-Ywarn-inaccessible", // Warn about inaccessible types in method signatures.
"-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`.
"-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
"-Ywarn-nullary-unit", // Warn when nullary methods return Unit.
"-Ywarn-numeric-widen", // Warn when numerics are widened.
"-Ywarn-unused:implicits", // Warn if an implicit parameter is unused.
"-Ywarn-unused:imports", // Warn if an import selector is not referenced.
"-Ywarn-unused:locals", // Warn if a local definition is unused.
"-Ywarn-unused:params", // Warn if a value parameter is unused.
"-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused.
"-Ywarn-unused:privates", // Warn if a private member is unused.
"-Ywarn-value-discard", // Warn when non-Unit expression results are unused.
"-Ypartial-unification", // Enable partial unification in type constructor inference
//"-Xfatal-warnings", // Fail the compilation if there are any warnings.
/*
* These are flags specific to the "better-monadic-for" plugin:
* https://github.com/oleg-py/better-monadic-for
*/
"-P:bm4:no-filtering:y",
"-P:bm4:no-map-id:y",
"-P:bm4:no-tupling:y",
)
//=============================================================================
//=============================================================================
//https://github.com/busymachines/busymachines-commons
def bmCommons(m: String): ModuleID =
"com.busymachines" %% s"busymachines-commons-$m" % "0.3.0-RC8"
lazy val bmcEffects: ModuleID = bmCommons("effects") withSources ()
lazy val bmcJson: ModuleID = bmCommons("json") withSources ()
//============================================================================================
//================================= http://typelevel.org/scala/ ==============================
//======================================== typelevel ========================================
//============================================================================================
//https://github.com/typelevel/cats
lazy val catsCore
: ModuleID = "org.typelevel" %% "cats-core" % "1.1.0" withSources ()
//https://github.com/typelevel/cats-effect
lazy val catsEffect
: ModuleID = "org.typelevel" %% "cats-effect" % "1.0.0-RC3" withSources ()
//https://github.com/monix/monix
lazy val monix: ModuleID = "io.monix" %% "monix" % "3.0.0-RC1" withSources ()
//https://github.com/functional-streams-for-scala/fs2
lazy val fs2: ModuleID = "co.fs2" %% "fs2-core" % "0.10.4" withSources ()
//https://circe.github.io/circe/
lazy val circeVersion: String = "0.9.3"
lazy val circeCore: ModuleID = "io.circe" %% "circe-core" % circeVersion
lazy val circeGeneric: ModuleID = "io.circe" %% "circe-generic" % circeVersion
lazy val circeGenericExtras
: ModuleID = "io.circe" %% "circe-generic-extras" % circeVersion
//https://github.com/http4s/http4s
lazy val Http4sVersion = "0.18.12"
lazy val http4sBlazeServer
: ModuleID = "org.http4s" %% "http4s-blaze-server" % Http4sVersion withSources ()
lazy val http4sCirce
: ModuleID = "org.http4s" %% "http4s-circe" % Http4sVersion withSources ()
lazy val http4sDSL
: ModuleID = "org.http4s" %% "http4s-dsl" % Http4sVersion withSources ()
//https://github.com/tpolecat/doobie
lazy val doobieVersion = "0.5.3"
lazy val doobieHikari = "org.tpolecat" %% "doobie-hikari" % doobieVersion withSources () // HikariCP transactor.
lazy val doobiePostgres = "org.tpolecat" %% "doobie-postgres" % doobieVersion withSources () // Postgres driver 42.2.2 + type mappings.
lazy val doobieTK = "org.tpolecat" %% "doobie-specs2" % doobieVersion % Test withSources () // specs2 support for typechecking statements.
lazy val flyway = "org.flywaydb" % "flyway-core" % "4.2.0" withSources ()
//============================================================================================
//======================================== security ========================================
//============================================================================================
//https://github.com/jmcardon/tsec
lazy val tsecV = "0.0.1-M11"
lazy val tsec = Seq(
"io.github.jmcardon" %% "tsec-common" % tsecV withSources (),
"io.github.jmcardon" %% "tsec-password" % tsecV withSources (),
"io.github.jmcardon" %% "tsec-cipher-jca" % tsecV withSources (),
"io.github.jmcardon" %% "tsec-cipher-bouncy" % tsecV withSources (),
"io.github.jmcardon" %% "tsec-mac" % tsecV withSources (),
"io.github.jmcardon" %% "tsec-signatures" % tsecV withSources (),
"io.github.jmcardon" %% "tsec-hash-jca" % tsecV withSources (),
"io.github.jmcardon" %% "tsec-hash-bouncy" % tsecV withSources (),
"io.github.jmcardon" %% "tsec-libsodium" % tsecV withSources (),
"io.github.jmcardon" %% "tsec-jwt-mac" % tsecV withSources (),
"io.github.jmcardon" %% "tsec-jwt-sig" % tsecV withSources (),
"io.github.jmcardon" %% "tsec-http4s" % tsecV withSources (),
)
//============================================================================================
//========================================= logging =========================================
//============================================================================================
//https://github.com/ChristopherDavenport/log4cats
lazy val log4cats = "io.chrisdavenport" %% "log4cats-slf4j" % "0.0.6" withSources ()
//this is a Java library, notice that we used one single % instead of %%
//it is the backend implementation used by log4cats
lazy val logbackClassic = "ch.qos.logback" % "logback-classic" % "1.2.3" withSources ()
//============================================================================================
//========================================== email ==========================================
//============================================================================================
//this is a Java library, notice that we used one single % instead of %%
lazy val javaxMail = "com.sun.mail" % "javax.mail" % "1.6.1" withSources ()
//============================================================================================
//========================================= test =========================================
//============================================================================================
//https://github.com/etorreborre/specs2
lazy val specs2
: ModuleID = "org.specs2" %% "specs2-core" % "4.3.0" % Test withSources ()
//============================================================================================
//=========================================== misc ===========================================
//============================================================================================
//https://github.com/pureconfig/pureconfig
lazy val pureConfig
: ModuleID = "com.github.pureconfig" %% "pureconfig" % "0.9.1" withSources ()
//https://github.com/ChristopherDavenport/linebacker
lazy val linebacker
: ModuleID = "io.chrisdavenport" % "linebacker_2.12" % "0.1.0" withSources ()
//https://github.com/pathikrit/better-files
lazy val betterFiles
: ModuleID = "com.github.pathikrit" %% "better-files" % "3.6.0" withSources ()
//https://github.com/aws/aws-sdk-java
lazy val amazonSDKS3
: ModuleID = "com.amazonaws" % "aws-java-sdk-s3" % "1.11.396" withSources ()
//https://github.com/sksamuel/scrimage
lazy val scrimage
: ModuleID = "com.sksamuel.scrimage" %% "scrimage-core" % "2.1.8" withSources ()
//https://github.com/milessabin/shapeless
lazy val shapeless: ModuleID = "com.chuusai" %% "shapeless" % "2.3.3" withSources()