-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.sbt
195 lines (181 loc) · 6.32 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
// https://typelevel.org/sbt-typelevel/faq.html#what-is-a-base-version-anyway
ThisBuild / tlBaseVersion := "0.0" // your current series x.y
ThisBuild / organization := "pink.cozydev"
ThisBuild / organizationName := "CozyDev"
ThisBuild / startYear := Some(2022)
ThisBuild / licenses := Seq(License.Apache2)
ThisBuild / developers := List(
// your GitHub handle and name
tlGitHubDev("valencik", "Andrew Valencik"),
tlGitHubDev("samspills", "Sam Pillsworth"),
)
// publish website from this branch
ThisBuild / tlSitePublishBranch := Some("main")
ThisBuild / resolvers +=
"SonaType Snapshots".at("https://s01.oss.sonatype.org/content/repositories/snapshots/")
// use JDK 11
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("11"))
ThisBuild / tlJdkRelease := Some(11)
val Scala212 = "2.12.20"
val Scala213 = "2.13.16"
val Scala3 = "3.3.5"
ThisBuild / crossScalaVersions := Seq(Scala212, Scala213, Scala3)
ThisBuild / scalaVersion := Scala212 // the default Scala
// Plugin setup stolen from Laika with love
ThisBuild / githubWorkflowBuildMatrixExclusions ++=
List("2.13", "3").map(scala => MatrixExclude(Map("project" -> "plugin", "scala" -> scala)))
ThisBuild / githubWorkflowBuildMatrixAdditions ~= { matrix =>
matrix + ("project" -> (matrix("project") :+ "plugin"))
}
val catsEffectV = "3.5.7"
val catsV = "2.13.0"
val fs2V = "3.11.0"
val laikaV = "1.3.1"
val lucilleV = "0.0.3"
val munitCatsEffectV = "2.0.0"
val munitV = "1.1.0"
val scalajsDomV = "2.8.0"
def scodecV(scalaV: String) = if (scalaV.startsWith("2.")) "1.11.10" else "2.3.2"
val scalametaV = "4.13.3"
lazy val root =
tlCrossRootProject
.aggregate(
core,
laikaIO,
jsInterop,
)
.configureRoot { root =>
root.aggregate(plugin, scaladoc) // don't include the plugin in rootJVM, only in root
}
lazy val core = crossProject(JVMPlatform, JSPlatform)
.crossType(CrossType.Pure)
.in(file("core"))
.settings(
name := "protosearch",
Compile / run / fork := true,
// forward stdin to forked process
Compile / run / connectInput := true,
// send forked output to stdout
outputStrategy := Some(StdoutOutput),
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % catsV,
"org.typelevel" %%% "cats-effect" % catsEffectV,
"org.scodec" %%% "scodec-core" % scodecV(scalaVersion.value),
"pink.cozydev" %%% "lucille" % lucilleV,
"org.scalameta" %%% "munit" % munitV % Test,
"org.typelevel" %%% "munit-cats-effect" % munitCatsEffectV % Test,
),
)
lazy val laikaIO = crossProject(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("laikaIO"))
.dependsOn(core)
.settings(
name := "protosearch-laika",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % catsV,
"org.typelevel" %%% "cats-effect" % catsEffectV,
"co.fs2" %%% "fs2-core" % fs2V,
"co.fs2" %%% "fs2-io" % fs2V,
"org.scodec" %%% "scodec-core" % scodecV(scalaVersion.value),
"pink.cozydev" %%% "lucille" % lucilleV,
"org.typelevel" %%% "laika-core" % laikaV,
"org.typelevel" %%% "laika-io" % laikaV,
"org.scalameta" %%% "munit" % munitV % Test,
"org.typelevel" %%% "munit-cats-effect" % munitCatsEffectV % Test,
),
Compile / packageBin / mappings += {
val jsArtifactInterop = (jsInterop.js / Compile / fullOptJS).value.data
val inDir = baseDirectory.value / "src" / "main" / "resources"
val dir = "pink/cozydev/protosearch/sbt"
jsArtifactInterop -> s"$dir/protosearch.js"
},
)
lazy val scaladoc = project
.in(file("scaladoc"))
.dependsOn(core.jvm)
.settings(
name := "protosearch-scaladoc",
crossScalaVersions := Seq(Scala212),
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit" % munitV % Test,
"org.scalameta" %%% "scalameta" % scalametaV,
),
)
lazy val jsInterop = crossProject(JSPlatform)
.crossType(CrossType.Pure)
.in(file("jsinterop"))
.dependsOn(core)
.settings(
name := "protosearch-jsinterop",
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % scalajsDomV
),
)
lazy val plugin =
project
.in(file("sbt"))
.dependsOn(core.jvm, laikaIO.jvm, scaladoc)
.enablePlugins(SbtPlugin)
.settings(
name := "protosearch-sbt",
sbtPlugin := true,
crossScalaVersions := Seq(Scala212),
addSbtPlugin("org.typelevel" % "laika-sbt" % laikaV),
addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % "0.7.7"),
Compile / packageBin / mappings += {
val jsArtifactInterop = (jsInterop.js / Compile / fullOptJS).value.data
val inDir = baseDirectory.value / "src" / "main" / "resources"
val dir = "pink/cozydev/protosearch/sbt"
jsArtifactInterop -> s"$dir/protosearch.js"
},
)
import laika.helium.config.{IconLink, HeliumIcon}
lazy val docs = project
.in(file("site"))
.enablePlugins(TypelevelSitePlugin)
.dependsOn(core.jvm, jsInterop.js)
.settings(
tlSiteHelium ~= {
import laika.helium.config._
import laika.ast.Path.Root
_.site
.topNavigationBar(
// override default because our README.md is a symlink
homeLink = IconLink.internal(Root / "index.md", HeliumIcon.home)
)
.site
.pageNavigation(keepOnSmallScreens = true)
.site
.mainNavigation(appendLinks =
Seq(
ThemeNavigationSection(
"Related Projects",
TextLink.external("https://lucene.apache.org/", "lucene"),
TextLink.external("https://github.com/cozydev-pink/lucille", "lucille"),
TextLink.external("https://github.com/cozydev-pink/textmogrify", "textmogrify"),
)
)
)
},
laikaInputs := {
import laika.ast.Path.Root
import laika.io.model.FilePath
val jsArtifactInterop = (jsInterop.js / Compile / fullOptJS / artifactPath).value
val sourcemapInterop = jsArtifactInterop.getName + ".map"
laikaInputs.value.delegate
.addFile(
FilePath.fromJavaFile(jsArtifactInterop),
Root / "interop" / "index.js",
)
.addFile(
FilePath.fromNioPath(jsArtifactInterop.toPath.resolveSibling(sourcemapInterop)),
Root / "interop" / sourcemapInterop,
)
},
laikaSite := laikaSite
.dependsOn(
jsInterop.js / Compile / fullOptJS
)
.value,
)