-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
365 lines (299 loc) · 12.2 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
355
356
357
358
359
360
361
362
363
364
365
import BuildTools._
import ProjectInfo._
ThisBuild / scalaVersion := props.ProjectScalaVersion
ThisBuild / crossSbtVersions := props.CrossSbtVersions
ThisBuild / developers := List(
Developer(
props.GitHubUsername,
"Kevin Lee",
"kevin.code@kevinlee.io",
url(s"https://github.com/${props.GitHubUsername}"),
),
)
ThisBuild / homepage := url(s"https://github.com/${props.GitHubUsername}/${props.ProjectName}").some
ThisBuild / scmInfo :=
ScmInfo(
url(s"https://github.com/${props.GitHubUsername}/${props.ProjectName}"),
s"git@github.com:${props.GitHubUsername}/${props.ProjectName}.git",
).some
ThisBuild / licenses := List("MIT" -> url("http://opensource.org/licenses/MIT"))
ThisBuild / startYear := 2018.some
ThisBuild / testFrameworks ~=
(frameworks => (TestFramework("hedgehog.sbt.Framework") +: frameworks).distinct)
ThisBuild / resolvers += "sonatype-snapshots" at s"https://${props.SonatypeCredentialHost}/content/repositories/snapshots"
Global / sbtVersion := props.GlobalSbtVersion
lazy val sbtDevOops = Project(props.ProjectName, file("."))
.enablePlugins(SbtPlugin)
.enablePlugins(DevOopsGitHubReleasePlugin, DocusaurPlugin)
.settings(
organization := props.Org,
name := props.ProjectName,
description := "DevOops - DevOps tool for GitHub",
writeVersion := versionWriter(Def.spaceDelimited("filename").parsed)(version.value),
docusaurDir := (ThisBuild / baseDirectory).value / "website",
docusaurBuildDir := docusaurDir.value / "build",
gitHubPagesOrgName := props.GitHubUsername,
gitHubPagesRepoName := props.ProjectName,
publishMavenStyle := true,
)
.settings(mavenCentralPublishSettings)
.dependsOn(
sbtDevOopsCommon,
sbtDevOopsScala,
sbtDevOopsSbtExtra,
sbtDevOopsGitHub,
)
.aggregate(
sbtDevOopsCommon,
sbtDevOopsScala,
sbtDevOopsSbtExtra,
sbtDevOopsHttpCore,
sbtDevOopsGitHubCore,
sbtDevOopsStarter,
sbtDevOopsGitHub,
sbtDevOopsReleaseVersionPolicy,
sbtDevOopsJava,
)
lazy val sbtDevOopsCommon = subProject(props.SubProjectNameCommon)
.enablePlugins(SbtPlugin)
.settings(
libraryDependencies ++= List(
libs.semVer,
libs.commonsIo,
libs.cats,
libs.newtype % Test,
) ++ libs.hedgehogLibs,
)
lazy val sbtDevOopsScala = subProject(props.SubProjectNameScala)
.enablePlugins(SbtPlugin)
.settings(
addSbtPlugin(libs.sbtTpolecat)
)
.dependsOn(sbtDevOopsCommon)
lazy val sbtDevOopsSbtExtra = subProject(props.SubProjectNameSbtExtra)
.enablePlugins(SbtPlugin)
lazy val sbtDevOopsHttpCore = subProject(props.SubProjectNameHttpCore)
.enablePlugins(SbtPlugin)
.settings(
libraryDependencies ++= List(
libs.catsEffect,
libs.newtype,
libs.effectie,
libs.justSysprocess,
libs.extrasCats,
) ++ libs.loggerF ++ libs.circe ++ libs.refined ++ libs.http4sClient ++ libs.javaxActivation212,
)
.dependsOn(sbtDevOopsCommon % props.IncludeTest)
lazy val sbtDevOopsGitHubCore = subProject(props.SubProjectNameGitHubCore)
.enablePlugins(SbtPlugin)
.settings(
libraryDependencies ++= libs.hedgehogLibs ++ List(libs.extrasHedgehogCatsEffect3),
)
.dependsOn(sbtDevOopsCommon, sbtDevOopsHttpCore)
lazy val sbtDevOopsStarter = subProject(props.SubProjectNameStarter)
.enablePlugins(SbtPlugin)
.settings(
addSbtPlugin(libs.sbtScalafmt),
addSbtPlugin(libs.sbtScalafix),
addSbtPlugin(libs.sbtWelcome),
libraryDependencies ++= List(libs.extrasScalaIo)
)
.dependsOn(sbtDevOopsScala, sbtDevOopsSbtExtra, sbtDevOopsHttpCore, sbtDevOopsGitHubCore)
lazy val sbtDevOopsGitHub = subProject(props.SubProjectNameGitHub)
.enablePlugins(SbtPlugin)
.dependsOn(sbtDevOopsCommon, sbtDevOopsGitHubCore)
lazy val sbtDevOopsReleaseVersionPolicy = subProject(props.SubProjectNameReleaseVersionPolicy)
.enablePlugins(SbtPlugin)
.settings(
addSbtPlugin(libs.sbtRelease),
addSbtPlugin(libs.sbtVersionPolicy),
libraryDependencies ++= List(
libs.extrasScalaIo,
)
)
.dependsOn(sbtDevOopsCommon)
lazy val sbtDevOopsJava = subProject(props.SubProjectNameJava)
.enablePlugins(SbtPlugin)
lazy val mavenCentralPublishSettings: SettingsDefinition = List(
/* Publish to Maven Central { */
sonatypeCredentialHost := props.SonatypeCredentialHost,
sonatypeRepository := props.SonatypeRepository,
/* } Publish to Maven Central */
)
// scalafmt: off
def prefixedProjectName(name: String) = s"${props.RepoName}${if (name.isEmpty) "" else s"-$name"}"
// scalafmt: on
def subProject(projectName: String): Project = {
val prefixedName = prefixedProjectName(projectName)
Project(projectName, file(s"modules/$prefixedName"))
.settings(
organization := props.Org,
name := prefixedName,
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full),
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.13.2" cross CrossVersion.full),
// scalacOptions ++= List("-Xsource:3"),
Compile / console / scalacOptions := scalacOptions.value diff List("-Ywarn-unused-import", "-Xfatal-warnings"),
Compile / compile / wartremoverErrors ++= commonWarts,
Test / compile / wartremoverErrors ++= commonWarts,
licenses := List("MIT" -> url("http://opensource.org/licenses/MIT")),
publishMavenStyle := true,
coverageHighlighting := (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 10)) =>
false
case _ =>
true
}),
scriptedLaunchOpts := {
scriptedLaunchOpts.value ++
Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
},
scriptedBufferLog := false,
)
.settings(mavenCentralPublishSettings)
}
lazy val props =
new {
private val GitHubRepo = findRepoOrgAndName
val Org = "io.kevinlee"
val GitHubUsername = GitHubRepo.fold("Kevin-Lee")(_.orgToString)
val RepoName = GitHubRepo.fold("sbt-devoops")(_.nameToString)
val ProjectName = RepoName
val SonatypeCredentialHost = "s01.oss.sonatype.org"
val SonatypeRepository = s"https://$SonatypeCredentialHost/service/local"
val SubProjectNameCommon = "common"
val SubProjectNameScala = "scala"
val SubProjectNameSbtExtra = "sbt-extra"
val SubProjectNameStarter = "starter"
val SubProjectNameHttpCore = "http-core"
val SubProjectNameGitHubCore = "github-core"
val SubProjectNameGitHub = "github"
val SubProjectNameReleaseVersionPolicy = "release-version-policy"
val SubProjectNameJava = "java"
val ProjectScalaVersion = "2.12.18"
val CrossScalaVersions = List(ProjectScalaVersion).distinct
val GlobalSbtVersion = "1.3.4"
val CrossSbtVersions = List(GlobalSbtVersion).distinct
val hedgehogVersion = "0.10.1"
val newtypeVersion = "0.4.4"
val catsVersion = "2.10.0"
val catsEffectVersion = "3.5.3"
val extrasVersion = "0.44.0"
val effectieVersion = "2.0.0-beta14"
val loggerFVersion = "2.0.0-beta24"
val refinedVersion = "0.11.1"
val circeVersion = "0.14.6"
val http4sVersion = "0.23.25"
val justSemVerVersion = "0.13.0"
val justSysprocessVersion = "1.0.0"
val commonsIoVersion = "2.11.0"
val activationVersion = "1.1.1"
val activationApiVersion = "1.2.0"
val SbtTpolecatVersion = "0.5.0"
val SbtVersionPolicyVersion = "3.2.1"
val SbtReleaseVersion = "1.1.0"
val SbtScalafmtVersion = "2.5.2"
val SbtScalafixVersion = "0.11.1"
val SbtWelcomeVersion = "0.4.0"
val IncludeTest = "compile->compile;test->test"
}
lazy val libs =
new {
lazy val hedgehogLibs = List(
"qa.hedgehog" %% "hedgehog-core" % props.hedgehogVersion % Test,
"qa.hedgehog" %% "hedgehog-runner" % props.hedgehogVersion % Test,
"qa.hedgehog" %% "hedgehog-sbt" % props.hedgehogVersion % Test,
)
lazy val newtype = "io.estatico" %% "newtype" % props.newtypeVersion
lazy val refined = Seq(
"eu.timepit" %% "refined" % props.refinedVersion,
"eu.timepit" %% "refined-cats" % props.refinedVersion,
)
lazy val cats = "org.typelevel" %% "cats-core" % props.catsVersion
lazy val catsEffect = "org.typelevel" %% "cats-effect" % props.catsEffectVersion
lazy val extrasCats = "io.kevinlee" %% "extras-cats" % props.extrasVersion
lazy val extrasScalaIo = "io.kevinlee" %% "extras-scala-io" % props.extrasVersion
lazy val extrasHedgehogCatsEffect3 =
"io.kevinlee" %% "extras-hedgehog-ce3" % props.extrasVersion % Test
lazy val effectie = "io.kevinlee" %% "effectie-cats-effect3" % props.effectieVersion
lazy val loggerF = List(
"io.kevinlee" %% "logger-f-cats" % props.loggerFVersion,
"io.kevinlee" %% "logger-f-sbt-logging" % props.loggerFVersion,
)
lazy val http4sClient = List(
"org.http4s" %% "http4s-dsl" % props.http4sVersion,
"org.http4s" %% "http4s-ember-client" % props.http4sVersion,
"org.http4s" %% "http4s-circe" % props.http4sVersion,
)
lazy val circe = List(
"io.circe" %% "circe-generic" % props.circeVersion,
"io.circe" %% "circe-parser" % props.circeVersion,
"io.circe" %% "circe-refined" % props.circeVersion,
)
lazy val semVer = "io.kevinlee" %% "just-semver" % props.justSemVerVersion
lazy val justSysprocess = "io.kevinlee" %% "just-sysprocess" % props.justSysprocessVersion
lazy val commonsIo = "commons-io" % "commons-io" % props.commonsIoVersion
lazy val javaxActivation212 = List(
"javax.activation" % "activation" % props.activationVersion,
)
lazy val sbtTpolecat = "org.typelevel" % "sbt-tpolecat" % props.SbtTpolecatVersion
lazy val sbtVersionPolicy = "ch.epfl.scala" % "sbt-version-policy" % props.SbtVersionPolicyVersion
lazy val sbtRelease = "com.github.sbt" % "sbt-release" % props.SbtReleaseVersion
lazy val sbtScalafmt = "org.scalameta" % "sbt-scalafmt" % props.SbtScalafmtVersion
lazy val sbtScalafix = "ch.epfl.scala" % "sbt-scalafix" % props.SbtScalafixVersion
lazy val sbtWelcome = "com.github.reibitto" % "sbt-welcome" % props.SbtWelcomeVersion
def all(scalaVersion: String) = crossVersionProps(
List(
commonsIo,
semVer,
newtype,
cats,
catsEffect,
effectie,
justSysprocess,
extrasScalaIo,
extrasHedgehogCatsEffect3,
) ++
hedgehogLibs ++
loggerF ++
http4sClient ++
circe,
scalaVersion,
) {
case Some((2, 12)) =>
javaxActivation212
case Some((2, 10)) =>
Seq.empty
}
}
lazy val writeVersion = inputKey[Unit]("Write Version in File'")
import scala.{Console => sConsole}
logo :=
raw"""
| __ __ ___ ____
| ___ / / / /_____/ _ \___ _ __/ __ \___ ___ ___
| (_-</ _ \/ __/___/ // / -_) |/ / /_/ / _ \/ _ \(_-<
|/___/_.__/\__/ /____/\__/|___/\____/\___/ .__/___/
| /_/
|
|${sConsole.BLUE}${name.value}${sConsole.RESET} v${sConsole.BLUE}${version.value}${sConsole.RESET}
|${sConsole.YELLOW}Scala ${scalaVersion.value}${sConsole.RESET}
|-----------------------------------------------------
|""".stripMargin
import sbtwelcome._
val aliasFormatter: String => String =
_ + s"${scala.io.AnsiColor.RESET}: "
usefulTasks := Seq(
UsefulTask("reload", "Run reload").alias("r"),
UsefulTask("clean", "Run clean").alias("cln"),
UsefulTask("compile", "Run compile").alias("c"),
UsefulTask("Test/compile", "Run Test/compile").alias("tc"),
UsefulTask("test", "Run test").alias("t"),
UsefulTask("scripted", "Run scripted for sbt-test").alias("st"),
UsefulTask("scalafmtCheckAll", "Run scalafmtCheckAll").alias("fmtchk"),
UsefulTask("scalafmtAll", "Run scalafmtAll").alias("fmt"),
UsefulTask("publishLocal", "Run publishLocal").alias("pl"),
UsefulTask("dependencyUpdates", "Run dependencyUpdates").alias("du"),
UsefulTask("unusedCompileDependencies", "Run unusedCompileDependencies").alias("uud"),
UsefulTask("undeclaredCompileDependencies", "Run undeclaredCompileDependencies").alias("udd"),
).map(_.formatAlias(aliasFormatter))
logoColor := sConsole.MAGENTA