-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathProjectPlugin.scala
435 lines (393 loc) · 15.3 KB
/
ProjectPlugin.scala
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
import com.typesafe.sbt.site.jekyll.JekyllPlugin.autoImport._
import microsites.MicrositesPlugin.autoImport._
import microsites._
import sbt.Keys._
import sbt.ScriptedPlugin.autoImport._
import sbt._
import sbtorgpolicies.OrgPoliciesPlugin
import sbtorgpolicies.OrgPoliciesPlugin.autoImport._
import sbtorgpolicies.model._
import sbtorgpolicies.templates._
import sbtorgpolicies.templates.badges._
import sbtorgpolicies.runnable.syntax._
import sbtrelease.ReleasePlugin.autoImport._
import sbtrelease.ReleaseStateTransformations._
import scoverage.ScoverageKeys._
import scala.language.reflectiveCalls
import tut.TutPlugin.autoImport._
object ProjectPlugin extends AutoPlugin {
override def requires: Plugins = OrgPoliciesPlugin
override def trigger: PluginTrigger = allRequirements
object autoImport {
lazy val V = new {
val avro4s: String = "1.8.4"
val avrohugger: String = "1.0.0-RC22"
val betterMonadicFor: String = "0.3.1"
val catsEffect: String = "2.0.0"
val circe: String = "0.12.3"
val dropwizard: String = "4.1.2"
val embeddedKafka: String = "2.4.0"
val enumeratum: String = "1.5.15"
val frees: String = "0.8.2"
val fs2: String = "2.1.0"
val fs2Grpc: String = "0.6.0"
val fs2Kafka: String = "0.20.2"
val grpc: String = "1.24.2"
val jodaTime: String = "2.10.5"
val http4s: String = "0.21.0-M6"
val kindProjector: String = "0.10.3"
val log4cats: String = "1.0.1"
val log4s: String = "1.8.2"
val logback: String = "1.2.3"
val monix: String = "3.1.0"
val monocle: String = "2.0.1"
val nettySSL: String = "2.0.25.Final"
val paradise: String = "2.1.1"
val pbdirect: String = "0.4.0"
val prometheus: String = "0.8.0"
val pureconfig: String = "0.12.2"
val reactiveStreams: String = "1.0.3"
val scala: String = "2.12.10"
val scopt: String = "3.7.1"
val scalacheck: String = "1.14.3"
val scalacheckToolbox: String = "0.3.1"
val scalamock: String = "4.4.0"
val scalatest: String = "3.0.8"
val skeuomorph: String = "0.0.19"
val slf4j: String = "1.7.30"
}
lazy val commonSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%%("cats-effect", V.catsEffect) % Test,
%%("scalamock", V.scalamock) % Test,
%%("scheckToolboxDatetime", V.scalacheckToolbox) % Test
)
)
lazy val internalSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%%("cats-effect", V.catsEffect),
%("grpc-stub", V.grpc),
"com.47deg" %% "pbdirect" % V.pbdirect,
"com.beachape" %% "enumeratum" % V.enumeratum,
%%("avro4s", V.avro4s),
%%("log4s", V.log4s),
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
%%("scalamock", V.scalamock) % Test
)
)
lazy val internalMonixSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%%("monix", V.monix),
"org.reactivestreams" % "reactive-streams" % V.reactiveStreams,
%%("scalamock", V.scalamock) % Test
)
)
lazy val internalFs2Settings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%%("fs2-core", V.fs2),
"org.lyranthe.fs2-grpc" %% "java-runtime" % V.fs2Grpc,
%%("scalamock", V.scalamock) % Test
)
)
lazy val clientCoreSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%%("cats-effect", V.catsEffect),
%%("scalamock", V.scalamock) % Test,
%("grpc-netty", V.grpc) % Test
)
)
lazy val clientNettySettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%("grpc-netty", V.grpc),
"io.netty" % "netty-tcnative-boringssl-static" % V.nettySSL % Test
)
)
lazy val clientOkHttpSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%("grpc-okhttp", V.grpc)
)
)
lazy val clientCacheSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%%("log4s", V.log4s),
%%("fs2-core", V.fs2),
%%("cats-effect", V.catsEffect),
compilerPlugin("com.olegpy" %% "better-monadic-for" % V.betterMonadicFor)
)
)
lazy val healthCheckSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%%("cats-effect", V.catsEffect)
)
)
lazy val healthCheckSettingsFS2: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
"io.chrisdavenport" %% "log4cats-core" % V.log4cats,
"io.chrisdavenport" %% "log4cats-slf4j" % V.log4cats,
%%("fs2-core", V.fs2),
%%("cats-effect", V.catsEffect)
)
)
lazy val healthCheckSettingsMonix: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
"io.chrisdavenport" %% "log4cats-core" % V.log4cats,
"io.chrisdavenport" %% "log4cats-slf4j" % V.log4cats,
%%("monix", V.monix),
%%("cats-effect", V.catsEffect)
)
)
lazy val serverSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%("grpc-netty", V.grpc),
%%("scalamock", V.scalamock) % Test,
"io.netty" % "netty-tcnative-boringssl-static" % V.nettySSL % Test
)
)
lazy val httpSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%%("http4s-dsl", V.http4s),
%%("http4s-blaze-server", V.http4s),
%%("http4s-circe", V.http4s),
%%("http4s-blaze-client", V.http4s) % Test,
%%("circe-generic", V.circe) % Test,
"ch.qos.logback" % "logback-classic" % V.logback % Test
)
)
lazy val configSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%%("pureconfig", V.pureconfig)
)
)
lazy val prometheusMetricsSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%("prometheus", V.prometheus)
)
)
lazy val dropwizardMetricsSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
"io.dropwizard.metrics" % "metrics-core" % V.dropwizard
)
)
lazy val testingSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%("grpc-testing", V.grpc),
%%("cats-effect", V.catsEffect),
%%("scalacheck", V.scalacheck) % Test
)
)
lazy val nettySslSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
"io.netty" % "netty-tcnative-boringssl-static" % V.nettySSL
)
)
lazy val idlGenSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%%("monocle-core", V.monocle),
"io.higherkindness" %% "skeuomorph" % V.skeuomorph,
"com.julianpeeters" %% "avrohugger-core" % V.avrohugger,
%%("circe-generic", V.circe)
)
)
lazy val kafkaSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
"com.ovoenergy" %% "fs2-kafka" % V.fs2Kafka,
"io.github.embeddedkafka" %% "embedded-kafka" % V.embeddedKafka % Test
)
)
lazy val exampleRouteguideRuntimeSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%%("monix", V.monix)
)
)
lazy val marshallersJodatimeSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%("joda-time", V.jodaTime),
%%("scheckToolboxDatetime", V.scalacheckToolbox) % Test
)
)
lazy val exampleRouteguideCommonSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%%("circe-core", V.circe),
%%("circe-generic", V.circe),
%%("circe-parser", V.circe),
%%("log4s", V.log4s),
%("logback-classic", V.logback)
)
)
lazy val exampleSeedLogSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
%("logback-classic", V.logback),
"io.chrisdavenport" %% "log4cats-core" % V.log4cats,
"io.chrisdavenport" %% "log4cats-slf4j" % V.log4cats
))
lazy val exampleSeedConfigSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % V.catsEffect,
"com.github.pureconfig" %% "pureconfig" % V.pureconfig))
lazy val exampleSeedClientAppSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
"com.github.scopt" %% "scopt" % V.scopt
))
lazy val exampleTodolistCommonSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
"io.frees" %% "frees-todolist-lib" % V.frees,
%%("log4s", V.log4s),
%("logback-classic", V.logback)
)
)
lazy val sbtPluginSettings: Seq[Def.Setting[_]] = Seq(
sbtPlugin := true,
scriptedLaunchOpts := {
scriptedLaunchOpts.value ++
Seq(
"-Xmx2048M",
"-XX:ReservedCodeCacheSize=256m",
"-XX:+UseConcMarkSweepGC",
"-Dversion=" + version.value
)
},
// Custom release process for the plugin:
releaseProcess := Seq[ReleaseStep](
releaseStepCommandAndRemaining("^ publishSigned"),
ReleaseStep(action = "sonatypeReleaseAll" :: _)
)
)
lazy val crossSettings: Seq[Def.Setting[_]] = Seq(
unmanagedSourceDirectories in Compile += {
baseDirectory.value.getParentFile / "shared" / "src" / "main" / "scala"
},
unmanagedSourceDirectories in Test += {
baseDirectory.value.getParentFile / "shared" / "src" / "test" / "scala"
}
)
lazy val micrositeSettings: Seq[Def.Setting[_]] = Seq(
micrositeName := "Mu-Scala",
micrositeBaseUrl := "mu-scala",
micrositeDescription := "A purely functional library for building RPC endpoint-based services",
micrositeGithubOwner := "higherkindness",
micrositeGithubRepo := "mu-scala",
micrositeGitterChannelUrl := "47deg/mu",
micrositeOrganizationHomepage := "https://www.47deg.com",
micrositeCompilingDocsTool := WithTut,
micrositePushSiteWith := GitHub4s,
micrositeGithubToken := sys.env.get(orgGithubTokenSetting.value),
micrositePalette := Map(
"brand-primary" -> "#de3423",
"brand-secondary" -> "#852319",
"brand-tertiary" -> "#381C19",
"gray-dark" -> "#333333",
"gray" -> "#666666",
"gray-light" -> "#EDEDED",
"gray-lighter" -> "#F4F5F9",
"white-color" -> "#E6E7EC"
),
micrositeHighlightTheme := "tomorrow-night-eighties",
micrositeHighlightLanguages += "protobuf"
)
lazy val docsSettings: Seq[Def.Setting[_]] = Seq(
libraryDependencies += %%("scalatest", V.scalatest),
scalacOptions in Tut ~= (_ filterNot Set("-Ywarn-unused-import", "-Xlint").contains)
)
}
import autoImport._
case class FixedCodecovBadge(info: BadgeInformation) extends Badge(info) {
override def badgeIcon: Option[BadgeIcon] =
BadgeIcon(
title = "codecov.io",
icon = s"http://codecov.io/gh/${info.owner}/${info.repo}/branch/master/graph/badge.svg",
url = s"http://codecov.io/gh/${info.owner}/${info.repo}"
).some
}
override def projectSettings: Seq[Def.Setting[_]] =
warnUnusedImport ++ Seq(
description := "mu RPC is a purely functional library for " +
"building RPC endpoint based services with support for RPC and HTTP/2",
startYear := Some(2017),
orgProjectName := "mu-scala",
orgGithubSetting := GitHubSettings(
organization = "higherkindness",
project = (name in LocalRootProject).value,
organizationName = "47 Degrees",
groupId = "io.higherkindness",
organizationHomePage = url("http://47deg.com"),
organizationEmail = "[email protected]"
),
scalaVersion := V.scala,
crossScalaVersions := Seq(V.scala),
scalacOptions ++= scalacAdvancedOptions,
scalacOptions ~= (_ filterNot Set("-Yliteral-types", "-Xlint").contains),
Test / fork := true,
Tut / scalacOptions -= "-Ywarn-unused-import",
compileOrder in Compile := CompileOrder.JavaThenScala,
coverageFailOnMinimum := false,
addCompilerPlugin(%%("paradise", V.paradise) cross CrossVersion.full),
addCompilerPlugin(%%("kind-projector", V.kindProjector) cross CrossVersion.binary),
libraryDependencies ++= Seq(
%%("scalatest", V.scalatest) % "test",
%("slf4j-nop", V.slf4j) % Test
),
releaseProcess := Seq[ReleaseStep](
orgInitialVcsChecks,
checkSnapshotDependencies,
orgInquireVersions,
orgTagRelease,
orgUpdateChangeLog,
releaseStepCommandAndRemaining("publishSigned"),
releaseStepCommand("sonatypeBundleRelease"),
setNextVersion,
orgCommitNextVersion,
orgPostRelease
)
) ++ Seq(
// sbt-org-policies settings:
// format: OFF
orgMaintainersSetting := List(Dev("developer47deg", Some("47 Degrees (twitter: @47deg)"), Some("[email protected]"))),
orgBadgeListSetting := List(
TravisBadge.apply,
FixedCodecovBadge.apply,
{ info => MavenCentralBadge.apply(info.copy(libName = "mu-scala")) },
ScalaLangBadge.apply,
LicenseBadge.apply,
// Gitter badge (owner field) can be configured with default value if we migrate it to the higherkindness organization
{ info => GitterBadge.apply(info.copy(owner = "47deg", repo = "mu")) },
GitHubIssuesBadge.apply
),
orgEnforcedFilesSetting := List(
LicenseFileType(orgGithubSetting.value, orgLicenseSetting.value, startYear.value),
ContributingFileType(
orgProjectName.value,
// Organization field can be configured with default value if we migrate it to the higherkindness organization
orgGithubSetting.value.copy(organization = "47deg", project = "mu-scala")
),
AuthorsFileType(
name.value,
orgGithubSetting.value,
orgMaintainersSetting.value,
orgContributorsSetting.value),
NoticeFileType(orgProjectName.value, orgGithubSetting.value, orgLicenseSetting.value, startYear.value),
VersionSbtFileType,
ChangelogFileType,
ReadmeFileType(
orgProjectName.value,
orgGithubSetting.value,
startYear.value,
orgLicenseSetting.value,
orgCommitBranchSetting.value,
sbtPlugin.value,
name.value,
version.value,
scalaBinaryVersion.value,
sbtBinaryVersion.value,
orgSupportedScalaJSVersion.value,
orgBadgeListSetting.value
),
ScalafmtFileType,
TravisFileType(crossScalaVersions.value, orgScriptCICommandKey, orgAfterCISuccessCommandKey)
),
orgAfterCISuccessTaskListSetting := List(
orgPublishReleaseTask.asRunnableItem(allModules = true, aggregated = false, crossScalaVersions = true),
orgUpdateDocFiles.asRunnableItem
) ++ guard(!version.value.endsWith("-SNAPSHOT"))(defaultPublishMicrosite)
)
// format: ON
}