-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
321 lines (298 loc) · 11.3 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
/* ------------------------------------------------------------------------- */
/* BASIC PROPERTIES */
// See version in "version.sbt"
// Friendly app name
Global / name := "comet"
// Scala version used in development
ThisBuild / scalaVersion := "3.1.2"
// Lint exclusions
Global / excludeLintKeys ++= Set(name, idePackagePrefix)
/* ------------------------------------------------------------------------- */
/* (CROSS) COMPILATION SETTINGS */
// Define Scala/Java reusable constants
lazy val scala2_13 = "2.13.8"
lazy val scala3_1 = "3.1.2"
lazy val java11 = JavaSpec.temurin("11")
lazy val java17 = JavaSpec.temurin("17")
// Although the library is developed and tested for Scala 3, we cross-compile
// to Scala 2 as well, to reach a wider target
// See https://www.scala-sbt.org/1.x/docs/Cross-Build.html
lazy val supportedScalaVersions = List(scala2_13, scala3_1)
// Helpers
lazy val scalaVersionPattern = """\..{1,2}$""".r
/* ------------------------------------------------------------------------- */
/* MODULES */
// Root project
lazy val comet = (project in file("."))
.aggregate(api)
.settings(
name := "root",
// crossScalaVersions must be set to Nil on the root project
crossScalaVersions := Nil,
// Publishing disabled in root project
publish / skip := true,
// Common settings
buildInfoSettings,
packagingSettings,
resolverSettings,
scaladocSettings,
// Excluded dependencies
excludeDependencies ++= Seq(
// Exclude slf4j backend if present in other dependencies to avoid
// warnings/conflicts with logback
ExclusionRule("org.slf4j", "slf4j-simple")
)
)
.enablePlugins(BuildInfoPlugin)
// Comet's core API, to be published
lazy val api = (project in file("api"))
.enablePlugins(BuildInfoPlugin)
.settings(
name := "comet",
idePackagePrefix := Some("org.ragna.comet"),
Compile / run / fork := true, // https://stackoverflow.com/q/66372308/9744696
crossScalaVersions := supportedScalaVersions, // cross-compile
// Common settings
buildInfoSettings,
packagingSettings,
resolverSettings,
scaladocSettings,
testFrameworks += ScalaTestFramework,
buildInfoSettings,
libraryDependencies ++= Seq(
catsEffect,
fs2,
fs2Kafka,
shexs,
shaclex,
wesoUtils,
// testing
scalaTest,
catsEffectTesting,
// logging
scalaLogging
)
)
// Documentation project, for MDoc + Docusaurus documentation
lazy val docs = project
.in(file("comet-docs"))
.enablePlugins(MdocPlugin, DocusaurusPlugin, ScalaUnidocPlugin)
.settings(
// Publishing disabled in docs project
publish / skip := true,
// Pre-existing settings
unidocSettings,
mdocSettings,
// Custom settings
name := s"${(Global / name).value}-api-docs",
moduleName := s"${(Global / name).value}-api-docs"
)
/* ------------------------------------------------------------------------- */
/* RESOLVER SETTINGS */
// Settings passed down to modules to resolve dependencies
lazy val resolverSettings = Seq(
resolvers ++= Seq(
Resolver.DefaultMavenRepository, // maven
Opts.resolver.sonatypeSnapshots, // sonatype
Opts.resolver.sonatypeReleases
)
)
/* ------------------------------------------------------------------------- */
/* PUBLISH SETTINGS */
// Shared publish settings for all modules.
// The module is pushed to Sonatype in CI (cross published for cross scala versions)
// See https://github.com/sbt/sbt-ci-release
ThisBuild / organization := "io.github.ulitol97"
ThisBuild / homepage := Some(url("https://github.com/ulitol97"))
ThisBuild / licenses := List("MIT" -> url("https://mit-license.org/"))
ThisBuild / developers := List(
Developer(
"ragna",
"Eduardo Ulibarri Toledo",
url("https://github.com/ulitol97")
)
)
// Override sonatype server location (accounts created after Feb 2021)
sonatypeCredentialHost := "s01.oss.sonatype.org"
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
/* ------------------------------------------------------------------------- */
/* BUILD INFO */
// Shared settings for the BuildInfo Plugin
// Allows access to apps metadata in runtime code
// See https://github.com/sbt/sbt-buildinfo
lazy val buildInfoSettings = Seq(
buildInfoKeys := Seq[BuildInfoKey](
name,
version,
scalaVersion,
sbtVersion
),
buildInfoPackage := "buildinfo",
buildInfoObject := "BuildInfo"
)
/* PACKAGING SETTINGS */
// Shared packaging settings for all modules
lazy val packagingSettings = Seq(
// Do not package logback files in .jar, they interfere with other logback
// files in classpath
Compile / packageBin / mappings ~= { project =>
project.filter { case (file, _) =>
val fileName = file.getName
!(fileName.startsWith("logback") && (fileName.endsWith(".xml") || fileName
.endsWith(".groovy")))
}
}
)
/* ------------------------------------------------------------------------- */
/* SBT GITHUB ACTIONS */
// GitHub Actions for build/test and clean are automatically generated
// The settings of these actions are configured here:
// - Scala versions used: scala 2.13, scala 3 (cross compiled)
// - Java versions used: LST 11, LTS 17
// - etc.
// See https://github.com/djspiewak/sbt-github-actions
lazy val ciScalaVersions = List(scala2_13, scala3_1)
lazy val ciJavaVersions = List(java11, java17)
// Specify which versions to be included in the GitHub Actions matrix when
// created by `githubWorkflowGenerate`
ThisBuild / githubWorkflowScalaVersions := ciScalaVersions
ThisBuild / githubWorkflowJavaVersions := ciJavaVersions
// Do not try to publish when building and testing, there's another action for that
ThisBuild / githubWorkflowPublishTargetBranches := Seq()
/* ------------------------------------------------------------------------- */
/* SCALADOC SETTINGS */
// Scaladoc settings for docs generation. Run task "doc" or "comet / doc".
// https://www.scala-sbt.org/1.x/docs/Howto-Scaladoc.html
// https://github.com/lampepfl/dotty/blob/main/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala#L62-L63
// https://github.com/scala/scala/blob/2.13.x/src/scaladoc/scala/tools/nsc/doc/Settings.scala
lazy val scaladocSettings: Seq[Def.Setting[_]] = Seq(
// Generate documentation on a separated "docs" folder
Compile / doc / target := baseDirectory.value / "target" / "scaladoc",
Compile / doc / scalacOptions ++= Seq(
// Base source path
"-sourcepath",
(LocalRootProject / baseDirectory).value.getAbsolutePath,
// Link to GitHub source
"-doc-source-url",
scmInfo.value.get.browseUrl + "/tree/master€{FILE_PATH}.scala",
// Page title
"-doc-title",
"Comet API - Docs",
// Docs version
"-doc-version",
version.value,
// Docs footer
"-doc-footer",
"By ulitol97 - <3",
// Other settings: include private members, etc.
"-private",
"-no-link-warnings"
) ++ {
// Skip unnecessary source generated by BuildInfo plugin
CrossVersion.partialVersion(scalaVersion.value) match {
// Scala 2
case Some((2, _)) => Seq(
"-skip-packages",
"org:buildinfo"
)
// Scala 3
case Some((3, _)) => Seq("-skip-by-id:buildinfo")
case _ => Seq()
}
},
// Need to generate docs to publish to OSS
Compile / packageDoc / publishArtifact := true
)
/* ------------------------------------------------------------------------- */
/* UNIDOC SETTINGS */
// Unidoc is used to generate Scaladoc for all modules and place it in a custom
// location inside the project's microsite
// See https://github.com/sbt/sbt-unidoc
lazy val unidocSettings: Seq[Def.Setting[_]] = Seq(
// Generate docs for the API module
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(api),
// Dump docs into the website static part, to link them with docusaurus
ScalaUnidoc / unidoc / target := (LocalRootProject / baseDirectory).value / websiteFolder / "static" / "scaladoc",
// When cleaning, remove unidoc generated docs as well
cleanFiles += (ScalaUnidoc / unidoc / target).value,
// Scalac options, mirroring scaladoc settings
ScalaUnidoc / unidoc / scalacOptions ++= (Compile / doc / scalacOptions).value
)
/* ------------------------------------------------------------------------- */
/* MDOC + DOCUSAURUS SETTINGS */
// Setup Mdoc + Docusaurus integration
// The docusaurus webpage will be located in /website
// See https://scalameta.org/mdoc/docs/docusaurus.html
// See https://docusaurus.io/
// Name of the directory inside the root folder containing the webdocs markdown
// For changes, edit docusaurus.config.js
lazy val docsFolder = "docs"
// Name of the directory inside the root folder containing the Docusaurus site
lazy val websiteFolder = "website"
lazy val mdocSettings = Seq(
mdocVariables := Map(
"APP_NAME" -> (Global / name).value.capitalize,
"APP_INNER_NAME" -> (Global / name).value,
"APP_VERSION" -> version.value,
"WEBPAGE_URL" -> "https://ulitol97.github.io/comet/",
"CLIENT_NAME" -> "RDFShape Client",
"CLIENT_REPO" -> "https://github.com/weso/rdfshape-client/",
"CLIENT_URL" -> "https://rdfshape.weso.es/",
"WEBSITE_FOLDER" -> websiteFolder,
"DOCS_FOLDER" -> docsFolder,
// Reference the Scala versions from webdocs
"SCALA_2_VERSION" -> scalaVersionPattern.replaceAllIn(scala2_13, ".x"),
"SCALA_3_VERSION" -> scalaVersionPattern.replaceAllIn(scala3_1, ".x"),
),
// No warnings reported for dead links
mdocExtraArguments := Seq("--no-link-hygiene"),
// When creating/publishing the docusaurus site,
// update the mdoc and scaladoc first
docusaurusCreateSite := docusaurusCreateSite
.dependsOn(Compile / unidoc)
.value,
docusaurusPublishGhpages :=
docusaurusPublishGhpages
.dependsOn(Compile / unidoc)
.value
)
/* ------------------------------------------------------------------------- */
/* TEST FRAMEWORKS */
// https://www.scala-sbt.org/1.x/docs/Testing.html
lazy val ScalaTestFramework = new TestFramework("scalatest.Framework")
/* ------------------------------------------------------------------------- */
/* DEPENDENCY VERSIONS */
// Core dependencies
lazy val catsVersion = "3.3.11"
// FS2 dependencies
lazy val fs2Version = "3.2.7"
lazy val fs2KafkaVersion = "3.0.0-M7"
// WESO dependencies
lazy val shaclexVersion = "0.2.2"
lazy val shexsVersion = "0.2.2"
lazy val umlShaclexVersion = "0.0.82"
lazy val wesoUtilsVersion = "0.2.4"
// Testing dependencies
lazy val scalaTestVersion = "3.2.12" // Usual testing
lazy val catsEffectTestingVersion = "1.4.0" // Integration of ScalaTest with cats-effect
// Other
lazy val scalaLoggingVersion = "3.9.4"
/* ------------------------------------------------------------------------- */
/* DEPENDENCIES */
// Core dependencies
lazy val catsEffect = "org.typelevel" %% "cats-effect" % catsVersion
// FS2 dependencies
lazy val fs2 = "co.fs2" %% "fs2-core" % fs2Version
lazy val fs2Kafka = "com.github.fd4s" %% "fs2-kafka" % fs2KafkaVersion
// WESO dependencies
lazy val shexs = "es.weso" %% "shexs" % shexsVersion
lazy val shaclex = "es.weso" %% "shaclex" % shaclexVersion
lazy val wesoUtils = "es.weso" %% "utilstest" % wesoUtilsVersion
// Testing dependencies
lazy val scalaTest = "org.scalatest" %% "scalatest" % scalaTestVersion % Test
lazy val catsEffectTesting =
"org.typelevel" %% "cats-effect-testing-scalatest" % catsEffectTestingVersion % Test
// Other
lazy val scalaLogging =
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingVersion