forked from zio/zio-protoquill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
385 lines (347 loc) · 14.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
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
import ReleaseTransformations._
//import com.typesafe.sbt.SbtScalariform.ScalariformKeys
//import scalariform.formatter.preferences._
import com.jsuereth.sbtpgp.PgpKeys.publishSigned
import sbtrelease.ReleasePlugin
import scala.sys.process.Process
import java.io.{File => JFile}
ThisBuild / versionScheme := Some("always")
addCommandAlias("runCommunityBuild", "; quill-sql/test; quill-sql-tests/test; quill-cassandra/Test/compile")
// During release cycles, GPG will expect passphrase user-input EVEN when --passphrase is specified
// this should add --pinentry-loopback in order to disable that. See here for more info:
// https://github.com/sbt/sbt-pgp/issues/178
Global / useGpgPinentry := true
releaseVersion := { ver =>
println(s"=== Releasing on initially specified version: ${ver}")
ver
}
releaseNextVersion := { ver =>
val withoutLast = ver.reverse.dropWhile(_.isDigit).reverse
val last = ver.reverse.takeWhile(_.isDigit).reverse
println(s"=== Detected original version: ${ver}. Which is ${withoutLast} + ${last}")
// see if the last group of chars are numeric, if they are, just increment
val actualLast = scala.util.Try(last.toInt).map(i => (i + 1).toString).getOrElse(last)
val newVer = withoutLast + actualLast + "-SNAPSHOT"
println(s"=== Final computed version is: ${newVer}")
newVer
}
val isCommunityBuild =
sys.props.getOrElse("community", "false").toBoolean
val isCommunityRemoteBuild =
sys.props.getOrElse("communityRemote", "false").toBoolean
lazy val scalatestVersion =
if (isCommunityRemoteBuild) "3.2.7" else "3.2.9"
lazy val baseModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](
`quill-sql`
)
lazy val sqlTestModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](
`quill-sql-tests`
)
lazy val dbModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](
`quill-jdbc`, `quill-zio`, `quill-jdbc-zio`, `quill-caliban`
)
lazy val jasyncModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](
`quill-jasync`, `quill-jasync-postgres`
)
lazy val bigdataModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](
`quill-cassandra`, `quill-cassandra-zio`
)
lazy val allModules =
baseModules ++ sqlTestModules ++ dbModules ++ jasyncModules ++ bigdataModules
lazy val communityBuildModules =
Seq[sbt.ClasspathDep[sbt.ProjectReference]](
`quill-sql`, `quill-sql-tests`, `quill-cassandra`
)
val filteredModules = {
val modulesStr = sys.props.get("modules")
println(s"SBT =:> Modules Argument Value: ${modulesStr}. community=${isCommunityBuild}, communityRemote=${isCommunityRemoteBuild}")
val selectedModules = modulesStr match {
case _ if (isCommunityBuild) =>
println("SBT =:> Doing Community Build! Filtering Community-Build Modules Only")
communityBuildModules
case Some("base") =>
println("SBT =:> Compiling Base Modules")
baseModules
case Some("sqltest") =>
println("SBT =:> Compiling SQL test Modules")
sqlTestModules
case Some("db") =>
println("SBT =:> Compiling Database Modules")
dbModules
case Some("async") =>
println("SBT =:> Compiling Async Database Modules")
jasyncModules
case Some("bigdata") =>
println("SBT =:> Compiling Big Data Modules")
bigdataModules
case Some("none") =>
println("SBT =:> Invoking Aggregate Project")
Seq[sbt.ClasspathDep[sbt.ProjectReference]]()
case _ =>
println("SBT =:> No Modules Switch Specified, Compiling All Modules by Default")
allModules
}
println(s"=== Selected Modules ===\n${selectedModules.map(_.project.toString).toList.mkString("\n")}\n=== End Selected Modules ===")
selectedModules
}
lazy val `quill` = {
(project in file("."))
.settings(commonSettings: _*)
// Unless release settings bubbled up here, they won't actually be used for the project
// release. E.g. if you don't want to run tests on a release (i.e. if they were run on a previous step)
// and release-settings here are not included tests will still be run etc...
.settings(releaseSettings: _*)
.aggregate(filteredModules.map(_.project): _*)
.dependsOn(filteredModules: _*)
.settings(
publishArtifact := false,
publish / skip := true,
publishLocal / skip := true,
publishSigned / skip := true,
)
}
lazy val `quill-sql` =
(project in file("quill-sql"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
resolvers ++= Seq(
Resolver.mavenLocal,
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
"Sonatype OSS Releases" at "https://oss.sonatype.org/content/repositories/releases"
),
excludeDependencies ++= Seq(
"com.typesafe.scala-logging" % "scala-logging_2.13"
),
libraryDependencies ++= Seq(
// Needs to be in-sync with both quill-engine and scalafmt-core or ClassNotFound
// errors will happen. Even if the pprint classes are actually there
("com.lihaoyi" %% "pprint" % "0.6.6"),
"io.getquill" %% "quill-engine" % "3.16.0",
("io.getquill" %% "quill-util" % "3.16.0")
.excludeAll({
if (isCommunityBuild)
Seq(ExclusionRule(organization = "org.scalameta", name = "scalafmt-core_2.13"))
else
Seq()
}: _*),
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.4",
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.scalatest" %% "scalatest-mustmatchers" % scalatestVersion % Test,
"com.vladsch.flexmark" % "flexmark-all" % "0.35.10" % Test
)//,
//Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oGF")
)
// Moving heavy tests to separate module so it can be compiled in parallel with others
lazy val `quill-sql-tests` =
(project in file("quill-sql-tests"))
.settings(commonSettings: _*)
.dependsOn(`quill-sql` % "compile->compile;test->test")
//lazy val `quill-sql-all` = (project in file(".")).aggregate(`quill-sql`, `quill-sql-tests`)
lazy val `quill-jdbc` =
(project in file("quill-jdbc"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(jdbcTestingSettings: _*)
.dependsOn(`quill-sql` % "compile->compile;test->test")
lazy val `quill-jasync` =
(project in file("quill-jasync"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.github.jasync-sql" % "jasync-common" % "1.1.4"
)
)
.dependsOn(`quill-sql` % "compile->compile;test->test")
lazy val `quill-jasync-postgres` =
(project in file("quill-jasync-postgres"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.github.jasync-sql" % "jasync-postgresql" % "1.1.4"
)
)
.dependsOn(`quill-jasync` % "compile->compile;test->test")
lazy val `quill-caliban` =
(project in file("quill-caliban"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.github.ghostdogpr" %% "caliban" % "1.2.4",
"com.github.ghostdogpr" %% "caliban-zio-http" % "1.2.4",
// Adding this to main dependencies would force users to use logback-classic for SLF4j unless the specifically remove it
// seems to be safer to just exclude & add a commented about need for a SLF4j implementation in Docs.
"ch.qos.logback" % "logback-classic" % "1.2.3" % Test,
"io.d11" %% "zhttp" % "1.0.0.0-RC17" % Test,
// Don't want to make this dependant on zio-test for the testing code so importing this here separately
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.scalatest" %% "scalatest-mustmatchers" % scalatestVersion % Test,
"org.postgresql" % "postgresql" % "42.2.18" % Test,
)
)
.dependsOn(`quill-jdbc-zio` % "compile->compile")
lazy val `quill-zio` =
(project in file("quill-zio"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % "1.0.12",
"dev.zio" %% "zio-streams" % "1.0.12"
)
)
.dependsOn(`quill-sql` % "compile->compile;test->test")
lazy val `quill-jdbc-zio` =
(project in file("quill-jdbc-zio"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(jdbcTestingLibraries: _*)
.settings(
Test / runMain / fork := true,
Test / fork := true,
Test / testGrouping := {
(Test / definedTests).value map { test =>
if (test.name endsWith "IntegrationSpec")
Tests.Group(name = test.name, tests = Seq(test), runPolicy = Tests.SubProcess(
ForkOptions().withRunJVMOptions(Vector("-Xmx200m"))
))
else
Tests.Group(name = test.name, tests = Seq(test), runPolicy = Tests.SubProcess(ForkOptions()))
}
}
)
.dependsOn(`quill-zio` % "compile->compile;test->test")
.dependsOn(`quill-sql` % "compile->compile;test->test")
.dependsOn(`quill-jdbc` % "compile->compile;test->test")
lazy val `quill-cassandra` =
(project in file("quill-cassandra"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
Test / fork := false,
libraryDependencies ++= Seq(
"com.datastax.oss" % "java-driver-core" % "4.13.0"
)
)
.dependsOn(`quill-sql` % "compile->compile;test->test")
lazy val `quill-cassandra-zio` =
(project in file("quill-cassandra-zio"))
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.datastax.oss" % "java-driver-core" % "4.13.0",
"dev.zio" %% "zio" % "1.0.12",
"dev.zio" %% "zio-streams" % "1.0.12",
("dev.zio" %% "zio-interop-guava" % "30.1.0.3").excludeAll(ExclusionRule(organization = "dev.zio")).cross(CrossVersion.for3Use2_13)
)
)
.dependsOn(`quill-cassandra` % "compile->compile;test->test")
.dependsOn(`quill-zio` % "compile->compile;test->test")
// Include scalafmt formatter for pretty printing failed queries
val includeFormatter =
sys.props.getOrElse("formatScala", "false").toBoolean
lazy val commonSettings =
basicSettings ++
{
if (isCommunityRemoteBuild)
Seq(
Compile / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
)
else
Seq()
}
lazy val jdbcTestingLibraries = Seq(
libraryDependencies ++= Seq(
"com.zaxxer" % "HikariCP" % "3.4.5",
"mysql" % "mysql-connector-java" % "8.0.22" % Test,
"com.h2database" % "h2" % "1.4.200" % Test,
"org.postgresql" % "postgresql" % "42.2.18" % Test,
"org.xerial" % "sqlite-jdbc" % "3.32.3.2" % Test,
"com.microsoft.sqlserver" % "mssql-jdbc" % "7.1.1.jre8-preview" % Test,
"com.oracle.ojdbc" % "ojdbc8" % "19.3.0.0" % Test,
//"org.mockito" %% "mockito-scala-scalatest" % "1.16.2" % Test
)
)
lazy val jdbcTestingSettings = jdbcTestingLibraries ++ Seq(
Test / fork := true
)
lazy val basicSettings = Seq(
// ,
// ("org.scala-lang.modules" %% "scala-java8-compat" % "1.0.1")
libraryDependencies ++= Seq(
("org.scala-lang.modules" %% "scala-java8-compat" % "1.0.1")
),
excludeDependencies ++= Seq(
ExclusionRule("org.scala-lang.modules", "scala-collection-compat_2.13")
),
scalaVersion := {
if (isCommunityBuild) dottyLatestNightlyBuild().get else "3.0.2"
},
organization := "io.getquill",
// The -e option is the 'error' report of ScalaTest. We want it to only make a log
// of the failed tests once all tests are done, the regular -o log shows everything else.
// Test / testOptions ++= Seq(
// Tests.Argument(TestFrameworks.ScalaTest, "-oF")
// // /*, "-eGNCXEHLOPQRM"*/, "-h", "target/html", "-u", "target/junit"
// //Tests.Argument(TestFrameworks.ScalaTest, "-u", "junits")
// //Tests.Argument(TestFrameworks.ScalaTest, "-h", "testresults")
// ),
scalacOptions ++= Seq(
"-language:implicitConversions",
)
)
lazy val releaseSettings = ReleasePlugin.extraReleaseCommands ++ Seq(
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
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")
},
pgpSecretRing := file("local.secring.gpg"),
pgpPublicRing := file("local.pubring.gpg"),
releaseVersionBump := sbtrelease.Version.Bump.Next,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseProcess := {
Seq[ReleaseStep]() ++
doOnDefault(checkSnapshotDependencies) ++
doOnDefault(inquireVersions) ++
doOnDefault(runClean) ++
doOnPush (setReleaseVersion) ++
doOnPush (commitReleaseVersion) ++
doOnPush (tagRelease) ++
doOnDefault(publishArtifacts) ++
doOnPush (setNextVersion) ++
doOnPush (commitNextVersion) ++
//doOnPush(releaseStepCommand("sonatypeReleaseAll")) ++
doOnPush (pushChanges)
},
homepage := Some(url("http://github.com/getquill/protoquill")),
licenses := List(("Apache License 2.0", url("https://raw.githubusercontent.com/getquill/protoquill/master/LICENSE.txt"))),
developers := List(
Developer("deusaquilus", "Alexander Ioffe", "", url("https://github.com/deusaquilus"))
),
scmInfo := Some(
ScmInfo(url("https://github.com/getquill/protoquill"), "git:[email protected]:getquill/protoquill.git")
)
)
def doOnDefault(steps: ReleaseStep*): Seq[ReleaseStep] =
Seq[ReleaseStep](steps: _*)
def doOnPush(steps: ReleaseStep*): Seq[ReleaseStep] =
if (skipPush)
Seq[ReleaseStep]()
else
Seq[ReleaseStep](steps: _*)
val skipPush =
sys.props.getOrElse("skipPush", "false").toBoolean