This repository has been archived by the owner on Jul 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
295 lines (271 loc) · 10.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
// *****************************************************************************
// Projects
// *****************************************************************************
import microsites.ExtraMdFileConfig
lazy val IT = config("it") extend Test
val filterDependencies: ModuleID => ModuleID = { dependency =>
library.exclusions.foldRight(dependency) { (rule, module) =>
module.excludeAll(rule)
}
}
addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt")
addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck")
addCommandAlias("releaseSite", "microsite/publishMicrosite")
lazy val gstorage = (project in file("gstorage"))
.enablePlugins(BuildInfoPlugin)
.configs(IntegrationTest)
.settings(inConfig(IT)(Defaults.testSettings))
.settings(commonSettings: _*)
.settings(publishSettings: _*)
.settings(
name := "google4s-gstorage",
libraryDependencies ++= Seq(
compilerPlugin(library.kindProjector),
// compile time dependencies
library.gCloudStorage % Compile
)
)
.dependsOn(core % "compile->compile;test->test;it->it")
lazy val gkms = (project in file("gkms"))
.enablePlugins(BuildInfoPlugin)
.configs(IntegrationTest)
.settings(inConfig(IT)(Defaults.testSettings))
.settings(commonSettings: _*)
.settings(publishSettings: _*)
.settings(
name := "google4s-gkms",
libraryDependencies ++= Seq(
// compiler plugins
compilerPlugin(library.kindProjector),
// compile time dependencies
library.gCloudKMS % Compile,
library.terminology % Compile
)
)
.dependsOn(core % "compile->compile;test->test;it->it")
lazy val gpubsub = (project in file("gpubsub"))
.enablePlugins(BuildInfoPlugin)
.configs(IntegrationTest)
.settings(commonSettings: _*)
.settings(inConfig(IT)(Defaults.testSettings))
.settings(publishSettings: _*)
.settings(
name := "google4s-gpubsub",
libraryDependencies ++= Seq(
// compile time dependencies
library.gPubSub % Compile,
library.akkaStream % Compile
)
)
.dependsOn(core % "compile->compile;test->test;it->it")
lazy val core = (project in file("core"))
.configs(IntegrationTest)
.settings(commonSettings: _*)
.settings(inConfig(IT)(Defaults.testSettings))
.settings(
name := "google4s-core",
skip in publish := true,
libraryDependencies ++= Seq(
compilerPlugin(library.kindProjector),
library.akkaStreamTest % "it,test",
library.akkaTest % "it,test",
library.scalaTest % "it,test",
library.scalaCheck % "it,test",
library.gCloudNio % "it,test",
// compile time dependencies
library.gApiCommon % Compile,
library.gApi % Compile,
library.catsCore % Compile
)
)
lazy val google4s = (project in file("."))
.settings(publishSettings: _*)
.settings(
skip in publish := true,
name := "google4s"
)
.aggregate(core, gstorage, gkms, gpubsub)
lazy val microsite = (project in file ("site"))
.enablePlugins(MicrositesPlugin)
.dependsOn(gpubsub, gkms, gstorage)
.settings(
skip in publish := true,
micrositeFooterText := Some(
"""
|<p>© 2019 <a href="https://github.com/toknapp/google4s">Ivan Morozov, Tokn GmbH</a></p>
|""".stripMargin
),
micrositeName := "Google4s",
micrositeDescription := "A lean, functional library for Google Cloud Services in Scala",
micrositeAuthor := "Ivan Morozov",
micrositeOrganizationHomepage := "http://www.upvest.co",
micrositeBaseUrl:= "/google4s",
micrositeGithubOwner := "toknapp",
micrositeGithubRepo := "google4s",
micrositeTwitterCreator := "@allquantor",
micrositeGithubToken := sys.env.get("GIT_TOKEN"),
micrositePushSiteWith := GitHub4s,
scalacOptions in Tut ~= (_ filterNot Set(
"-Xfatal-warnings",
"-Ywarn-numeric-widen",
"-Ywarn-unused:imports",
"-Ywarn-unused:locals",
"-Ywarn-unused:patvars",
"-Ywarn-unused:privates",
"-Ywarn-numeric-widen",
"-Ywarn-dead-code",
"-Xlint:-missing-interpolator,_").contains),
)
// *****************************************************************************
// Dependencies
// *****************************************************************************
lazy val library =
new {
object Version {
val akka = "2.5.19"
val cats = "1.4.0"
val circe = "0.10.1"
val gCloudStorage = "1.53.0"
val gCloudKMS = "0.74.0-beta"
val gCloudNio = "0.72.0-alpha"
val gPubSub = "1.53.0"
val gApiCommon = "1.7.0"
val gApi = "1.35.1"
val terminology = "0.7.0"
val scalaTest = "3.0.5"
val scalaCheck = "1.13.5" // https://github.com/typelevel/cats/blob/910df7807a890f0f2ba26a750ab51e1072bf37ee/build.sbt#L140
val kindProjector = "0.9.9"
}
val akkaStream = "com.typesafe.akka" %% "akka-stream" % Version.akka
val akkaStreamTest = "com.typesafe.akka" %% "akka-stream-testkit" % Version.akka
val akkaTest = "com.typesafe.akka" %% "akka-testkit" % Version.akka
val catsCore = "org.typelevel" %% "cats-core" % Version.cats
val gPubSub = "com.google.cloud" % "google-cloud-pubsub" % Version.gPubSub
val gCloudStorage = "com.google.cloud" % "google-cloud-storage" % Version.gCloudStorage
val gCloudKMS = "com.google.cloud" % "google-cloud-kms" % Version.gCloudKMS
val gCloudNio = "com.google.cloud" % "google-cloud-nio" % Version.gCloudNio
val gApi = "com.google.api" % "gax" % Version.gApi
val gApiCommon = "com.google.api" % "api-common" % Version.gApiCommon
val terminology = "co.upvest" %% "terminology" % Version.terminology
val kindProjector = "org.spire-math" %% "kind-projector" % Version.kindProjector
val scalaTest = "org.scalatest" %% "scalatest" % Version.scalaTest
val scalaCheck = "org.scalacheck" %% "scalacheck" % Version.scalaCheck
// All exclusions that should be applied to every module.
val exclusions = Seq(
ExclusionRule(organization = "org.slf4j", name = "slf4j-log4j12"),
ExclusionRule(organization = "log4j", name = "log4j"),
ExclusionRule(organization = "ch.qos.logback", name = "logback-classic")
)
}
// *****************************************************************************
// Settings
// *****************************************************************************
lazy val commonSettings = Seq(
scalaVersion := "2.12.8",
organization := "co.upvest",
scalacOptions ++= Seq(
"-unchecked",
"-deprecation",
"-language:_",
"-target:jvm-1.8",
"-encoding",
"UTF-8",
"-Xfatal-warnings",
"-Ywarn-unused-import",
"-Yno-adapted-args",
"-Ywarn-inaccessible",
"-Ywarn-dead-code",
"-Ywarn-infer-any",
"-Ywarn-nullary-override",
"-Ywarn-nullary-unit",
"-Ywarn-unused-import",
"-Ypartial-unification",
"-Xmacro-settings:materialize-derivations"
),
scalacOptions in (Compile, console) ~= { _ filterNot (_ == "-Ywarn-unused-import") },
scalacOptions in Test ~= { _ filterNot (_ == "-Ywarn-dead-code") },
javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
cancelable in Global := true,
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion, isSnapshot),
fork in Global := true
)
// *****************************************************************************
// Release settings
// *****************************************************************************
organization in ThisBuild := "co.upvest"
lazy val tagName = Def.setting {
s"v${if (releaseUseGlobalVersion.value) (version in ThisBuild).value else version.value}"
}
lazy val credentialSettings = Seq(
credentials ++= (for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq
)
import microsites.ExtraMdFileConfig
import sbtrelease.ReleaseStateTransformations._
import sbtrelease.Version
def checkoutBranch(branch: String): ReleaseStep = { st: State =>
val Some(vcs) = Project.extract(st).get(releaseVcs)
val 0 = vcs.cmd("checkout", branch).!
st
}
publishArtifact in google4s := false
lazy val releaseSettings = Seq(
releaseTagName := tagName.value,
useGpg := true,
pgpReadOnly := true,
usePgpKeyHex("5C90DFE428FC2B33"),
pgpPassphrase := Some(Array.empty),
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseVcsSign := true,
releaseVersionBump := Version.Bump.Minor,
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := Function.const(false),
releaseCommitMessage := "Bumping version",
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")
},
publishConfiguration := publishConfiguration.value.withOverwrite(isSnapshot.value),
PgpKeys.publishSignedConfiguration := PgpKeys.publishSignedConfiguration.value.withOverwrite(isSnapshot.value),
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(isSnapshot.value),
PgpKeys.publishLocalSignedConfiguration := PgpKeys.publishLocalSignedConfiguration.value
.withOverwrite(isSnapshot.value),
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
setReleaseVersion,
tagRelease,
publishArtifacts,
releaseStepCommand("sonatypeReleaseAll"),
checkoutBranch("develop"),
setNextVersion,
commitNextVersion,
pushChanges
)
)
lazy val publishSettings = Seq(
homepage := Some(url("https://github.com/toknapp/google4s")),
licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT")),
scmInfo := Some(ScmInfo(url("https://github.com/toknapp/google4s"), "scm:[email protected]:toknapp/google4s.git")),
pomExtra := (
<developers>
<developer>
<id>allquantor</id>
<name>Ivan Morozov</name>
<url>https://github.com/allquantor/</url>
</developer>
<developer>
<id>rootmos</id>
<name>Gustav Behm</name>
<url>https://github.com/rootmos/</url>
</developer>
</developers>
)
) ++ credentialSettings ++ releaseSettings