-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.sbt
232 lines (212 loc) · 7.77 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
import java.util.Date
import com.typesafe.tools.mima.core._
import sbtcrossproject.CrossPlugin.autoImport.crossProject
lazy val V = new {
def munit = "1.0.0"
def scalacheck = "1.18.1"
}
val scala212 = "2.12.20"
val scala213 = "2.13.15"
val scala3 = "3.3.4"
def isScala213 = Def.setting(scalaBinaryVersion.value == "2.13")
def isScala3 = Def.setting(scalaVersion.value.startsWith("3."))
val ScalaVersions = List(scala213, scala212, scala3)
inThisBuild(List(
version ~= { dynVer =>
if (System.getenv("CI") != null) dynVer
else {
import scala.sys.process._
// drop `v` prefix
"git describe --abbrev=0 --tags".!!.drop(1).trim + "-SNAPSHOT"
}
},
useSuperShell := false,
organization := "org.scalameta",
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",
url("https://geirsson.com"),
),
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
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"),
)
publish / skip := true
disablePlugins(MimaPlugin)
lazy val pprint = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("metaconfig-pprint")).settings(
sharedSettings,
mimaSettings,
moduleName := "metaconfig-pprint",
libraryDependencies += "com.lihaoyi" %%% "fansi" % "0.5.0",
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",
libraryDependencies ++= List(
"org.typelevel" %%% "paiges-core" % "0.4.4",
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.12.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
if (scalaVersion.value.startsWith("2")) Seq(
(ThisBuild / baseDirectory).value / "metaconfig-core" / "shared" /
"src" / "main" / "scala-2",
)
else Seq.empty
},
).dependsOn(pprint)
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.3",
).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 ++= List("org.ekrich" %%% "sconfig" % "1.8.1"),
).platformsSettings(JSPlatform, NativePlatform)(
libraryDependencies ++= List("org.ekrich" %%% "sjavatime" % "1.3.0"),
).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")),
libraryDependencies ++= List(
"org.scalacheck" %%% "scalacheck" % V.scalacheck,
"org.scalameta" %%% "munit-scalacheck" % V.munit % Test,
),
)
.jsSettings(scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)))
.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.4.3")
},
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",
)
},
).jvmConfigure(_.enablePlugins(GraalVMNativeImagePlugin).dependsOn(
typesafe,
sconfig.jvm,
)).dependsOn(core)
lazy val docs = project.in(file("metaconfig-docs")).settings(
sharedSettings,
libraryDependencies ++= List(
"com.lihaoyi" %%% "scalatags" % "0.13.1",
"org.scalacheck" %%% "scalacheck" % V.scalacheck,
"org.scalameta" %%% "munit-scalacheck" % V.munit % Test,
),
publish / skip := true,
dependencyOverrides +=
"org.scalameta" %% "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)