forked from postgresql-async/postgresql-async
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
157 lines (144 loc) · 4.65 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
import ReleaseTransformations._
val commonName = "db-async-common"
val postgresqlName = "postgresql-async"
val mysqlName = "mysql-async"
val nettyVersion = "4.1.75.Final"
def testDependency(scalaVersion: String) = {
Seq(
"org.scalatest" %% "scalatest" % "3.2.11" % Test,
"org.mockito" % "mockito-core" % "4.4.0" % Test,
"org.slf4j" % "slf4j-simple" % "1.7.36" % Test
)
}
def scalaVersionSpecificFolders(
srcName: String,
srcBaseDir: java.io.File,
scalaVersion: String
) = {
def extraDirs(suffix: String) =
srcBaseDir / "src" / srcName / s"scala${suffix}"
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, y)) =>
val shared2x = extraDirs("-2.x")
val extra = if (y >= 13) extraDirs("-2.13+") else extraDirs("-2.13-")
Seq(shared2x, extra)
case Some((0 | 3, _)) => Seq(extraDirs("-2.13+"), extraDirs("-3.x"))
case _ => Nil
}
}
lazy val root = (project in file("."))
.settings(baseSettings: _*)
.settings(
name := "db-async-base",
publish := {},
publishLocal := {},
publishArtifact := false
)
.aggregate(common, postgresql, mysql)
lazy val common = (project in file("db-async-common"))
.settings(
name := commonName,
libraryDependencies ++= commonDependencies(scalaVersion.value)
)
.settings(baseSettings: _*)
lazy val postgresql = (project in file("postgresql-async"))
.settings(baseSettings: _*)
.settings(
name := postgresqlName
)
.dependsOn(common % "compile->compile;test->test")
lazy val mysql = (project in file("mysql-async"))
.settings(baseSettings: _*)
.settings(
name := mysqlName
)
.dependsOn(common % "compile->compile;test->test")
def commonDependencies(scalaVersion: String) = Seq(
"org.slf4j" % "slf4j-api" % "1.7.36",
"joda-time" % "joda-time" % "2.10.13",
"org.joda" % "joda-convert" % "2.2.2",
"io.netty" % "netty-codec" % nettyVersion,
"io.netty" % "netty-handler" % nettyVersion,
"org.javassist" % "javassist" % "3.28.0-GA",
"org.scala-lang.modules" %% "scala-collection-compat" % "2.7.0",
"com.google.code.findbugs" % "jsr305" % "3.0.2" % Provided
) ++ testDependency(scalaVersion)
def scalacOpts(v: String): Seq[String] = {
val base = Opts.compile.encoding(
"UTF8"
) :+ Opts.compile.deprecation :+ Opts.compile.unchecked :+ "-feature"
if (v.startsWith("3.")) {
base
} else if (v.startsWith("2.11")) {
base ++ Seq(
"-Xmax-classfile-name",
"78",
"-Xsource:3",
"-Ydelambdafy:method"
)
} else { // 2.12.x & 2.13.x
base ++ Seq(
Opts.compile.deprecation,
Opts.compile.unchecked,
"-Xsource:3"
)
}
}
val baseSettings = Seq(
crossScalaVersions := Seq("2.11.12", "2.12.15", "2.13.8", "3.1.1"),
(Test / fork) := true,
scalaVersion := "2.13.8",
scalacOptions := scalacOpts(scalaVersion.value),
(doc / scalacOptions) := Seq(
s"-doc-external-doc:scala=https://www.scala-lang.org/files/archive/api/${scalaVersion.value}/"
),
javacOptions := Seq("-source", "1.8", "-target", "1.8", "-encoding", "UTF8"),
(Test / javaOptions) ++= Seq(
"-Dio.netty.leakDetection.level=paranoid",
"-Dorg.slf4j.simpleLogger.log.io.netty=DEBUG"
),
Compile / unmanagedSourceDirectories ++= scalaVersionSpecificFolders(
"main",
baseDirectory.value,
scalaVersion.value
),
Test / unmanagedSourceDirectories ++= scalaVersionSpecificFolders(
"test",
baseDirectory.value,
scalaVersion.value
),
organization := "com.github.postgresql-async",
(Test / parallelExecution) := false
) ++ publishSettings
lazy val publishSettings = Seq(
scmInfo := Some(
ScmInfo(
url("https://github.com/postgresql-async/postgresql-async"),
"[email protected]:postgresql-async/postgresql-async.git"
)
),
releaseProcess := Seq[
ReleaseStep
]( // release was run by github action, just make a tag here
checkSnapshotDependencies,
inquireVersions,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
setNextVersion,
commitNextVersion,
pushChanges
),
developers += Developer(
"jilen",
"jilen",
url("https://github.com/jilen")
),
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0")),
homepage := Some(url("https://github.com/postgresql-async/postgresql-async"))
)
(ThisBuild / scalafmtOnCompile) := true
(Compile / compile) := {
(Compile / compile).dependsOn(Compile / scalafmtSbt).value
}