-
Notifications
You must be signed in to change notification settings - Fork 28
/
build.sbt
332 lines (288 loc) · 10.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
import com.typesafe.sbt.SbtGit.git
val pubVersion = "0.15.2"
val publishSettings = List(
name := "Typed Schema",
organization := "ru.tinkoff",
description := "Typelevel DSL for defining webservices, convertible to akka-http/finagle and swagger definitions",
publishMavenStyle := true,
publishTo := (
if (isSnapshot.value)
Some(Opts.resolver.sonatypeSnapshots)
else
sonatypePublishToBundle.value
),
credentials ++= Option(Path.userHome / ".sbt" / ".ossrh-credentials")
.filter(_.exists())
.map(Credentials(_)),
version := {
val branch = git.gitCurrentBranch.value
if (branch == "master") pubVersion
else s"$pubVersion-$branch-SNAPSHOT"
},
scmInfo := Some(
ScmInfo(
url("https://github.com/TinkoffCreditSystems/typed-schema"),
"git@github.com:username/projectname.git"
)
)
)
ThisBuild / licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))
ThisBuild / publishMavenStyle := true
ThisBuild / homepage := Some(url("https://github.com/TinkoffCreditSystems/typed-schema"))
ThisBuild / developers := List(
Developer("odomontois", "Oleg Nizhnik", "odomontois@gmail.com", url("https://github.com/odomontois"))
)
val minorVersion = SettingKey[Int]("minor scala version")
val scala212V = "2.12.15"
val scala213V = "2.13.8"
val crossCompile = crossScalaVersions := List(scala212V, scala213V)
val commonScalacOptions = scalacOptions ++= List(
"-deprecation",
"-feature",
"-language:existentials",
"-language:experimental.macros",
"-language:higherKinds",
"-language:implicitConversions",
"-language:postfixOps"
)
val specificScalacOptions = scalacOptions ++= {
minorVersion.value match {
case 12 => List("-Ypartial-unification")
case 13 => List("-Ymacro-annotations")
}
}
val setMinorVersion = minorVersion := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) => v.toInt
case _ => 0
}
}
lazy val compilerPlugins = libraryDependencies ++= List(
compilerPlugin("org.typelevel" % "kind-projector" % Version.kindProjector cross CrossVersion.patch),
compilerPlugin("com.olegpy" %% "better-monadic-for" % Version.bm4),
)
val paradise = libraryDependencies ++= {
minorVersion.value match {
case 12 => List(compilerPlugin("org.scalamacros" % "paradise" % Version.macroParadise cross CrossVersion.patch))
case 13 => List()
}
}
val magnolia = libraryDependencies += "com.propensive" %% "magnolia" % Version.magnolia
val tofuOptics =
libraryDependencies ++= List("core", "macro").map(module => "tf.tofu" %% s"tofu-optics-$module" % Version.tofu)
val circe =
libraryDependencies ++= List("core", "parser").map(module => "io.circe" %% s"circe-$module" % Version.circe) ++ List(
"derivation",
"derivation-annotations"
).map(module => "io.circe" %% s"circe-$module" % Version.circeDerivation)
val akkaHttpCirce = libraryDependencies += "de.heikoseeberger" %% "akka-http-circe" % Version.akkaHttpCirce
val catsCore = "org.typelevel" %% "cats-core" % Version.cats
val catsFree = "org.typelevel" %% "cats-free" % Version.cats
val catsEffect = "org.typelevel" %% "cats-effect" % Version.catsEffect
val shapeless = "com.chuusai" %% "shapeless" % Version.shapeless
val enumeratum = "com.beachape" %% "enumeratum" % Version.enumeratum
val akkaHttpLib = "com.typesafe.akka" %% "akka-http" % Version.akkaHttp
val akkaTestKit = "com.typesafe.akka" %% "akka-testkit" % Version.akka % Test
val akkaHttpTestKit = "com.typesafe.akka" %% "akka-http-testkit" % Version.akkaHttp % Test
val finagleHttp = "com.twitter" %% "finagle-http" % Version.finagle
val derevo = "tf.tofu" %% "derevo-cats" % Version.derevo
val swaggerUILib = "org.webjars.npm" % "swagger-ui-dist" % Version.swaggerUI
val scalaTags = "com.lihaoyi" %% "scalatags" % Version.scalaTags
val env = "tf.tofu" %% "tofu-env" % Version.tofu
val scalatest = "org.scalatest" %% "scalatest" % Version.scalaTest % Test
val scalacheck = "org.scalacheck" %% "scalacheck" % Version.scalaCheck % Test
val scalatestScalacheck = "org.scalatestplus" %% "scalacheck-1-15" % Version.scalaTestScalaCheck % Test
val akka = List("actor", "stream").map(module => "com.typesafe.akka" %% s"akka-$module" % Version.akka)
val zio = List("dev.zio" %% "zio" % Version.zio, "dev.zio" %% "zio-interop-cats" % Version.zioCats)
val tethys = List("core", "jackson").map(module => "com.tethys-json" %% s"tethys-$module" % Version.tethys)
val reflect = libraryDependencies += scalaOrganization.value % "scala-reflect" % scalaVersion.value
val compiler = libraryDependencies += scalaOrganization.value % "scala-compiler" % scalaVersion.value
val collectionCompat = libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "2.6.0"
val enumeratumCirce = "com.beachape" %% "enumeratum-circe" % Version.enumeratumCirce
val typesafeConfig = "com.typesafe" % "config" % Version.typesafeConfig
val swaggerUIVersion = SettingKey[String]("swaggerUIVersion")
lazy val testLibs = libraryDependencies ++= scalatest :: scalacheck :: scalatestScalacheck :: Nil
lazy val commonSettings = publishSettings ++ List(
scalaVersion := scala213V,
collectionCompat,
compilerPlugins,
commonScalacOptions,
specificScalacOptions,
crossCompile,
setMinorVersion,
testLibs,
)
lazy val kernel = project
.in(file("modules/kernel"))
.settings(
commonSettings,
moduleName := "typed-schema-typedsl",
libraryDependencies ++= catsCore :: shapeless :: enumeratum :: Nil
)
lazy val param = project
.in(file("modules/param"))
.dependsOn(kernel)
.settings(
commonSettings,
moduleName := "typed-schema-param",
libraryDependencies += derevo,
magnolia,
paradise,
)
lazy val macros = project
.in(file("modules/macros"))
.dependsOn(kernel)
.settings(
commonSettings,
moduleName := "typed-schema-macros",
libraryDependencies ++= shapeless :: catsCore :: akkaHttpTestKit :: Nil,
reflect
)
lazy val swagger = project
.in(file("modules/swagger"))
.dependsOn(kernel, macros)
.settings(
commonSettings,
moduleName := "typed-schema-swagger",
libraryDependencies ++= enumeratum :: derevo :: enumeratumCirce :: Nil,
magnolia,
tofuOptics,
paradise,
circe,
)
lazy val akkaHttp = project
.in(file("modules/akkaHttp"))
.dependsOn(kernel, macros, param)
.settings(
commonSettings,
moduleName := "typed-schema-akka-http",
libraryDependencies ++= akkaHttpLib :: akkaTestKit :: akkaHttpTestKit :: akka,
akkaHttpCirce
)
lazy val finagle = project
.in(file("modules/finagle"))
.dependsOn(kernel, macros, param)
.settings(
commonSettings,
moduleName := "typed-schema-finagle",
libraryDependencies ++= finagleHttp :: catsEffect :: catsFree :: Nil
)
lazy val finagleCirce = project
.in(file("modules/finagleCirce"))
.dependsOn(finagle)
.settings(
commonSettings,
moduleName := "typed-schema-finagle-circe",
circe
)
lazy val finagleTethys = project
.in(file("modules/finagleTethys"))
.dependsOn(finagle)
.settings(
commonSettings,
moduleName := "typed-schema-finagle-tethys",
libraryDependencies ++= tethys
)
lazy val finagleCustom = project
.in(file("modules/finagleCustom"))
.dependsOn(finagleCirce, finagleTethys, swagger)
.settings(
commonSettings,
moduleName := "typed-schema-finagle-custom",
libraryDependencies += derevo
)
lazy val finagleZio = project
.in(file("modules/finagle-zio"))
.dependsOn(finagle)
.settings(
commonSettings,
moduleName := "typed-schema-finagle-zio",
libraryDependencies ++= catsEffect :: zio
)
lazy val finagleCommon = project
.in(file("modules/finagle-common"))
.dependsOn(finagle, swagger)
.settings(
commonSettings,
moduleName := "typed-schema-finagle-common"
)
lazy val finagleEnv = project
.in(file("modules/finagle-env"))
.dependsOn(finagle)
.settings(
commonSettings,
moduleName := "typed-schema-finagle-env",
libraryDependencies ++= catsEffect :: env :: Nil
)
lazy val main = project
.in(file("modules/main"))
.dependsOn(kernel, macros, swagger, akkaHttp)
.settings(
commonSettings,
moduleName := "typed-schema-base",
libraryDependencies ++= akkaHttpLib :: akkaHttpTestKit :: akkaTestKit :: akka
)
lazy val swaggerUI =
(project in file("modules/swaggerUI"))
.dependsOn(swagger)
.enablePlugins(BuildInfoPlugin)
.settings(
commonSettings,
moduleName := "typed-schema-swagger-ui",
libraryDependencies ++= swaggerUILib :: scalaTags :: Nil,
swaggerUIVersion := {
libraryDependencies.value
.find(_.name == "swagger-ui-dist")
.map(_.revision)
.get
},
buildInfoKeys := swaggerUIVersion :: Nil,
buildInfoPackage := "ru.tinkoff.tschema.swagger"
)
lazy val swaggerTypesafe = project
.in(file("modules/swaggerTypesafe"))
.dependsOn(kernel, swagger)
.settings(
commonSettings,
paradise,
moduleName := "typed-schema-swagger-typesafe",
libraryDependencies += typesafeConfig,
)
lazy val swaggerTypesafeCheck = project
.in(file("modules/swaggerTypesafeCheck"))
.dependsOn(swaggerTypesafe)
.settings(
commonSettings,
paradise,
moduleName := "typed-schema-swagger-typesafe-check"
)
lazy val typedschema =
(project in file("."))
.dependsOn(macros, kernel, main)
.settings(
publish / skip := true,
scalaVersion := scala213V,
publishSettings,
setMinorVersion,
crossCompile
)
.aggregate(
macros,
kernel,
main,
param,
swagger,
swaggerTypesafe,
swaggerTypesafeCheck,
akkaHttp,
finagle,
finagleZio,
finagleEnv,
finagleCirce,
finagleTethys,
finagleCommon,
finagleCustom,
swaggerUI,
)
addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt")
addCommandAlias("checkfmt", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck")