-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
221 lines (201 loc) · 8.39 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
import Dependencies.Library._
name := "scala-play-starter-kit"
// Add any command aliases that may be useful as shortcuts
addCommandAlias("cc", ";clean;compile")
addCommandAlias("populate", "population/run")
addCommandAlias("db_migrate", "migration/flywayMigrate")
addCommandAlias("db_clean", "migration/flywayClean")
addCommandAlias("cd", "project")
addCommandAlias("ls", "projects")
addCommandAlias("cr", ";clean ;reload")
addCommandAlias("cru", ";clean ;reload ;test:update")
addCommandAlias("du", "dependencyUpdates")
addCommandAlias("rdu", ";reload ;dependencyUpdates")
addCommandAlias("ru", ";reload ;test:update")
addCommandAlias("tc", "test:compile")
// workaround for scalafmt in sbt 0.13
lazy val latestScalafmt = "1.2.0"
commands += Command.args("scalafmt", "Run scalafmt cli.") {
case (state, args) =>
val Right(scalafmt) =
org.scalafmt.bootstrap.ScalafmtBootstrap.fromVersion(latestScalafmt)
scalafmt.main("--non-interactive" +: args.toArray)
state
}
lazy val commonSettings = Seq(
version := "1.0",
scalaVersion := "2.12.4",
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases",
resolvers += "Akka Snapshot Repository" at "http://repo.akka.io/snapshots/",
resolvers += "micronautics/scala on bintray" at "http://dl.bintray.com/micronautics/scala",
scalacOptions ++= Seq(
// "-P:splain:implicits:false",
"-deprecation", // warn about deprecated code
"-encoding",
"UTF-8", // UTF-8 should be the default file encoding everywhere
"-explaintypes", // explain type errors with more details
"-feature", // should enable Scala features explicitly
"-language:higherKinds", // higher-kinded types are useful with typeclasses
"-language:implicitConversions", // implicit parameters and classes are useful
"-unchecked", // static code shouldn't depend on assumptions
// "-Xfatal-warnings", // warnings SHOULD be errors - it will help with code smells
"-Xfuture", // enable future language features
"-Xlint:delayedinit-select", // selecting member of DelayedInit
"-Xlint:doc-detached", // warn when a scaladoc is detached from its element
"-Xlint:infer-any", // Any shouldn't be infered - it's unsafe
"-Xlint:missing-interpolator", // a variable isn't defined in a string interpolation
"-Xlint:nullary-override", // warn when 'def f()' overrides 'def f'
"-Xlint:nullary-unit", // warn when nullary methods return with Unit
"-Xlint:private-shadow", // something shadows a private member
"-Xlint:stars-align", // pattern sequence wildcard must align with sequence component
"-Xlint:type-parameter-shadow", // something local shadows a type parameter
"-Xlint:unsound-match", // the used pattern matching is unsafe
"-Ywarn-dead-code", // warn about unused code
"-Ywarn-extra-implicit", // there should be a max of 1 implicit parameter for each definition
"-Ywarn-inaccessible", // warn about inaccessible types in method signatures
// "-Ywarn-unused:imports", // warn about unused imports
// "-Ywarn-unused:locals", // warn about unused local variables
// "-Ywarn-unused:params", // warn about unused parameters
// "-Ywarn-unused:patvars", // warn about unused pattern matching variables
// "-Ywarn-unused:privates", // warn about unused private members
"-Ywarn-value-discard", // warn when a non-Unit expression is unused
"-Ypartial-unification" //if running 2.12
),
// Note that the REPL can?t really cope with -Ywarn-unused:imports or -Xfatal-warnings so you should turn them off for
// the console.
scalacOptions in (Compile, console) ~= (_.filterNot(
Set(
"-Ywarn-unused:imports",
"-Xfatal-warnings"
)
))
)
lazy val commonWartRemoverSettings = Seq(
// more at wartremover.org/doc/warts.html
wartremoverWarnings in (Compile, compile) ++= Seq(
Wart.ArrayEquals,
// Wart.Any,
Wart.AnyVal,
Wart.AsInstanceOf, // type conversion hurts typesafety
Wart.EitherProjectionPartial, // the 'get' method can throw an exception
Wart.Enumeration, // Scala's enumerations are slow, use ADTs
Wart.ExplicitImplicitTypes, // implicits must have explicit type annotations
Wart.FinalCaseClass, // case class must be sealed - they meant to be simple data types
Wart.FinalVal, // final vals cause inconsistency during incremental compilation
Wart.ImplicitConversion, // implicit conversions are dangerous
Wart.IsInstanceOf, // pattern matching is safer
Wart.LeakingSealed, // the subclasses of sealed traits must be final to avoid leaking
Wart.Null, // null is unsafe and useless in Scala
Wart.OptionPartial, // don't use Option's get method, it might throw exceptions
Wart.Return, // return is spaghetti(and breaks referential transparency)
Wart.StringPlusAny, // concatenate only a String with an other String
Wart.Throw, // don't throw exceptions, use Either or Option
Wart.TraversableOps, // get, head, tail etc. are unsafe - possible exceptions
Wart.TryPartial, // Try's get is unsafe
Wart.Var,
Wart.While // these are only useful at micro-optimizations, use tail recursion instead
// the following options somehow triggers a `NullPointerException` with quill in use during compilation...
// Wart.JavaConversions, // use java collections explicitly
// Wart.MutableDataStructures, // mutable data structures in Scala are generally useless
)
)
lazy val rootWartRemoverSettings = commonWartRemoverSettings ++
Seq(
// Exlucde play routes from wartremover
wartremoverExcluded ++= routes.in(Compile).value
)
lazy val populationWartRemoverSettings = commonWartRemoverSettings
lazy val dataAccessWartRemoverSettings = commonWartRemoverSettings
lazy val populationDependencies = Seq(PostgreSQL.db, Quill.asyncpostgresql, Refined.core)
lazy val dataAccessDependencies = Seq(
PostgreSQL.db,
Quill.asyncpostgresql,
JavaxInject.inject,
Shapeless.core,
JodaTime.core,
Enumeratum.core,
Refined.core,
Cats.core,
CatsEffect.core
) ++ Silhouette.toSeq
lazy val migrationDependencies = Seq(PostgreSQL.db, FlywayDB.core)
lazy val utilityDependencies = Seq(
Refined.core,
Quill.asyncpostgresql
)
lazy val appDependencies = Seq(
jdbc,
ehcache,
ws,
specs2 % Test,
guice,
PostgreSQL.db,
Quill.asyncpostgresql,
FlywayDB.play,
Cats.core,
Shapeless.core,
Bootstrap.core,
PureConfig.core,
Enumeratum.core,
Refined.core,
Enumeratum.core
) ++
Silhouette.toSeq ++
Circe.toSeq ++
WebJars.toSeq
import org.flywaydb.sbt.FlywayPlugin._
lazy val conf =
com.typesafe.config.ConfigFactory
.parseFile(new File("configuration/src/main/resources/db.conf"))
.resolve()
lazy val flywaySettings = Seq(
flywayUrl := conf.getString("db.default.url"),
flywayUser := conf.getString("db.default.user"),
flywayPassword := conf.getString("db.default.password"),
flywayLocations := Seq("filesystem:conf/db/migration"),
flywayValidateOnMigrate := true
// flywayLocations := Seq("classpath:db/migration")
)
lazy val `scala-play-starter-kit` = (project in file("."))
.dependsOn(utility, `data_access`, configuration)
.aggregate(utility, `data_access`, configuration)
.settings(commonSettings: _*)
.settings(rootWartRemoverSettings: _*)
.settings {
libraryDependencies ++= appDependencies
}
.enablePlugins(PlayScala)
.enablePlugins(DockerPlugin)
lazy val population = (project in file("population"))
.dependsOn(`data_access`, configuration)
.aggregate(`data_access`, configuration)
.settings(commonSettings: _*)
.settings(populationWartRemoverSettings: _*)
.settings {
libraryDependencies ++= populationDependencies
}
lazy val utility = (project in file("utility"))
.settings(commonSettings: _*)
.settings(commonWartRemoverSettings: _*)
.settings {
libraryDependencies ++= utilityDependencies
}
lazy val configuration = (project in file("configuration"))
.settings(commonSettings: _*)
lazy val migration = (project in file("migration"))
.dependsOn(configuration)
.settings(commonSettings: _*)
.settings(commonWartRemoverSettings: _*)
.settings(flywaySettings: _*)
.settings {
libraryDependencies ++= migrationDependencies
}
.enablePlugins(FlywayPlugin)
lazy val `data_access` = (project in file("data_access"))
.dependsOn(utility)
.settings(commonSettings: _*)
.settings(dataAccessWartRemoverSettings: _*)
.settings {
libraryDependencies ++= dataAccessDependencies
}
//unmanagedResourceDirectories in Test <+= baseDirectory ( _ /"target/web/public/test" )