forked from tofu-tf/typed-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
351 lines (306 loc) · 10.9 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
import com.typesafe.sbt.SbtGit.git
val pubVersion = "0.12.5.1"
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 += Credentials(Path.userHome / ".sbt" / ".ossrh-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"
)
)
)
licenses in ThisBuild += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))
publishMavenStyle in ThisBuild := true
homepage in ThisBuild := Some(url("https://github.com/TinkoffCreditSystems/typed-schema"))
developers in ThisBuild := List(
Developer("odomontois", "Oleg Nizhnik", "odomontois@gmail.com", url("https://github.com/odomontois"))
)
val minorVersion = SettingKey[Int]("minor scala version")
val crossCompile = crossScalaVersions := List("2.13.2", "2.12.11")
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),
compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"),
)
val paradise = libraryDependencies ++= {
minorVersion.value match {
case 12 => List(compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch))
case 13 => List()
}
}
val magnolia = libraryDependencies += "com.propensive" %% "magnolia" % Version.magnolia
val tofuOptics =
libraryDependencies ++= List("core", "macro").map(module => "ru.tinkoff" %% 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 scalatags = libraryDependencies += "com.lihaoyi" %% "scalatags" % Version.scalaTags
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 simulacrum = "org.typelevel" %% "simulacrum" % Version.simulacrum
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 = "org.manatki" %% "derevo-cats" % Version.derevo
val swaggerUILib = "org.webjars.npm" % "swagger-ui-dist" % Version.swaggerUI
val scalaTags = "com.lihaoyi" %% "scalatags" % Version.scalaTags
val env = "ru.tinkoff" %% "tofu-env" % Version.tofu
val scalatest = "org.scalatest" %% "scalatest" % Version.scalaTest % Test
val scalacheck = "org.scalacheck" %% "scalacheck" % Version.scalaCheck % Test
val scalatestScalacheck = "org.scalatestplus" %% "scalatestplus-scalacheck" % 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.2.0"
val enumeratumCirce = "com.beachape" %% "enumeratum-circe" % Version.enumeratumCirce
def resourcesOnCompilerCp(config: Configuration): Setting[_] =
managedClasspath in config := {
val res = (resourceDirectory in config).value
val old = (managedClasspath in config).value
Attributed.blank(res) +: old
}
val swaggerUIVersion = SettingKey[String]("swaggerUIVersion")
lazy val testLibs = libraryDependencies ++= scalatest :: scalacheck :: scalatestScalacheck :: Nil
lazy val commonSettings = publishSettings ++ List(
scalaVersion := "2.13.2",
collectionCompat,
compilerPlugins,
commonScalacOptions,
specificScalacOptions,
crossCompile,
setMinorVersion,
testLibs,
)
lazy val simulacrumSettings = Seq(
libraryDependencies ++= Seq(
scalaOrganization.value % "scala-reflect" % scalaVersion.value % Provided,
simulacrum % Provided
),
pomPostProcess := { node =>
import scala.xml.transform.{RewriteRule, RuleTransformer}
new RuleTransformer(new RewriteRule {
override def transform(node: xml.Node): Seq[xml.Node] = node match {
case e: xml.Elem
if e.label == "dependency" &&
e.child.exists(child => child.label == "groupId" && child.text == simulacrum.organization) &&
e.child.exists(child => child.label == "artifactId" && child.text.startsWith(s"${simulacrum.name}_")) =>
Nil
case _ => Seq(node)
}
}).transform(node).head
}
)
lazy val kernel = project
.in(file("modules/kernel"))
.settings(
commonSettings,
simulacrumSettings,
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,
simulacrumSettings,
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 :: Nil,
swaggerUIVersion := {
libraryDependencies.value
.find(_.name == "swagger-ui-dist")
.map(_.revision)
.get
},
scalatags,
buildInfoKeys := swaggerUIVersion :: Nil,
buildInfoPackage := "ru.tinkoff.tschema.swagger"
)
lazy val docs = project
.in(file("modules/docs"))
.enablePlugins(ScalaUnidocPlugin)
.settings(
scalaVersion := "2.13.2",
publish / skip := true,
crossCompile,
setMinorVersion,
unidocProjectFilter in (ScalaUnidoc, unidoc) := inProjects(main, kernel, swagger, akkaHttp)
)
.dependsOn(kernel, macros, main, akkaHttp)
lazy val typedschema =
(project in file("."))
.dependsOn(macros, kernel, main)
.settings(
publish / skip := true,
scalaVersion := "2.13.2",
publishSettings,
setMinorVersion,
crossCompile
)
.aggregate(
macros,
kernel,
main,
param,
swagger,
akkaHttp,
finagle,
finagleZio,
finagleEnv,
finagleCirce,
finagleTethys,
finagleCommon,
finagleCustom,
swaggerUI,
docs
)
addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt")
addCommandAlias("checkfmt", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck")