-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
182 lines (165 loc) · 5.25 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
inThisBuild(
List(
organization := "africa.shuwari.sbt",
organizationName := "Shuwari Africa Ltd.",
organizationHomepage := Some(url("https://shuwari.africa/dev")),
licenses := List(
"Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")
),
description := "Collection of sbt plugins for easy initialisation of uniform organisation wide default project settings.",
homepage := Some(url("https://github.com/shuwariafrica/sbt-shuwari")),
version := versionSetting.value,
dynver := versionSetting.toTaskable.toTask.value,
scmInfo := Some(
ScmInfo(
url("https://github.com/unganisha/sbt-shuwari"),
"scm:git@github.com:shuwariafrica/sbt-shuwari.git"
)
),
scalacOptions ++= List("-feature", "-deprecation"),
startYear := Some(2022),
sonatypeCredentialHost := "s01.oss.sonatype.org",
publishCredentials,
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision
)
)
lazy val `sbt-shuwari-mode` =
project
.in(modules("mode"))
.enablePlugins(SbtPlugin)
.settings(publishSettings)
lazy val `sbt-shuwari-header` =
project
.in(modules("header"))
.enablePlugins(SbtPlugin)
.settings(addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0"))
.settings(publishSettings)
lazy val `sbt-shuwari-scalac` =
project
.in(modules("scalac"))
.enablePlugins(SbtPlugin)
.dependsOn(`sbt-shuwari-mode`)
.settings(
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.0")
)
.settings(publishSettings)
lazy val `sbt-shuwari-core` =
project
.in(modules("core"))
.enablePlugins(SbtPlugin)
.settings(publishSettings)
lazy val `sbt-shuwari` =
project
.in(file(".sbt-shuwari"))
.dependsOn(`sbt-shuwari-core`, `sbt-shuwari-scalac`, `sbt-shuwari-header`)
.enablePlugins(SbtPlugin)
.settings(publishSettings)
lazy val `sbt-shuwari-js` =
project
.in(modules("js"))
.enablePlugins(SbtPlugin)
.settings(publishSettings)
.dependsOn(`sbt-shuwari-mode`, `sbt-shuwari-scalac`)
.settings(addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0"))
lazy val `sbt-shuwari-cross` =
project
.in(modules("cross"))
.enablePlugins(SbtPlugin)
.dependsOn(`sbt-shuwari`)
.settings(publishSettings)
.settings(addSbtPlugin("org.portable-scala" % "sbt-crossproject" % "1.3.2"))
lazy val `sbt-shuwari-documentation` =
project
.in(file(".sbt-shuwari-doc"))
.dependsOn(`sbt-shuwari`)
.enablePlugins(MdocPlugin)
.settings(
mdocIn := (LocalRootProject / baseDirectory).value / "modules" / "documentation",
mdocOut := (LocalRootProject / baseDirectory).value,
mdocVariables := Map(
"VERSION" -> version.value
)
)
lazy val `sbt-shuwari-build-root` =
project
.in(file("."))
.aggregate(
`sbt-shuwari-mode`,
`sbt-shuwari-header`,
`sbt-shuwari-scalac`,
`sbt-shuwari-core`,
`sbt-shuwari`,
`sbt-shuwari-cross`,
`sbt-shuwari-js`
)
.enablePlugins(SbtPlugin)
.settings(
publish := {},
publish / skip := true,
sonatypeProfileName := "africa.shuwari"
)
def modules(name: String) = file(s"./modules/$name")
def publishCredentials = credentials := List(
Credentials(
"Sonatype Nexus Repository Manager",
sonatypeCredentialHost.value,
System.getenv("PUBLISH_USER"),
System.getenv("PUBLISH_USER_PASSPHRASE")
)
)
def publishSettings = publishCredentials +: pgpSettings ++: List(
packageOptions += Package.ManifestAttributes(
"Created-By" -> "Simple Build Tool",
"Built-By" -> System.getProperty("user.name"),
"Build-Jdk" -> System.getProperty("java.version"),
"Specification-Title" -> name.value,
"Specification-Version" -> version.value,
"Specification-Vendor" -> organizationName.value,
"Implementation-Title" -> name.value,
"Implementation-Version" -> implementationVersionSetting.value,
"Implementation-Vendor-Id" -> organization.value,
"Implementation-Vendor" -> organizationName.value
),
publishTo := sonatypePublishToBundle.value,
developers := List(
Developer(
id = "shuwaridev",
name = "Shuwari Developer Team",
email = "dev at shuwari com",
url = url("https://shuwari.com/dev")
)
),
pomIncludeRepository := (_ => false),
publishMavenStyle := true
)
def pgpSettings = List(
PgpKeys.pgpSelectPassphrase :=
sys.props
.get("SIGNING_KEY_PASSPHRASE")
.map(_.toCharArray),
usePgpKeyHex(System.getenv("SIGNING_KEY_ID"))
)
def baseVersionSetting(appendMetadata: Boolean): Def.Initialize[String] = {
def baseVersionFormatter(in: sbtdynver.GitDescribeOutput) = {
def meta =
if (appendMetadata) s"+${in.commitSuffix.distance}.${in.commitSuffix.sha}"
else ""
if (!in.isSnapshot()) in.ref.dropPrefix
else {
val parts = {
def current = in.ref.dropPrefix.split("\\.").map(_.toInt)
current.updated(current.length - 1, current.last + 1)
}
s"${parts.mkString(".")}-SNAPSHOT$meta"
}
}
Def.setting(
dynverGitDescribeOutput.value.mkVersion(
baseVersionFormatter,
"SNAPHOT"
)
)
}
def versionSetting = baseVersionSetting(appendMetadata = false)
def implementationVersionSetting = baseVersionSetting(appendMetadata = true)