forked from typelevel/doobie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
460 lines (413 loc) · 13.6 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
import UnidocKeys._
import FreeGen2._
import ReleaseTransformations._
/**
* This build now depends on partial unification, but this is slightly tricky. It's built into 2.12,
* but for 2.11 we need the Typelevel compiler, util 2.11.9 arrives. For 2.10 we need the plugin. In
* addition the cats/fs2 build isn't available for 2.10 because there's no fs2 for 2.10, so we need
* sbt-doge to support that. Whee.
*/
enablePlugins(CrossPerProjectPlugin)
lazy val buildSettings = Seq(
organization := "org.tpolecat",
licenses ++= Seq(("MIT", url("http://opensource.org/licenses/MIT"))),
scalaVersion := "2.12.1",
scalaOrganization := (if (scalaVersion.value startsWith "2.11") "org.typelevel" else "org.scala-lang"),
crossScalaVersions := Seq("2.11.8", scalaVersion.value)
)
lazy val scalazCrossSettings = Seq(
crossScalaVersions := "2.10.6" +: crossScalaVersions.value
)
lazy val commonSettings = Seq(
scalacOptions ++= Seq(
"-encoding", "UTF-8", // 2 args
"-feature",
"-deprecation",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-language:experimental.macros",
"-unchecked",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-value-discard"
) ++ (
if (scalaVersion.value.startsWith("2.12") ||
scalaVersion.value.startsWith("2.11")) Seq("-Ypartial-unification")
else Nil
),
scalacOptions in (Compile, doc) ++= Seq(
"-groups",
"-sourcepath", (baseDirectory in LocalRootProject).value.getAbsolutePath,
"-doc-source-url", "https://github.com/tpolecat/doobie/tree/v" + version.value + "€{FILE_PATH}.scala",
"-skip-packages", "scalaz"
),
libraryDependencies ++= macroParadise(scalaVersion.value) ++ Seq(
"org.scalacheck" %% "scalacheck" % "1.13.4" % "test",
"org.specs2" %% "specs2-core" % "3.8.6" % "test",
"org.specs2" %% "specs2-scalacheck" % "3.8.6" % "test"
) ++ (
if (scalaVersion.value startsWith "2.10") Seq(
compilerPlugin("com.milessabin" % "si2712fix-plugin_2.10.6" % "1.2.0")
)
else Nil
),
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.3")
)
lazy val publishSettings = Seq(
publishMavenStyle := true,
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
publishArtifact in Test := false,
homepage := Some(url("https://github.com/tpolecat/doobie")),
pomIncludeRepository := Function.const(false),
pomExtra := (
<scm>
<url>git@github.com:tpolecat/doobie.git</url>
<connection>scm:git:git@github.com:tpolecat/doobie.git</connection>
</scm>
<developers>
<developer>
<id>tpolecat</id>
<name>Rob Norris</name>
<url>http://tpolecat.org</url>
</developer>
</developers>
),
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
ReleaseStep(action = Command.process("package", _)),
setReleaseVersion,
commitReleaseVersion,
tagRelease,
ReleaseStep(action = Command.process("publishSigned", _)),
setNextVersion,
commitNextVersion,
ReleaseStep(action = Command.process("sonatypeReleaseAll", _)),
pushChanges),
mappings in (Compile, packageSrc) ++= (managedSources in Compile).value pair relativeTo(sourceManaged.value / "main" / "scala")
)
lazy val doobieSettings = buildSettings ++ commonSettings
lazy val doobie = project.in(file("."))
.settings(doobieSettings)
.settings(noPublishSettings)
.dependsOn(core, core_cats, h2, h2_cats, hikari, hikari_cats, postgres, postgres_cats, specs2, specs2_cats, example, example_cats, bench, bench_cats, scalatest, scalatest_cats, docs, docs_cats)
.aggregate(core, core_cats, h2, h2_cats, hikari, hikari_cats, postgres, postgres_cats, specs2, specs2_cats, example, example_cats, bench, bench_cats, scalatest, scalatest_cats, docs, docs_cats)
.settings(freeGen2Settings)
.settings(
freeGen2Dir := file("yax/core/src/main/scala/doobie/free2"),
freeGen2Classes := {
import java.sql._
List[Class[_]](
classOf[java.sql.NClob],
classOf[java.sql.Blob],
classOf[java.sql.Clob],
classOf[java.sql.DatabaseMetaData],
classOf[java.sql.Driver],
classOf[java.sql.Ref],
classOf[java.sql.SQLData],
classOf[java.sql.SQLInput],
classOf[java.sql.SQLOutput],
classOf[java.sql.Connection],
classOf[java.sql.Statement],
classOf[java.sql.PreparedStatement],
classOf[java.sql.CallableStatement],
classOf[java.sql.ResultSet]
)
}
)
lazy val noPublishSettings = Seq(
publish := (),
publishLocal := (),
publishArtifact := false
)
def macroParadise(v: String): List[ModuleID] =
if (v.startsWith("2.10")) List(compilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full))
else Nil
lazy val ctut = taskKey[Unit]("Copy tut output to blog repo nearby.")
///
/// CORE
///
def coreSettings(mod: String) =
doobieSettings ++
publishSettings ++ Seq(
name := "doobie-" + mod,
description := "Pure functional JDBC layer for Scala.",
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value, // required for shapeless macros
"com.chuusai" %% "shapeless" % "2.3.2",
"com.lihaoyi" %% "sourcecode" % "0.1.3"
),
scalacOptions += "-Yno-predef",
sourceGenerators in Compile += Def.task {
val outDir = (sourceManaged in Compile).value / "scala" / "doobie"
val outFile = new File(outDir, "buildinfo.scala")
outDir.mkdirs
val v = version.value
val t = System.currentTimeMillis
IO.write(outFile,
s"""|package doobie
|
|/** Auto-generated build information. */
|object buildinfo {
| /** Current version of doobie ($v). */
| val version = "$v"
| /** Build date (${new java.util.Date(t)}). */
| val date = new java.util.Date(${t}L)
|}
|""".stripMargin)
Seq(outFile)
}.taskValue
)
lazy val core = project.in(file("modules/core"))
.settings(
yax(file("yax/core"), "scalaz"),
coreSettings("core"),
libraryDependencies ++= Seq(
"org.scalaz" %% "scalaz-core" % "7.2.7",
"org.scalaz" %% "scalaz-effect" % "7.2.7",
"org.scalaz.stream" %% "scalaz-stream" % "0.8.6a",
"com.h2database" % "h2" % "1.4.193" % "test"
),
scalazCrossSettings
)
val catsVersion = "0.9.0"
lazy val core_cats = project.in(file("modules-cats/core"))
.settings(
yax(file("yax/core"), "cats", "fs2"),
coreSettings("core-cats"),
libraryDependencies ++= Seq(
"co.fs2" %% "fs2-core" % "0.9.2",
"co.fs2" %% "fs2-cats" % "0.3.0",
"org.typelevel" %% "cats-core" % catsVersion,
"org.typelevel" %% "cats-free" % catsVersion,
"org.typelevel" %% "cats-laws" % catsVersion % "test",
"com.h2database" % "h2" % "1.4.193" % "test"
)
)
///
/// EXAMPLE
///
lazy val example = project.in(file("modules/example"))
.settings(doobieSettings ++ noPublishSettings)
.settings(
yax(file("yax/example"), "scalaz"),
scalazCrossSettings
)
.dependsOn(core, postgres, specs2, scalatest, hikari, h2)
lazy val example_cats = project.in(file("modules-cats/example"))
.settings(doobieSettings ++ noPublishSettings)
.settings(yax(file("yax/example"), "cats", "fs2"))
.dependsOn(core_cats, postgres_cats, specs2_cats, scalatest_cats, hikari_cats, h2_cats)
///
/// POSTGRES
///
val postgisDep = "net.postgis" % "postgis-jdbc" % "2.2.1"
def postgresSettings(mod: String): Seq[Setting[_]] =
doobieSettings ++
publishSettings ++ Seq(
name := "doobie-" + mod,
description := "Postgres support for doobie.",
libraryDependencies ++= Seq(
"org.postgresql" % "postgresql" % "9.4.1211",
postgisDep % "provided"
),
initialCommands := """
import doobie.imports._
import doobie.postgres.imports._
val xa = DriverManagerTransactor[IOLite]("org.postgresql.Driver", "jdbc:postgresql:world", "postgres", "")
import xa.yolo._
import org.postgis._
import org.postgresql.util._
import org.postgresql.geometric._
"""
)
lazy val postgres = project.in(file("modules/postgres"))
.settings(
yax(file("yax/postgres"), "scalaz"),
postgresSettings("postgres"),
scalazCrossSettings
)
.dependsOn(core)
lazy val postgres_cats = project.in(file("modules-cats/postgres"))
.settings(
yax(file("yax/postgres"), "cats", "fs2"),
postgresSettings("postgres-cats")
)
.dependsOn(core_cats)
///
/// H2
///
def h2Settings(mod: String): Seq[Setting[_]] =
doobieSettings ++
publishSettings ++ Seq(
name := "doobie-" + mod,
description := "H2 support for doobie.",
libraryDependencies += "com.h2database" % "h2" % "1.4.193"
)
lazy val h2 = project.in(file("modules/h2"))
.settings(
yax(file("yax/h2"), "scalaz"),
h2Settings("h2"),
scalazCrossSettings
)
.dependsOn(core)
lazy val h2_cats = project.in(file("modules-cats/h2"))
.settings(
yax(file("yax/h2"), "cats", "fs2"),
h2Settings("h2-cats")
)
.dependsOn(core_cats)
///
/// HIKARI
///
def hikariSettings(mod: String): Seq[Setting[_]] =
doobieSettings ++
publishSettings ++ Seq(
name := "doobie-" + mod,
description := "Hikari support for doobie.",
libraryDependencies += "com.zaxxer" % "HikariCP" % "2.5.1"
)
lazy val hikari = project.in(file("modules/hikari"))
.settings(
yax(file("yax/hikari"), "scalaz"),
hikariSettings("hikari"),
scalazCrossSettings
)
.dependsOn(core)
lazy val hikari_cats = project.in(file("modules-cats/hikari"))
.settings(
yax(file("yax/hikari"), "cats", "fs2"),
hikariSettings("hikari-cats")
)
.dependsOn(core_cats)
///
/// SPECS2
///
def specs2Settings(mod: String): Seq[Setting[_]] =
doobieSettings ++
publishSettings ++ Seq(
name := s"doobie-$mod",
description := "Specs2 support for doobie.",
libraryDependencies += "org.specs2" %% "specs2-core" % "3.8.4"
)
lazy val specs2 = project.in(file("modules/specs2"))
.settings(
yax(file("yax/specs2"), "scalaz"),
specs2Settings("specs2"),
scalazCrossSettings
)
.dependsOn(core)
lazy val specs2_cats = project.in(file("modules-cats/specs2"))
.settings(
yax(file("yax/specs2"), "cats", "fs2"),
specs2Settings("specs2-cats")
)
.dependsOn(core_cats)
///
/// SCALATEST
///
def scalaTestSettings(mod: String): Seq[Setting[_]] =
doobieSettings ++
publishSettings ++ Seq(
name := s"doobie-$mod",
description := "Scalatest support for doobie.",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0"
)
lazy val scalatest = project.in(file("modules/scalatest"))
.settings(
yax(file("yax/scalatest"), "scalaz"),
scalaTestSettings("scalatest"),
scalazCrossSettings
)
.dependsOn(core)
lazy val scalatest_cats = project.in(file("modules-cats/scalatest"))
.settings(
yax(file("yax/scalatest"), "cats", "fs2"),
scalaTestSettings("scalatest-cats")
)
.dependsOn(core_cats)
///
/// BENCH
///
lazy val bench = project.in(file("modules/bench"))
.settings(doobieSettings ++ noPublishSettings)
.settings(
yax(file("yax/bench"), "scalaz"),
scalazCrossSettings
)
.dependsOn(core, postgres)
lazy val bench_cats = project.in(file("modules-cats/bench"))
.settings(doobieSettings ++ noPublishSettings)
.settings(yax(file("yax/bench"), "cats", "fs2"))
.dependsOn(core_cats, postgres_cats)
///
/// DOCS
///
val circeVersion = "0.7.0"
def docsSettings(token: String, tokens: String*): Seq[Setting[_]] =
doobieSettings ++
noPublishSettings ++
tutSettings ++ Seq(
libraryDependencies ++= Seq(
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion,
"io.argonaut" %% "argonaut" % "6.2-RC1"
),
ctut := {
val src = crossTarget.value / "tut"
val dst = file("../tpolecat.github.io/_doobie-" + token + "-" + version.value + "/")
if (!src.isDirectory) {
println("Input directory " + src + " not found.")
} else if (!dst.isDirectory) {
println("Output directory " + dst + " not found.")
} else {
println("Copying to " + dst.getPath)
val map = src.listFiles.filter(_.getName.endsWith(".md")).map(f => (f, new File(dst, f.getName)))
IO.copy(map, overwrite = true, preserveLastModified = false)
}
},
tutSourceDirectory := sourceManaged.value / "main" / "tut",
tutPluginJars := {
// piggyback on a task tut depends on, so yax runs first
yax.walk(file("yax/docs/src/main/tut"), sourceManaged.value / "main", tokens.toSet + token)
tutPluginJars.value
},
fork in Test := true,
// postgis is `provided` dependency for users, and section from book of doobie needs it
libraryDependencies += postgisDep
)
lazy val docs = project.in(file("modules/docs"))
.settings(
docsSettings("scalaz"),
scalazCrossSettings
)
.dependsOn(
core,
postgres,
specs2,
hikari,
h2,
scalatest
)
lazy val docs_cats = project.in(file("modules-cats/docs"))
.settings(docsSettings("cats", "fs2"))
.dependsOn(
core_cats,
postgres_cats,
specs2_cats,
hikari_cats,
h2_cats,
scalatest_cats
)