forked from russwyte/mechanoid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sbt
More file actions
212 lines (194 loc) · 8.46 KB
/
build.sbt
File metadata and controls
212 lines (194 loc) · 8.46 KB
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
val scala3Version = "3.8.2"
val zioVersion = "2.1.24"
// lets enable semanticdb
ThisBuild / semanticdbEnabled := true
ThisBuild / scalaVersion := scala3Version
ThisBuild / organization := sys.env.getOrElse("PUBLISH_ORG", "io.github.russwyte")
ThisBuild / organizationName := sys.env.getOrElse("PUBLISH_ORG_NAME", "russwyte")
ThisBuild / organizationHomepage := Some(url("https://github.com/russwyte"))
ThisBuild / licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
ThisBuild / homepage := Some(url("https://github.com/russwyte/mechanoid"))
ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/russwyte/mechanoid"),
"scm:git@github.com:russwyte/mechanoid.git",
)
)
ThisBuild / developers := List(
Developer(
id = "russwyte",
name = "Russ White",
email = "356303+russwyte@users.noreply.github.com",
url = url("https://github.com/russwyte"),
)
)
ThisBuild / versionScheme := Some("early-semver")
// --- Fork publishing support (GitHub Packages) ---
// Forks set PUBLISH_PACKAGES_REPO and GITHUB_TOKEN in CI to publish to their own GitHub Packages.
// Optionally set PUBLISH_ORG and PUBLISH_ORG_NAME to change the Maven group ID.
val githubPackagesRepo: Option[MavenRepository] =
sys.env.get("PUBLISH_PACKAGES_REPO").map("GitHub Packages" at _)
ThisBuild / credentials ++= sys.env
.get("GITHUB_TOKEN")
.map { token =>
Credentials("GitHub Package Registry", "maven.pkg.github.com", "_", token)
}
.toSeq
ThisBuild / resolvers ++= githubPackagesRepo.toSeq
// PGP signing: only when publishing to Maven Central (forks targeting GitHub Packages won't have the key)
githubPackagesRepo match {
case None => usePgpKeyHex("2F64727A87F1BCF42FD307DD8582C4F16659A7D6")
case Some(_) => Seq.empty
}
ThisBuild / libraryDependencies ++= Seq(
"dev.zio" %% "zio" % zioVersion % "provided",
"dev.zio" %% "zio-streams" % zioVersion % "provided",
"dev.zio" %% "zio-logging" % "2.5.3" % "provided",
"dev.zio" %% "zio-logging-slf4j" % "2.5.3" % "provided",
"dev.zio" %% "zio-logging-slf4j-bridge" % "2.5.3" % "provided",
"dev.zio" %% "zio-json" % "0.8.0" % "provided",
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test,
"dev.zio" %% "zio-test-magnolia" % zioVersion % Test,
)
lazy val commonSettings = Seq(
scalacOptions ++= Seq(
"-deprecation",
"-Wunused:all",
"-feature",
),
scalafixDependencies += "com.github.vovapolu" %% "scaluzzi" % "0.1.23",
// Exclude macros, inline methods, and export-only package objects from coverage
// - Macros/inline run at compile time, incompatible with scoverage
// - Mechanoid$package is just type re-exports with no runtime code
coverageExcludedPackages := "mechanoid\\.macros\\..*;mechanoid\\.machine\\.Macros.*;mechanoid\\.machine\\.MacroUtils.*;mechanoid\\.machine\\.AssemblyMacros.*;mechanoid\\.machine\\.MachineMacros.*;mechanoid\\.machine\\.ProducingMacros.*;mechanoid\\.core\\.Finite.*;mechanoid\\.core\\.Redactor.*;mechanoid\\.Mechanoid\\$package.*",
// Minimum coverage thresholds - fail build if coverage drops below these
coverageFailOnMinimum := true,
coverageMinimumStmtTotal := 95,
coverageMinimumBranchTotal := 95,
)
lazy val publishSettings = Seq(
publishMavenStyle := true,
pomIncludeRepository := { _ => false },
publishTo := githubPackagesRepo.map(r => r: Resolver).orElse(localStaging.value),
)
addCommandAlias("testCoverage", "clean; coverage; test; coverageAggregate; coverageReport")
// Parameterized coverage command: moduleCoverage <module>
// Example: sbt "moduleCoverage core" or sbt "moduleCoverage postgres"
commands += Command.single("moduleCoverage") { (state, module) =>
s"clean; coverage; $module/test; $module/coverageReport" :: state
}
lazy val root = project
.in(file("."))
.aggregate(core, postgres, examples, compileTimeChecks)
.settings(
name := "mechanoid-root",
publish / skip := true,
)
lazy val core = project
.in(file("core"))
.settings(commonSettings)
.settings(publishSettings)
.settings(
name := "mechanoid",
description := "A type-safe, effect-oriented finite state machine library for Scala built on ZIO",
)
lazy val postgres = project
.in(file("postgres"))
.dependsOn(core % "compile->compile;test->test")
.settings(commonSettings)
.settings(publishSettings)
.settings(
name := "mechanoid-postgres",
description := "PostgreSQL persistence implementation for Mechanoid FSM library",
libraryDependencies ++= Seq(
"io.github.russwyte" %% "saferis" % "0.12.0",
"org.postgresql" % "postgresql" % "42.7.10",
"org.testcontainers" % "postgresql" % "1.21.4" % Test,
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test,
),
// Override vulnerable transitive deps from testcontainers -> docker-java
dependencyOverrides ++= Seq(
"com.fasterxml.jackson.core" % "jackson-core" % "2.18.6",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.18.6",
"org.apache.commons" % "commons-compress" % "1.28.0",
),
)
lazy val examples = project
.in(file("examples"))
.dependsOn(core, postgres)
.settings(commonSettings)
.settings(
name := "mechanoid-examples",
publish / skip := true,
// ZIO deps are "provided" at root level, so examples needs them explicitly
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % zioVersion,
"dev.zio" %% "zio-streams" % zioVersion,
"dev.zio" %% "zio-json" % "0.8.0",
"dev.zio" %% "zio-logging" % "2.5.3",
"dev.zio" %% "zio-logging-slf4j" % "2.5.3",
"dev.zio" %% "zio-logging-slf4j-bridge" % "2.5.3",
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test,
),
assembly / mainClass := Some("mechanoid.examples.heartbeat.Main"),
assembly / assemblyJarName := "app.jar",
assembly / assemblyMergeStrategy := {
case PathList("META-INF", "MANIFEST.MF") => MergeStrategy.discard
case PathList("META-INF", xs @ _*) if xs.lastOption.exists(_.endsWith(".SF")) => MergeStrategy.discard
case PathList("META-INF", xs @ _*) if xs.lastOption.exists(_.endsWith(".DSA")) => MergeStrategy.discard
case PathList("META-INF", xs @ _*) if xs.lastOption.exists(_.endsWith(".RSA")) => MergeStrategy.discard
case PathList("META-INF", "services", _*) => MergeStrategy.concat
case PathList("reference.conf") => MergeStrategy.concat
case _ => MergeStrategy.first
},
)
lazy val compileExperiments = project
.in(file("compile-experiments"))
.dependsOn(core)
.settings(commonSettings)
.settings(
name := "compile-experiments",
publish / skip := true,
)
lazy val compileTimeChecks = project
.in(file("compile-time-checks"))
.dependsOn(core)
.settings(
name := "compile-time-checks",
publish / skip := true,
// Turn warnings into errors so typeCheck can catch them
scalacOptions ++= Seq(
"-Werror",
"-deprecation",
"-feature",
),
libraryDependencies ++= Seq(
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test,
),
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"),
)
lazy val docs = project
.in(file("mechanoid-docs"))
.dependsOn(core, postgres)
.enablePlugins(MdocPlugin)
.settings(
name := "mechanoid-docs",
publish / skip := true,
mdocVariables := Map(
"VERSION" -> version.value
),
mdocIn := baseDirectory.value / "docs",
mdocOut := (ThisBuild / baseDirectory).value,
// ZIO deps are "provided" at root level, so mdoc needs them explicitly
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % zioVersion,
"dev.zio" %% "zio-streams" % zioVersion,
"dev.zio" %% "zio-json" % "0.8.0",
),
// Override vulnerable transitive dep from mdoc -> undertow
dependencyOverrides += "io.undertow" % "undertow-core" % "2.2.39.Final",
)