-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sbt
273 lines (262 loc) · 7.75 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
val scala212Ver = "2.12.20"
val scala213Ver = "2.13.16"
val scala3Ver = "3.3.4"
val githubId = "rayrobdod/string-context-parser-combinator"
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"
ThisBuild / dynverVTagPrefix := false
ThisBuild / organization := "name.rayrobdod"
lazy val sharedSettings = Seq(
sonatypeRepository := "https://s01.oss.sonatype.org/service/local",
organizationHomepage := Some(url("https://rayrobdod.name/")),
homepage := Some(url("https://rayrobdod.name/programming/libraries/scala/string-context-parser-combinator/")),
versionScheme := Some("early-semver"),
licenses := Seq(License.Apache2),
developers := List(
Developer(
"rayrobdod",
"Raymond Dodge",
url("https://rayrobdod.name"),
),
),
autoAPIMappings := true,
libraryDependencies += {
"org.scalameta" %%% "munit" % "1.1.0" % Test,
},
tpolecatExcludeOptions ++= Set(
org.typelevel.scalacoptions.ScalacOptions.warnUnusedNoWarn,
org.typelevel.scalacoptions.ScalacOptions.privateWarnUnusedNoWarn,
),
Compile / doc / scalacOptions ++= (scalaBinaryVersion.value match {
case "2.12" | "2.13" => Seq(
"-doc-title", name.value,
"-doc-version", (if ("-SNAPSHOT" == version.value) {"SNAPSHOT"} else {version.value}),
"-doc-root-content", ((Compile / docRootContentToWikidoc).value).toString,
"-doc-source-url", s"https://github.com/${githubId}/tree/${if (version.value.endsWith("-SNAPSHOT")) {git.gitHeadCommit.value.get} else {version.value}}€{FILE_PATH}.scala",
"-implicits",
"-groups",
"-sourcepath", baseDirectory.value.getParentFile.getParentFile.getParentFile.toString,
)
case _ => Seq(
"-doc-root-content", ((Compile / scalaSource).value / "rootdoc.md").toString,
"-groups",
"-project-version", (if ("-SNAPSHOT" == version.value) {"SNAPSHOT"} else {version.value}),
"-revision", git.gitHeadCommit.value.get,
"-scastie-configuration", Seq(
"resolvers ++= Resolver.sonatypeOssRepos(\"snapshots\")",
s"""libraryDependencies += "${organization.value}" %% "${name.value}" % "${version.value}""""
).mkString("\\n"),
"-siteroot", ((sourceDirectory).value / "docs").toString,
"-snippet-compiler:compile",
s"-social-links:github::https://github.com/${githubId}",
s"-source-links:github://${githubId}",
)
}),
Compile / doc / fileInputOptions += "-siteroot",
Test / testOptions += Tests.Argument(
"-oS",
),
)
lazy val sharedJsSettings = Seq(
tpolecatScalacOptions ++= {
val hash = git.gitHeadCommit.value.get
val local = (LocalRootProject / baseDirectory).value.toURI.toString
val remote = s"https://raw.githubusercontent.com/${githubId}/${hash}"
import org.typelevel.scalacoptions.ScalaVersion.V3_0_0
import scala.Ordering.Implicits._
Set(
org.typelevel.scalacoptions.ScalacOption(
s"-scalajs-mapSourceURI:$local->$remote/",
version => version >= V3_0_0,
),
org.typelevel.scalacoptions.ScalacOption(
s"-P:scalajs:mapSourceURI:$local->$remote/",
version => version < V3_0_0,
),
)
},
)
lazy val base = (projectMatrix in file("Base"))
.settings(sharedSettings)
.settings(
name := "string-context-parser-combinator",
description := "A scala library for writing custom string interpolation implementations using parser combinators",
apiURL := {
val suffix = scalaBinaryVersion.value match {
case "2.12" => "_2.12"
case "2.13" => "_2.13"
case "3" => ""
}
val v = version.value match {
case x if x.endsWith("-SNAPSHOT") => "SNAPSHOT"
case v => v
}
Some(url(s"https://rayrobdod.github.io/string-context-parser-combinator/${v}${suffix}/"))
},
Compile / packageBin / packageOptions += Package.ManifestAttributes(
"Automatic-Module-Name" -> "name.rayrobdod.stringContextParserCombinator"
),
Compile / doc / scalacOptions ++= (scalaBinaryVersion.value match {
case "2.12" | "2.13" => Seq(
)
case _ => Seq(
"-versions-dictionary-url", "https://rayrobdod.github.io/string-context-parser-combinator/versions.json",
)
}),
libraryDependencies ++= (scalaBinaryVersion.value match {
case "2.12" | "2.13" => Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
)
case _ => Seq()
}),
mimaPreviousArtifacts := Set(organization.value %% name.value % "0.1.0"),
tastyMiMaPreviousArtifacts := mimaPreviousArtifacts.value,
console / initialCommands := """
import scala.quoted.{Expr, Quotes}
import name.rayrobdod.stringContextParserCombinator.Interpolator.idInterpolators._
import name.rayrobdod.stringContextParserCombinator.typeclass._
""",
)
.jvmPlatform(scalaVersions = Seq(
scala212Ver,
scala213Ver,
scala3Ver,
))
.jsPlatform(
scalaVersions = Seq(
scala212Ver,
scala213Ver,
scala3Ver,
),
sharedJsSettings,
)
.nativePlatform(scalaVersions = Seq(
scala212Ver,
scala213Ver,
scala3Ver,
))
lazy val json = (projectMatrix in file("JsonParser"))
.dependsOn(base)
.disablePlugins(MimaPlugin)
.disablePlugins(TastyMiMaPlugin)
.settings(sharedSettings)
.settings(
name := "json",
publish / skip := true,
libraryDependencies ++= Seq(
"org.json4s" %%% "json4s-ast" % "4.0.7",
),
console / initialCommands := """
import org.json4s._
import name.rayrobdod.stringContextParserCombinatorExample.json._
""",
)
.jvmPlatform(scalaVersions = Seq(
scala212Ver,
scala213Ver,
scala3Ver,
))
.jsPlatform(
scalaVersions = Seq(
scala212Ver,
scala213Ver,
scala3Ver,
),
sharedJsSettings,
)
.nativePlatform(scalaVersions = Seq(
scala212Ver,
scala213Ver,
scala3Ver,
))
lazy val time = (projectMatrix in file("TimeParser"))
.dependsOn(base)
.disablePlugins(MimaPlugin)
.disablePlugins(TastyMiMaPlugin)
.settings(sharedSettings)
.settings(
name := "time",
publish / skip := true,
console / initialCommands := """
import java.time._
import name.rayrobdod.stringContextParserCombinatorExample.datetime._
""",
)
.jvmPlatform(scalaVersions = Seq(
scala212Ver,
scala213Ver,
scala3Ver,
))
.jsPlatform(
scalaVersions = Seq(
scala212Ver,
scala213Ver,
scala3Ver,
),
Seq(
libraryDependencies ++= Seq(
"io.github.cquiroz" %%% "scala-java-time" % "2.6.0",
),
) ++
sharedJsSettings,
)
.nativePlatform(
scalaVersions = Seq(
scala212Ver,
scala213Ver,
scala3Ver,
),
Seq(
libraryDependencies ++= Seq(
"io.github.cquiroz" %%% "scala-java-time" % "2.6.0",
),
)
)
lazy val uri = (projectMatrix in file("UriParser"))
.dependsOn(base)
.disablePlugins(MimaPlugin)
.disablePlugins(TastyMiMaPlugin)
.settings(sharedSettings)
.settings(
name := "uri",
publish / skip := true,
console / initialCommands := """
import java.net.URI
import name.rayrobdod.stringContextParserCombinatorExample.uri._
""",
)
.jvmPlatform(scalaVersions = Seq(
scala212Ver,
scala213Ver,
scala3Ver,
))
lazy val xml = (projectMatrix in file("XmlParser"))
.dependsOn(base)
.disablePlugins(MimaPlugin)
.disablePlugins(TastyMiMaPlugin)
.settings(sharedSettings)
.settings(
name := "xml",
publish / skip := true,
libraryDependencies ++= Seq(
"org.scala-lang.modules" %%% "scala-xml" % "2.3.0",
),
console / initialCommands := """
import name.rayrobdod.stringContextParserCombinatorExample.xml._
""",
)
.jvmPlatform(scalaVersions = Seq(
scala3Ver,
))
disablePlugins(MimaPlugin)
disablePlugins(TastyMiMaPlugin)
autoScalaLibrary := false
publish / skip := true
enablePlugins(StageWebsitePlugin)
webSnapshotVariants := Map(
"2.12" -> (base.jvm(scala212Ver) / Compile / packageDoc / mappings).value,
"2.13" -> (base.jvm(scala213Ver) / Compile / packageDoc / mappings).value,
"3" -> (base.jvm(scala3Ver) / Compile / packageDoc / mappings).value,
)
webStage / mappings += ((base.jvm(scala3Ver) / sourceDirectory).value / "docs" / "versions.json") -> "versions.json"