-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathbuild.sbt
More file actions
249 lines (227 loc) · 8.61 KB
/
build.sbt
File metadata and controls
249 lines (227 loc) · 8.61 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
import com.typesafe.tools.mima.core._
import sbtcrossproject.CrossPlugin.autoImport.crossProject
lazy val V = new {
def munit = "1.3.0"
def scalacheck = "1.19.0"
}
val scala212 = "2.12.21"
val scala213 = "2.13.18"
val scala3 = "3.3.7"
def isScala213 = Def.setting(scalaBinaryVersion.value == "2.13")
def isScala3 = Def.setting(scalaVersion.value.startsWith("3."))
val smorg = "org.scalameta"
val Scala2Versions = List(scala213, scala212)
val ScalaVersions = scala3 :: Scala2Versions
inThisBuild(List(
// version is set dynamically by sbt-dynver, but let's adjust it
version := {
val curVersion = version.value
def dynVer(out: sbtdynver.GitDescribeOutput): String = {
def tagVersion = out.ref.dropPrefix
if (out.isCleanAfterTag) tagVersion
else if (System.getenv("CI") == null) s"$tagVersion-next-SNAPSHOT" // modified for local builds
else if (out.commitSuffix.distance == 0) tagVersion
else if (sys.props.contains("backport.release")) tagVersion
else curVersion
}
dynverGitDescribeOutput.value.mkVersion(dynVer, curVersion)
},
useSuperShell := false,
organization := smorg,
licenses :=
Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
homepage := Some(url("https://github.com/scalameta/metaconfig")),
autoAPIMappings := true,
apiURL := Some(url("https://github.com/scalameta/metaconfig")),
developers += Developer(
"olafurpg",
"Ólafur Páll Geirsson",
"olafurpg@gmail.com",
url("https://geirsson.com"),
),
resolvers += Resolver.sonatypeCentralSnapshots,
versionScheme := Some("early-semver"),
))
addCommandAlias(
"scalafixAll",
s"; ++$scala212 ; scalafixEnable ; all scalafix test:scalafix",
)
addCommandAlias(
"scalafixCheckAll",
s"; ++$scala212 ; scalafixEnable ; scalafix --check ; test:scalafix --check",
)
addCommandAlias(
"native-image",
"; tests/graalvm-native-image:packageBin ; taskready",
)
commands += Command.command("taskready") { s =>
import scala.sys.process._
"afplay /System/Library/Sounds/Hero.aiff".!
s
}
val languageAgnosticCompatibilityPolicy: ProblemFilter = (problem: Problem) => {
val (ref, fullName) = problem match {
case problem: TemplateProblem => (problem.ref, problem.ref.fullName)
case problem: MemberProblem => (problem.ref, problem.ref.fullName)
}
val public = ref.isPublic
val include = fullName.startsWith("metaconfig.")
val exclude = fullName.contains(".internal.") ||
fullName.startsWith("metaconfig.cli")
public && include && !exclude
}
lazy val sharedSettings = Def.settings(
scalacOptions ++= { if (isScala3.value) Nil else Seq("-Yrangepos") },
scalacOptions += {
if (isScala213.value || isScala3.value) "-Wunused:imports"
else "-Ywarn-unused-import"
},
scalacOptions += "-deprecation",
scalacOptions += "-Xfatal-warnings",
scalacOptions ++= {
if (isScala213.value) "-Wconf:cat=deprecation:is" :: Nil
else if (isScala3.value) "-Wconf:cat=deprecation:silent" :: Nil
else Nil
},
scalacOptions ++=
{ if (isScala3.value) Nil else "-Wconf:cat=feature:is" :: Nil },
mimaBinaryIssueFilters += languageAgnosticCompatibilityPolicy,
crossScalaVersions := ScalaVersions,
scalaVersion := scala213,
)
lazy val mimaSettings = Def.settings(
mimaPreviousArtifacts := Set("com.geirsson" %% moduleName.value % "0.9.10"),
)
lazy val sharedJSSettings = Def.settings(
crossScalaVersions := Scala2Versions,
// to support Node.JS functionality
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)),
)
publish / skip := true
disablePlugins(MimaPlugin)
lazy val depPaiges = libraryDependencies +=
"org.typelevel" %%% "paiges-core" % "0.4.4"
def depScalacheck = libraryDependencies ++= List(
"org.scalacheck" %%% "scalacheck" % V.scalacheck,
smorg %%% "munit-scalacheck" % V.munit % Test,
)
lazy val pprint = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("metaconfig-pprint")).settings(
sharedSettings,
mimaSettings,
moduleName := "metaconfig-pprint",
libraryDependencies += "com.lihaoyi" %%% "fansi" % "0.5.1",
libraryDependencies ++= {
if (scalaVersion.value.startsWith("2.")) List(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
)
else Nil
},
)
lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("metaconfig-core")).settings(
sharedSettings,
mimaSettings,
moduleName := "metaconfig-core",
depPaiges,
libraryDependencies +=
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.14.0",
).settings(
libraryDependencies += {
val reflectVersion = if (isScala3.value) scala213 else scalaVersion.value
"org.scala-lang" % "scala-reflect" % reflectVersion
},
Compile / unmanagedSourceDirectories += {
// TODO: why isn't sbt-crossproject adding epoch scala version
// sources? it should
val scalaMajor = if (isScala3.value) "scala-3" else "scala-2"
baseDirectory.value / "shared" / "src" / "main" / scalaMajor
},
).dependsOn(pprint).jsSettings(
sharedJSSettings,
libraryDependencies +=
smorg %%% "io" % "4.15.2" cross CrossVersion.for3Use2_13,
)
lazy val cli = crossProject(JVMPlatform, NativePlatform)
.in(file("metaconfig-cli")).settings(
sharedSettings,
mimaSettings,
moduleName := "metaconfig-cli",
depPaiges,
).dependsOn(core)
lazy val typesafe = project.in(file("metaconfig-typesafe-config")).settings(
sharedSettings,
mimaSettings,
moduleName := "metaconfig-typesafe-config",
description := "Integration for HOCON using typesafehub/config.",
libraryDependencies += "com.typesafe" % "config" % "1.4.6",
).dependsOn(core.jvm)
lazy val sconfig = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("metaconfig-sconfig")).settings(
sharedSettings,
mimaSettings,
moduleName := "metaconfig-sconfig",
description := "Integration for HOCON using ekrich/sconfig.",
libraryDependencies += ("org.ekrich" %%% "sconfig" % "1.12.4").excludeAll(
"org.scala-lang.modules" %
s"scala-collection-compat_${scalaBinaryVersion.value}",
),
).platformsSettings(JSPlatform, NativePlatform)(
libraryDependencies += "org.ekrich" %%% "sjavatime" % "1.5.0",
).jsSettings(sharedJSSettings).dependsOn(core)
lazy val tests = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("metaconfig-tests")).disablePlugins(MimaPlugin).settings(
sharedSettings,
publish / skip := true,
Compile / packageDoc / publishArtifact := false,
testFrameworks := List(new TestFramework("munit.Framework")),
depScalacheck,
).jsSettings(sharedJSSettings).jvmSettings(
GraalVMNativeImage / mainClass := Some("metaconfig.tests.ExampleMain"),
Compile / doc / sources := Seq.empty,
libraryDependencies ++= {
if (scalaVersion.value.startsWith("2.")) Seq(
"com.github.alexarchambault" %%% "scalacheck-shapeless_1.15" % "1.3.0",
)
else Seq("org.typelevel" %% "shapeless3-deriving" % "3.5.0")
},
graalVMNativeImageOptions ++= {
val reflectionFile = (Compile / Keys.sourceDirectory).value / "graal" /
"reflection.json"
assert(reflectionFile.exists, "no such file: " + reflectionFile)
List(
"-H:+ReportUnsupportedElementsAtRuntime",
"--initialize-at-build-time",
"--initialize-at-run-time=metaconfig",
"--no-server",
"--enable-http",
"--enable-https",
"-H:EnableURLProtocols=http,https",
"--enable-all-security-services",
"--no-fallback",
s"-H:ReflectionConfigurationFiles=$reflectionFile",
"--allow-incomplete-classpath",
"-H:+ReportExceptionStackTraces",
)
},
).jvmEnablePlugins(GraalVMNativeImagePlugin)
.jvmConfigure(_.dependsOn(typesafe, cli.jvm)).dependsOn(core, sconfig)
lazy val docs = project.in(file("metaconfig-docs")).settings(
sharedSettings,
depScalacheck,
libraryDependencies += "com.lihaoyi" %%% "scalatags" % "0.13.1",
publish / skip := true,
dependencyOverrides +=
smorg %% "metaconfig-typesafe-config" % (ThisBuild / version).value,
moduleName := "metaconfig-docs",
mdocVariables := Map(
"VERSION" -> version.value.replaceFirst("\\+.*", ""),
"SCALA_VERSION" -> scalaVersion.value,
),
mdocOut := (ThisBuild / baseDirectory).value / "website" / "target" / "docs",
mdocExtraArguments := List("--no-link-hygiene"),
// mdoc's metaconfig might (and will eventually) lag behind the current version, causing eviction errors
evictionErrorLevel := Level.Warn,
).dependsOn(core.jvm, typesafe, sconfig.jvm).enablePlugins(DocusaurusPlugin)
.disablePlugins(MimaPlugin)