forked from zio/zio-protoquill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
310 lines (278 loc) · 11.4 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
import com.jsuereth.sbtpgp.PgpKeys.publishSigned
Global / onChangedBuildSource := ReloadOnSourceChanges
inThisBuild(
List(
organization := "io.getquill",
homepage := Some(url("https://zio.dev/zio-protoquill")),
licenses := List(("Apache License 2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))),
developers := List(
Developer("deusaquilus", "Alexander Ioffe", "", url("https://github.com/deusaquilus"))
),
scmInfo := Some(
ScmInfo(url("https://github.com/zio/zio-protoquill"), "git:git@github.com:zio/zio-protoquill.git")
),
versionScheme := Some("always"),
)
)
addCommandAlias("runCommunityBuild", "; quill-sql/test; quill-sql-tests/test; quill-cassandra/Test/compile")
addCommandAlias("fmt", "all scalafmt test:scalafmt")
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.17"
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-doobie`, `quill-zio`, `quill-jdbc-zio`, `quill-caliban`
)
lazy val bigdataModules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](
`quill-cassandra`, `quill-cassandra-zio`
)
lazy val allModules =
baseModules ++ sqlTestModules ++ dbModules ++ 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("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
}
val zioQuillVersion = "4.8.0"
lazy val `quill` =
(project in file("."))
.settings(commonSettings: _*)
.settings(
publishArtifact := false,
publish / skip := true,
publishLocal / skip := true,
publishSigned / skip := true,
crossScalaVersions := Nil, // https://www.scala-sbt.org/1.x/docs/Cross-Build.html#Cross+building+a+project+statefully
)
.aggregate(filteredModules.map(_.project): _*)
lazy val `quill-sql` =
(project in file("quill-sql"))
.settings(commonSettings: _*)
.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
"io.suzaku" %% "boopickle" % "1.4.0",
"com.lihaoyi" %% "pprint" % "0.8.1",
"ch.qos.logback" % "logback-classic" % "1.4.11" % Test,
"io.getquill" %% "quill-engine" % zioQuillVersion,
"dev.zio" %% "zio" % "2.0.18",
("io.getquill" %% "quill-util" % zioQuillVersion)
.excludeAll({
if (isCommunityBuild)
Seq(ExclusionRule(organization = "org.scalameta", name = "scalafmt-core_2.13"))
else
Seq.empty
}: _*),
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.scalatest" %% "scalatest-mustmatchers" % scalatestVersion % Test,
"com.vladsch.flexmark" % "flexmark-all" % "0.64.8" % Test
)
)
// 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(publish / skip := true)
.settings(commonSettings: _*)
.settings(
Test / testOptions += Tests.Argument("-oF")
)
.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(jdbcTestingSettings: _*)
.dependsOn(`quill-sql` % "compile->compile;test->test")
ThisBuild / libraryDependencySchemes += "org.typelevel" %% "cats-effect" % "always"
lazy val `quill-doobie` =
(project in file("quill-doobie"))
.settings(commonSettings: _*)
.settings(jdbcTestingSettings: _*)
.settings(
libraryDependencies ++= Seq(
"org.tpolecat" %% "doobie-core" % "1.0.0-RC2",
"org.tpolecat" %% "doobie-postgres" % "1.0.0-RC2" % Test
)
)
.dependsOn(`quill-jdbc` % "compile->compile;test->test")
lazy val `quill-caliban` =
(project in file("quill-caliban"))
.settings(commonSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.github.ghostdogpr" %% "caliban" % "2.0.2",
"com.github.ghostdogpr" %% "caliban-zio-http" % "2.0.2",
// 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.4.11" % Test,
"io.d11" %% "zhttp" % "2.0.0-RC11" % 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.6.0" % Test,
)
)
.dependsOn(`quill-jdbc-zio` % "compile->compile")
lazy val `quill-zio` =
(project in file("quill-zio"))
.settings(commonSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % "2.0.18",
"dev.zio" %% "zio-streams" % "2.0.18"
)
)
.dependsOn(`quill-sql` % "compile->compile;test->test")
lazy val `quill-jdbc-zio` =
(project in file("quill-jdbc-zio"))
.settings(commonSettings: _*)
.settings(jdbcTestingLibraries: _*)
.settings(
libraryDependencies ++= Seq(
// Needed for PGObject in JsonExtensions but not necessary if user is not using postgres
"org.postgresql" % "postgresql" % "42.6.0" % "provided",
"dev.zio" %% "zio-json" % "0.6.2"
),
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(
Test / fork := false,
libraryDependencies ++= Seq(
"com.datastax.oss" % "java-driver-core" % "4.17.0"
)
)
.dependsOn(`quill-sql` % "compile->compile;test->test")
lazy val `quill-cassandra-zio` =
(project in file("quill-cassandra-zio"))
.settings(commonSettings: _*)
.settings(
Test / fork := true,
libraryDependencies ++= Seq(
"com.datastax.oss" % "java-driver-core" % "4.17.0",
"dev.zio" %% "zio" % "2.0.18",
"dev.zio" %% "zio-streams" % "2.0.18"
)
)
.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.empty
}
lazy val jdbcTestingLibraries = Seq(
// JDBC Libraries for testing of quill-jdbc___ contexts
libraryDependencies ++= Seq(
"com.zaxxer" % "HikariCP" % "5.0.1" exclude("org.slf4j", "*"),
// In 8.0.22 error happens: Conversion from java.time.OffsetDateTime to TIMESTAMP is not supported
"com.mysql" % "mysql-connector-j" % "8.1.0" % Test,
"com.h2database" % "h2" % "2.2.224" % Test,
// In 42.2.18 error happens: PSQLException: conversion to class java.time.OffsetTime from timetz not supported
"org.postgresql" % "postgresql" % "42.6.0" % Test,
"org.xerial" % "sqlite-jdbc" % "3.42.0.1" % Test,
// In 7.1.1-jre8-preview error happens: The conversion to class java.time.OffsetDateTime is unsupported.
"com.microsoft.sqlserver" % "mssql-jdbc" % "7.4.1.jre11" % 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(
Test / testOptions += Tests.Argument("-oI"),
libraryDependencies ++= Seq(
("org.scala-lang.modules" %% "scala-java8-compat" % "1.0.2")
),
excludeDependencies ++= Seq(
ExclusionRule("org.scala-lang.modules", "scala-collection-compat_2.13")
),
scalaVersion := "3.3.1",
// 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", "-explain",
// See https://docs.scala-lang.org/scala3/guides/migration/tooling-syntax-rewriting.html
"-no-indent",
"-release:11",
),
javacOptions := Seq("-source", "11", "-target", "11"),
)