forked from zio/zio-quill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
354 lines (322 loc) · 11.8 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
import ReleaseTransformations._
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
import scalariform.formatter.preferences._
import sbtrelease.ReleasePlugin
lazy val `quill` =
(project in file("."))
.settings(tutSettings ++ commonSettings)
.settings(`tut-settings`:_*)
.dependsOn(
`quill-core-jvm`, `quill-core-js`, `quill-sql-jvm`, `quill-sql-js`,
`quill-jdbc`, `quill-finagle-mysql`, `quill-finagle-postgres`, `quill-async`,
`quill-async-mysql`, `quill-async-postgres`, `quill-cassandra`, `quill-orientdb`
).aggregate(
`quill-core-jvm`, `quill-core-js`, `quill-sql-jvm`, `quill-sql-js`,
`quill-jdbc`, `quill-finagle-mysql`, `quill-finagle-postgres`, `quill-async`,
`quill-async-mysql`, `quill-async-postgres`, `quill-cassandra`, `quill-orientdb`
)
lazy val superPure = new org.scalajs.sbtplugin.cross.CrossType {
def projectDir(crossBase: File, projectType: String): File =
projectType match {
case "jvm" => crossBase
case "js" => crossBase / s".$projectType"
}
def sharedSrcDir(projectBase: File, conf: String): Option[File] =
Some(projectBase.getParentFile / "src" / conf / "scala")
}
lazy val `quill-core` =
crossProject.crossType(superPure)
.settings(commonSettings: _*)
.settings(mimaSettings: _*)
.settings(libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.3.2",
"com.typesafe.scala-logging" %% "scala-logging" % "3.7.2",
"org.scala-lang" % "scala-reflect" % scalaVersion.value
))
.jsSettings(
libraryDependencies += "org.scala-js" %%% "scalajs-java-time" % "0.2.2",
coverageExcludedPackages := ".*"
)
lazy val `quill-core-jvm` = `quill-core`.jvm
lazy val `quill-core-js` = `quill-core`.js
lazy val `quill-sql` =
crossProject.crossType(superPure)
.settings(commonSettings: _*)
.settings(mimaSettings: _*)
.jsSettings(
coverageExcludedPackages := ".*"
)
.dependsOn(`quill-core` % "compile->compile;test->test")
lazy val `quill-sql-jvm` = `quill-sql`.jvm
lazy val `quill-sql-js` = `quill-sql`.js
lazy val `quill-jdbc` =
(project in file("quill-jdbc"))
.settings(commonSettings: _*)
.settings(mimaSettings: _*)
.settings(
fork in Test := true,
libraryDependencies ++= Seq(
"com.zaxxer" % "HikariCP" % "2.7.2",
"mysql" % "mysql-connector-java" % "5.1.42" % Test,
"com.h2database" % "h2" % "1.4.196" % Test,
"org.postgresql" % "postgresql" % "42.1.4" % Test,
"org.xerial" % "sqlite-jdbc" % "3.18.0" % Test,
"com.microsoft.sqlserver" % "mssql-jdbc" % "6.1.7.jre8-preview" % Test
)
)
.dependsOn(`quill-sql-jvm` % "compile->compile;test->test")
lazy val `quill-finagle-mysql` =
(project in file("quill-finagle-mysql"))
.settings(commonSettings: _*)
.settings(mimaSettings: _*)
.settings(
fork in Test := true,
libraryDependencies ++= Seq(
"com.twitter" %% "finagle-mysql" % "7.1.0"
)
)
.dependsOn(`quill-sql-jvm` % "compile->compile;test->test")
lazy val `quill-finagle-postgres` =
(project in file("quill-finagle-postgres"))
.settings(commonSettings: _*)
.settings(mimaSettings: _*)
.settings(
fork in Test := true,
libraryDependencies ++= Seq(
"io.github.finagle" %% "finagle-postgres" % "0.4.3"
)
)
.dependsOn(`quill-sql-jvm` % "compile->compile;test->test")
lazy val `quill-async` =
(project in file("quill-async"))
.settings(commonSettings: _*)
.settings(mimaSettings: _*)
.settings(
fork in Test := true,
libraryDependencies ++= Seq(
"com.github.mauricio" %% "db-async-common" % "0.2.21"
)
)
.dependsOn(`quill-sql-jvm` % "compile->compile;test->test")
lazy val `quill-async-mysql` =
(project in file("quill-async-mysql"))
.settings(commonSettings: _*)
.settings(mimaSettings: _*)
.settings(
fork in Test := true,
libraryDependencies ++= Seq(
"com.github.mauricio" %% "mysql-async" % "0.2.21"
)
)
.dependsOn(`quill-async` % "compile->compile;test->test")
lazy val `quill-async-postgres` =
(project in file("quill-async-postgres"))
.settings(commonSettings: _*)
.settings(mimaSettings: _*)
.settings(
fork in Test := true,
libraryDependencies ++= Seq(
"com.github.mauricio" %% "postgresql-async" % "0.2.21"
)
)
.dependsOn(`quill-async` % "compile->compile;test->test")
lazy val `quill-cassandra` =
(project in file("quill-cassandra"))
.settings(commonSettings: _*)
.settings(mimaSettings: _*)
.settings(
fork in Test := true,
libraryDependencies ++= Seq(
"com.datastax.cassandra" % "cassandra-driver-core" % "3.3.0",
"io.monix" %% "monix" % "2.3.0"
)
)
.dependsOn(`quill-core-jvm` % "compile->compile;test->test")
lazy val `quill-orientdb` =
(project in file("quill-orientdb"))
.settings(commonSettings: _*)
.settings(mimaSettings: _*)
.settings(
fork in Test := true,
libraryDependencies ++= Seq(
"com.orientechnologies" % "orientdb-graphdb" % "2.2.29"
)
)
.dependsOn(`quill-sql-jvm` % "compile->compile;test->test")
lazy val `tut-sources` = Seq(
"CASSANDRA.md",
"README.md"
)
lazy val `tut-settings` = Seq(
tutScalacOptions := Seq(),
tutSourceDirectory := baseDirectory.value / "target" / "tut",
tutNameFilter := `tut-sources`.map(_.replaceAll("""\.""", """\.""")).mkString("(", "|", ")").r,
sourceGenerators in Compile +=
Def.task {
`tut-sources`.foreach { name =>
val source = baseDirectory.value / name
val file = baseDirectory.value / "target" / "tut" / name
val str = IO.read(source).replace("```scala", "```tut")
IO.write(file, str)
}
Seq()
}.taskValue
)
lazy val mimaSettings = MimaPlugin.mimaDefaultSettings ++ Seq(
mimaPreviousArtifacts := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor <= 11 =>
Set(organization.value % s"${name.value}_${scalaBinaryVersion.value}" % "0.5.0")
case _ =>
Set()
}
}
)
commands += Command.command("checkUnformattedFiles") { st =>
val vcs = Project.extract(st).get(releaseVcs).get
val modified = vcs.cmd("ls-files", "--modified", "--exclude-standard").!!.trim.split('\n').filter(_.contains(".scala"))
if(modified.nonEmpty)
throw new IllegalStateException(s"Please run `sbt scalariformFormat test:scalariformFormat` and resubmit your pull request. Found unformatted files: ${modified.toList}")
st
}
def updateReadmeVersion(selectVersion: sbtrelease.Versions => String) =
ReleaseStep(action = st => {
val newVersion = selectVersion(st.get(ReleaseKeys.versions).get)
import scala.io.Source
import java.io.PrintWriter
val pattern = """"io.getquill" %% "quill-.*" % "(.*)"""".r
val fileName = "README.md"
val content = Source.fromFile(fileName).getLines.mkString("\n")
val newContent =
pattern.replaceAllIn(content,
m => m.matched.replaceAllLiterally(m.subgroups.head, newVersion))
new PrintWriter(fileName) { write(newContent); close }
val vcs = Project.extract(st).get(releaseVcs).get
vcs.add(fileName).!
st
})
def updateWebsiteTag =
ReleaseStep(action = st => {
val vcs = Project.extract(st).get(releaseVcs).get
vcs.tag("website", "update website", force = true).!
st
})
lazy val commonSettings = ReleasePlugin.extraReleaseCommands ++ Seq(
organization := "io.getquill",
scalaVersion := "2.11.11",
crossScalaVersions := Seq("2.11.11","2.12.4"),
libraryDependencies ++= Seq(
"org.scalamacros" %% "resetallattrs" % "1.0.0",
"org.scalatest" %%% "scalatest" % "3.0.4" % Test,
"ch.qos.logback" % "logback-classic" % "1.2.3" % Test,
"com.google.code.findbugs" % "jsr305" % "3.0.2" % Provided // just to avoid warnings during compilation
),
EclipseKeys.createSrc := EclipseCreateSrc.Default,
unmanagedClasspath in Test ++= Seq(
baseDirectory.value / "src" / "test" / "resources"
),
EclipseKeys.eclipseOutput := Some("bin"),
scalacOptions ++= Seq(
"-Xfatal-warnings",
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-unchecked",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfuture"
),
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => Seq("-Xlint", "-Ywarn-unused-import")
case Some((2, 12)) => Seq("-Xlint:-unused,_", "-Ywarn-unused:imports")
case _ => Seq()
}
},
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1),
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
scoverage.ScoverageKeys.coverageMinimum := 96,
scoverage.ScoverageKeys.coverageFailOnMinimum := false,
ScalariformKeys.preferences := ScalariformKeys.preferences.value
.setPreference(AlignParameters, true)
.setPreference(CompactStringConcatenation, false)
.setPreference(IndentPackageBlocks, true)
.setPreference(FormatXml, true)
.setPreference(PreserveSpaceBeforeArguments, false)
.setPreference(DoubleIndentClassDeclaration, false)
.setPreference(RewriteArrowSymbols, false)
.setPreference(AlignSingleLineCaseStatements, true)
.setPreference(AlignSingleLineCaseStatements.MaxArrowIndent, 40)
.setPreference(SpaceBeforeColon, false)
.setPreference(SpaceInsideBrackets, false)
.setPreference(SpaceInsideParentheses, false)
.setPreference(DanglingCloseParenthesis, Force)
.setPreference(IndentSpaces, 2)
.setPreference(IndentLocalDefs, false)
.setPreference(SpacesWithinPatternBinders, true)
.setPreference(SpacesAroundMultiImports, true),
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"),
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseProcess := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) =>
Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
setReleaseVersion,
updateReadmeVersion(_._1),
commitReleaseVersion,
updateWebsiteTag,
tagRelease,
publishArtifacts,
setNextVersion,
updateReadmeVersion(_._2),
commitNextVersion,
ReleaseStep(action = Command.process("sonatypeReleaseAll", _)),
pushChanges
)
case Some((2, 12)) =>
Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
setReleaseVersion,
publishArtifacts,
ReleaseStep(action = Command.process("sonatypeReleaseAll", _))
)
case _ => Seq[ReleaseStep]()
}
},
pomExtra := (
<url>http://github.com/getquill/quill</url>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>https://raw.githubusercontent.com/getquill/quill/master/LICENSE.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git@github.com:getquill/quill.git</url>
<connection>scm:git:git@github.com:getquill/quill.git</connection>
</scm>
<developers>
<developer>
<id>fwbrasil</id>
<name>Flavio W. Brasil</name>
<url>http://github.com/fwbrasil/</url>
</developer>
</developers>)
)