-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sbt
145 lines (129 loc) · 4.33 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
name := "query-monad-code"
version := "1.0-SNAPSHOT"
ThisBuild / scalaVersion := "2.12.10"
ThisBuild / crossScalaVersions := Seq("2.11.12", "2.12.10")
def scalacOptionsVersion(scalaVersion: String) = {
val defaultOptions = Seq(
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-encoding",
"utf-8", // Specify character encoding used by source files.
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
"-Xfatal-warnings", // Fail the compilation if there are any warnings.
"-Xlint",
"-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver.
"-Ypartial-unification", // Enable partial unification in type constructor inference
"-Ywarn-dead-code", // Warn when dead code is identified.
"-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", // Warn if unused.
"-Ywarn-value-discard" // Warn when non-Unit expression results are unused.
)
val v211Options = Seq(
"-Xsource:2.12" // See https://github.com/scala/scala/releases/tag/v2.11.11
)
val v212Options = Seq(
"-Ywarn-extra-implicit" // Warn when more than one implicit parameter section is defined.
)
CrossVersion.partialVersion(scalaVersion) match {
case Some((2L, 11L)) => defaultOptions ++ v211Options
case _ => defaultOptions ++ v212Options
}
}
// Common values
def commonSettings = Seq(
organization := "com.zengularity",
crossPaths := false,
scalacOptions ++= scalacOptionsVersion(scalaVersion.value),
scalacOptions in (Compile, console) ~= (_.filterNot(
Set(
"-Ywarn-unused:imports",
"-Xfatal-warnings"
)
)),
scalacOptions in (Test, compile) ~= (_.filterNot(
Set(
"-Ywarn-unused:imports",
"-Xfatal-warnings",
"-Yrangepos"
)
)),
resolvers ++= Seq[Resolver](
Resolver.sonatypeRepo("releases")
)
)
// Scalafmt
ThisBuild / scalafmtOnCompile := true
// Wartremover
wartremoverErrors ++= Warts.unsafe
//
// Projects definitions
//
// Core + Modules
lazy val core = (project in file("core"))
.settings(
commonSettings ++ Seq(
name := "query-core",
libraryDependencies ++= Seq(
Dependencies.acolyte % Test,
Dependencies.anorm % Test,
Dependencies.cats,
Dependencies.specs2 % Test
)
)
)
lazy val playSqlModule = (project in file("modules/play-sql"))
.settings(commonSettings)
.settings(
name := "query-play-sql",
libraryDependencies ++= Seq(
jdbc,
evolutions % Test,
logback % Test,
Dependencies.acolyte % Test,
Dependencies.acolytePlay % Test,
Dependencies.anorm % Test,
Dependencies.h2 % Test,
Dependencies.scalaLogging,
Dependencies.specs2 % Test
)
)
.dependsOn(core % "test->test;compile->compile")
// Examples
lazy val sampleAppExample = (project in file("examples/sample-app"))
.enablePlugins(PlayScala)
.settings(
commonSettings ++ Seq(
name := "sample-app-example",
libraryDependencies ++= Seq(
Dependencies.anorm,
Dependencies.h2
)
)
)
.dependsOn(core, playSqlModule)
lazy val todoAppExample = (project in file("examples/todo-app"))
.enablePlugins(PlayScala)
.settings(commonSettings)
.settings(
name := "todo-app-example",
libraryDependencies ++= Seq(
evolutions,
Dependencies.anorm,
Dependencies.postgres,
Dependencies.jbcrypt
),
play.sbt.routes.RoutesKeys.routesImport := Seq(
"java.util.UUID"
)
)
.dependsOn(core, playSqlModule)
// Aggregate all projects
lazy val root: Project = project
.in(file("."))
.aggregate(core, playSqlModule, sampleAppExample, todoAppExample)