-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sbt
More file actions
227 lines (210 loc) · 7.27 KB
/
build.sbt
File metadata and controls
227 lines (210 loc) · 7.27 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations.*
import org.scalajs.linker.interface.ModuleSplitStyle
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
import scala.sys.process.*
lazy val refreshFlakeTask = taskKey[Unit]("Refresh flake.nix")
lazy val isLinux: Boolean = System.getProperty("os.name").toLowerCase.contains("linux")
lazy val isAmd64: Boolean = System.getProperty("os.arch") == "amd64"
ThisBuild / scalaVersion := "2.13.16"
lazy val izumiVersion = "1.2.24"
// Shared settings for both JVM and JS
lazy val sharedSettings = Seq(
name := "baboon",
libraryDependencies ++= Seq("com.lihaoyi" %%% "fastparse" % "3.1.1"),
libraryDependencies ++= Seq(
"fundamentals-platform",
"fundamentals-functional",
"fundamentals-language",
"fundamentals-collections",
"distage-core",
).map("io.7mind.izumi" %%% _ % izumiVersion),
libraryDependencies ++= Seq(
"io.github.classgraph" % "classgraph" % "4.8.181"
),
libraryDependencies ++= Seq(
"org.scala-lang.modules" %%% "scala-parser-combinators" % "2.4.0"
),
libraryDependencies ++= Seq(
"org.scalatest" %%% "scalatest" % "3.2.19" % Test,
),
libraryDependencies ++= Seq(
"io.circe" %%% "circe-core",
"io.circe" %%% "circe-generic",
"io.circe" %%% "circe-parser"
).map(_ % "0.14.1"),
libraryDependencies ++= Seq(
"com.softwaremill.magnolia1_2" %%% "magnolia" % "1.1.10",
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided"
),
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.13.3" cross CrossVersion.full),
scalacOptions ++= Seq(
s"-Xmacro-settings:product-name=${name.value}",
s"-Xmacro-settings:product-version=${version.value}",
s"-Xmacro-settings:product-group=${organization.value}",
s"-Xmacro-settings:scala-version=${scalaVersion.value}",
s"-Xmacro-settings:scala-versions=${crossScalaVersions.value.mkString(":")}"
),
scalacOptions ++= Seq(
"-Wconf:cat=other-match-analysis:error",
"-encoding",
"utf8",
"-deprecation",
"-feature",
"-unchecked",
"-language:experimental.macros",
"-language:higherKinds",
"-language:implicitConversions",
"-explaintypes",
"-Xsource:3-cross",
"-Wdead-code",
"-Wextra-implicit",
"-Wnumeric-widen",
"-Woctal-literal",
"-Wvalue-discard",
"-Wunused:_",
"-Wmacros:after",
"-Ycache-plugin-class-loader:always",
"-Ycache-macro-class-loader:last-modified",
"-Wconf:msg=nowarn:silent",
"-Wconf:any:warning",
"-Wconf:cat=optimizer:warning",
"-Wconf:cat=other-match-analysis:error",
"-Vtype-diffs",
"-P:kind-projector:underscore-placeholders"
)
)
// Cross-platform project with CrossType.Pure
lazy val baboon = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("baboon-compiler"))
.settings(sharedSettings)
.jvmSettings(
Compile / unmanagedResourceDirectories += baseDirectory.value / "src" / "main" / "resources",
libraryDependencies ++= Seq(
"com.github.alexarchambault" %% "case-app" % "2.1.0-M30",
"org.jline" % "jline" % "3.26.3",
"io.7mind.izumi" %% "distage-testkit-scalatest" % izumiVersion % Test
)
)
.jvmConfigure(_.enablePlugins(GraalVMNativeImagePlugin, UniversalPlugin))
.jvmSettings(
GraalVMNativeImage / mainClass := Some("io.septimalmind.baboon.Baboon"),
graalVMNativeImageOptions ++= Seq(
"-H:-CheckToolchain", // fixes Darwin builds under Nix
"-H:+UnlockExperimentalVMOptions",
"--no-fallback",
"-H:+ReportExceptionStackTraces",
"--report-unsupported-elements-at-runtime",
"--enable-https",
"--enable-http",
"-march=compatibility"
) ++ (if (isLinux && isAmd64) Seq("--static", "--libc=musl") else Seq.empty),
run / fork := true,
refreshFlakeTask := {
val log = streams.value.log
val rootDir = (ThisBuild / baseDirectory).value
val lockfileConfig = rootDir / "lockfile-config.json"
val lockfileOutput = rootDir / "deps.lock.json"
val refreshCommand = Process(
Seq("nix", "develop", "--command", "squish-lockfile", lockfileConfig.getPath),
rootDir
)
val result = (refreshCommand #> lockfileOutput).!(log)
if (result != 0) {
throw new MessageOnlyException(s"flake.nix update failed: squish-lockfile exited with $result")
}
val gitAdd = Process(Seq("git", "add", lockfileOutput.getPath), rootDir)
val gitResult = gitAdd.!(log)
if (gitResult != 0) {
throw new MessageOnlyException(s"git add failed with exit code $gitResult")
}
}
)
.jsSettings(
scalaJSLinkerConfig ~= {
_.withModuleKind(ModuleKind.ESModule)
.withModuleSplitStyle(ModuleSplitStyle.SmallestModules)
},
scalaJSUseMainModuleInitializer := false,
libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.6.0",
)
// Define JVM and JS projects
lazy val baboonJVM = baboon.jvm
lazy val baboonJS = baboon.js
// Root aggregate project
lazy val root = project
.in(file("."))
.aggregate(baboonJVM, baboonJS)
// .aggregate(baboonJVM)
.settings(
name := "baboon-root",
publish / skip := true,
publishLocal / skip := true,
Compile / sources := Seq.empty,
Test / sources := Seq.empty,
releaseProcess := releaseSteps
)
lazy val refreshFlake: ReleaseStep = releaseStepTask(baboonJVM / refreshFlakeTask)
lazy val releaseSteps: Seq[ReleaseStep] = Seq(
checkSnapshotDependencies,
refreshFlake,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
setNextVersion,
commitNextVersion,
pushChanges
)
ThisBuild / releaseProcess := releaseSteps
ThisBuild / scalacOptions ++= Seq(
s"-Xmacro-settings:sbt-version=${sbtVersion.value}",
s"-Xmacro-settings:git-repo-clean=${com.github.sbt.git.SbtGit.GitKeys.gitUncommittedChanges.value}",
s"-Xmacro-settings:git-branch=${com.github.sbt.git.SbtGit.GitKeys.gitCurrentBranch.value}",
s"-Xmacro-settings:git-described-version=${com.github.sbt.git.SbtGit.GitKeys.gitDescribedVersion.value
.getOrElse("")}",
s"-Xmacro-settings:git-head-commit=${com.github.sbt.git.SbtGit.GitKeys.gitHeadCommit.value.getOrElse("")}"
)
ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/7mind/baboon"),
"scm:git@github.com:7mind/baboon.git"
)
)
ThisBuild / organization := "io.7mind.izumi"
ThisBuild / publishTo := {
if (isSnapshot.value) {
Some(
"central-snapshots" at "https://central.sonatype.com/repository/maven-snapshots/"
)
} else {
localStaging.value
}
}
ThisBuild / credentials ++= Seq(
Path.userHome / ".sbt" / "secrets" / "credentials.sonatype-new.properties",
Path.userHome / ".sbt" / "secrets" / "credentials.sonatype-nexus.properties",
file(".") / ".secrets" / "credentials.sonatype-nexus.properties",
)
.filter(_.exists())
.map(Credentials.apply)
ThisBuild / homepage := Some(url("https://github.com/7mind/baboon"))
ThisBuild / licenses := Seq(
"BSD-style" -> url("http://www.opensource.org/licenses/mit-license.php")
)
ThisBuild / developers := List(
Developer(
id = "7mind",
name = "Septimal Mind",
url = url("https://github.com/7mind"),
email = "team@7mind.io",
)
)
ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/7mind/baboon"),
"scm:git:https://github.com/7mind/baboon.git",
)
)