-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sbt
255 lines (232 loc) · 7.37 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
import com.typesafe.tools.mima.core.ProblemFilters
import com.typesafe.tools.mima.core.*
import org.typelevel.sbt.gha.RefPredicate
import org.typelevel.sbt.gha.Ref
import org.scalafmt.sbt.ScalafmtPlugin.{globalInstance => Scalafmt}
Global / onChangedBuildSource := ReloadOnSourceChanges
lazy val buildInfoSettings: Seq[Setting[?]] = {
val infoKeys = Seq[BuildInfoKey](
name,
BuildInfoKey.map(version)(kv => ("snapshot4sVersion", kv._2)),
scalaVersion,
sbtVersion,
git.gitCurrentBranch,
git.gitHeadCommit
)
Seq(
buildInfoPackage := "snapshot4s",
buildInfoKeys := infoKeys
)
}
lazy val scala3Version = "3.3.4"
lazy val scala213Version = "2.13.15"
lazy val sbtPluginScalaVersion = "2.12.20"
lazy val scalaVersions = Seq(
scala3Version,
scala213Version,
sbtPluginScalaVersion
)
def scalaReflect(scalaVersion: String): List[ModuleID] =
if (scalaVersion.startsWith("3.")) Nil
else List("org.scala-lang" % "scala-reflect" % scalaVersion)
inThisBuild(
Seq(
scalaVersion := scala3Version,
versionScheme := Some("early-semver"),
organization := "com.siriusxm",
developers ++= List(
tlGitHubDev("miciek", "Michał Płachta"),
tlGitHubDev("majk-p", "Michał Pawlik"),
tlGitHubDev("zainab-ali", "Zainab Ali")
),
githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17")),
githubWorkflowPublishTargetBranches += RefPredicate.Equals(Ref.Branch("main")),
ThisBuild / githubWorkflowBuild += WorkflowStep
.Run(List("sbt scripted"), name = Some("Scripted tests")),
tlBaseVersion := "0.1",
tlUntaggedAreSnapshots := false,
tlFatalWarnings := sys.env.get("GITHUB_ACTIONS").contains("true"),
tlCiHeaderCheck := true,
tlCiScalafmtCheck := true,
tlCiScalafixCheck := true,
tlJdkRelease := Some(8),
organizationName := "SiriusXM",
startYear := Some(2024),
licenses += ("Apache-2.0", new URL("https://www.apache.org/licenses/LICENSE-2.0.txt"))
)
)
lazy val root = (project in file("."))
.aggregate(allModules: _*)
.enablePlugins(NoPublishPlugin)
lazy val allModules: Seq[ProjectReference] = Seq(
Seq[ProjectReference](docs, plugin),
hashing.projectRefs,
core.projectRefs,
weaver.projectRefs,
munit.projectRefs,
scalatest.projectRefs
).flatten
lazy val pluginSettings = Seq(
scalaVersion := sbtPluginScalaVersion,
sbtPluginPublishLegacyMavenStyle := false,
scriptedLaunchOpts := {
scriptedLaunchOpts.value ++
Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
},
scriptedBufferLog := false
)
lazy val hashing = (projectMatrix in file("modules/hashing"))
.settings(
name := "snapshot4s-hashing",
libraryDependencies ++= Seq(
"com.disneystreaming" %%% "weaver-cats" % Versions.weaver % Test,
"com.disneystreaming" %%% "weaver-scalacheck" % Versions.weaver % Test
),
mimaPreviousArtifacts := Set.empty
)
.jvmPlatform(scalaVersions = scalaVersions)
.jsPlatform(scalaVersions = scalaVersions)
lazy val core = (projectMatrix in file("modules/core"))
.settings(
name := "snapshot4s-core",
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "pprint" % Versions.pprint,
"com.disneystreaming" %%% "weaver-cats" % Versions.weaver % Test,
"org.scalameta" %%% "munit" % Versions.munit % Test,
"org.typelevel" %% "scalac-compat-annotation" % Versions.scalacCompatAnnotation
) ++ scalaReflect(scalaVersion.value),
mimaPreviousArtifacts := Set.empty
)
.dependsOn(hashing)
.jvmPlatform(
scalaVersions = scalaVersions,
libraryDependencies += "com.lihaoyi" %% "os-lib" % Versions.oslib
)
.jsPlatform(
scalaVersions = scalaVersions,
// module support is required to run tests
Test / scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) }
)
lazy val munit = (projectMatrix in file("modules/munit"))
.settings(
name := "snapshot4s-munit",
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit" % Versions.munit,
"com.disneystreaming" %%% "weaver-cats" % Versions.weaver % Test
),
mimaPreviousArtifacts := Set.empty
)
.dependsOn(core)
.jvmPlatform(scalaVersions = scalaVersions)
.jsPlatform(scalaVersions = scalaVersions)
lazy val weaver = (projectMatrix in file("modules/weaver"))
.settings(
name := "snapshot4s-weaver",
libraryDependencies ++= Seq(
"com.disneystreaming" %%% "weaver-cats" % Versions.weaver,
"org.scalameta" %%% "munit" % Versions.munit
),
mimaPreviousArtifacts := Set.empty
)
.dependsOn(core)
.jvmPlatform(scalaVersions = scalaVersions)
.jsPlatform(scalaVersions = scalaVersions)
lazy val scalatest = (projectMatrix in file("modules/scalatest"))
.settings(
name := "snapshot4s-scalatest",
libraryDependencies ++= Seq(
"org.scalatest" %%% "scalatest-core" % Versions.scalatest,
"com.disneystreaming" %%% "weaver-cats" % Versions.weaver % Test
),
mimaPreviousArtifacts := Set.empty
)
.dependsOn(core)
.jvmPlatform(scalaVersions = scalaVersions)
.jsPlatform(scalaVersions = scalaVersions)
// This filter finds the libraries required by the scripted tests.
lazy val scriptedScopeFilter = ScopeFilter(
inProjects(
Seq(hashing, core, weaver, munit, scalatest).flatMap(_.projectRefs): _*
)
)
lazy val plugin = project
.in(file("modules/plugin"))
.enablePlugins(SbtPlugin, BuildInfoPlugin)
.dependsOn(hashing.jvm(sbtPluginScalaVersion))
.settings(
name := "sbt-snapshot4s",
buildInfoSettings,
pluginSettings,
testFrameworks += new TestFramework("weaver.framework.CatsEffect"),
mimaPreviousArtifacts := Set.empty,
scriptedDependencies := {
scriptedDependencies.value
publishLocal.all(scriptedScopeFilter).value
}
)
def latestStableVersion = {
import scala.sys.process._
"git -c versionsort.suffix=- tag --list --sort=-version:refname".!!.split("\n").toList
.map(_.trim)
.find(_.startsWith("v"))
.map(_.replace("v", ""))
}
lazy val docs = project
.in(file("docs"))
.settings(
tlMimaPreviousVersions := Set.empty,
mdocIn := new File("docs/markdown/"),
mdocOut := new File("website/docs"),
mdocVariables := Map(
"LATEST_STABLE_VERSION" -> latestStableVersion.getOrElse(version.value)
),
fork := false, // Without this set to false mdoc would mess up it's paths and stop working
libraryDependencies += "org.scalatest" %%% "scalatest" % Versions.scalatest
)
.dependsOn(
core.jvm(scala3Version),
weaver.jvm(scala3Version),
munit.jvm(scala3Version),
scalatest.jvm(scala3Version)
)
.enablePlugins(MdocPlugin, NoPublishPlugin)
addCommandAlias(
"formatAll",
List(
"scalafmtAll",
"scalafmtSbt",
"scalafixAll"
).mkString(" ; ")
)
addCommandAlias(
"validateFormatting",
List(
"scalafmtCheckAll",
"scalafmtSbtCheck",
"scalafixAll --check"
).mkString(" ; ")
)
addCommandAlias(
"validate",
List(
"clean",
"headerCheck",
"Test/compile",
"docs/mdoc --check",
"hashing/test",
"core/test",
"munit/test",
"weaver/test",
"plugin/test",
"docs/test",
"scripted",
"mimaReportBinaryIssues"
).mkString(" ; ")
)
addCommandAlias(
"release",
List(
"package",
"publish"
).mkString(" ; ")
)