forked from typelevel/Laika
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
236 lines (216 loc) · 7.4 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
import laika.markdown.github.GitHubFlavor
import laika.parse.code.SyntaxHighlighting
import sbt.Keys.{ artifactPath, crossScalaVersions }
import org.scalajs.linker.interface.ESVersion
import Dependencies._
lazy val basicSettings = Seq(
version := "0.19.2-SNAPSHOT",
homepage := Some(new URL("https://typelevel.org/Laika/")),
organization := "org.planet42",
organizationHomepage := Some(new URL("http://typelevel.org")),
description := "Text Markup Transformer for sbt and Scala applications",
startYear := Some(2012),
licenses := Seq("Apache 2.0" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt")),
scalaVersion := versions.scala2_12,
scalacOptions ++= (Opts.compile.encoding("UTF-8") :+
Opts.compile.deprecation :+
Opts.compile.unchecked :+
"-feature" :+
"-language:implicitConversions" :+
"-language:postfixOps" :+
"-language:higherKinds") ++
(if (priorTo2_13(scalaVersion.value)) Seq("-Ypartial-unification") else Nil)
)
val mimaPreviousVersions = Set("0.19.0")
val previousArtifacts = Seq(
mimaPreviousArtifacts := mimaPreviousVersions
.map(v => projectID.value.withRevision(v).withExplicitArtifacts(Vector.empty))
)
def priorTo2_13(version: String): Boolean =
CrossVersion.partialVersion(version) match {
case Some((2, minor)) if minor < 13 => true
case _ => false
}
lazy val moduleSettings = basicSettings ++ previousArtifacts ++ Seq(
crossScalaVersions := Seq(versions.scala2_12, versions.scala2_13, versions.scala3)
)
lazy val publishSettings = Seq(
publishMavenStyle := true,
Test / publishArtifact := false,
pomIncludeRepository := { _ => false },
publishTo := {
if (version.value.trim.endsWith("SNAPSHOT")) None
else Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
},
pomExtra := (<scm>
<url>https://github.com/typelevel/Laika.git</url>
<connection>scm:git:https://github.com/typelevel/Laika.git</connection>
</scm>
<developers>
<developer>
<id>jenshalm</id>
<name>Jens Halm</name>
<url>http://planet42.org</url>
</developer>
</developers>)
)
lazy val noPublishSettings = Seq(
publish := (()),
publishLocal := (()),
publishTo := None
)
val munit = "org.scalameta" %% "munit" % versions.munit % "test"
val jTidy = "net.sf.jtidy" % "jtidy" % versions.jTidy % "test"
val catsEffect = "org.typelevel" %% "cats-effect" % versions.catsEffect
val fs2IO = "co.fs2" %% "fs2-io" % versions.fs2
val munitCE3 = "org.typelevel" %% "munit-cats-effect-3" % versions.munitCE3 % "test"
val fop = "org.apache.xmlgraphics" % "fop" % versions.fop
val http4s = Seq(
"org.http4s" %% "http4s-dsl" % versions.http4s,
"org.http4s" %% "http4s-ember-server" % versions.http4s
)
lazy val root = project.in(file("."))
.aggregate(core.js, core.jvm, pdf, io, preview, plugin)
.settings(basicSettings)
.settings(noPublishSettings)
.enablePlugins(ScalaUnidocPlugin)
.disablePlugins(MimaPlugin)
.settings(
crossScalaVersions := Nil,
ScalaUnidoc / unidoc / unidocProjectFilter := inAnyProject -- inProjects(
plugin,
core.js,
demo.jvm,
demo.js
)
)
lazy val docs = project.in(file("docs"))
.dependsOn(plugin)
.enablePlugins(LaikaPlugin)
.enablePlugins(MdocPlugin)
.enablePlugins(SbtPlugin)
.settings(noPublishSettings)
.settings(
name := "laika-docs",
laikaTheme := ManualSettings.helium,
laikaConfig := ManualSettings.config,
laikaExtensions := Seq(GitHubFlavor, SyntaxHighlighting, ManualBundle),
Laika / sourceDirectories := Seq(mdocOut.value),
Laika / target := baseDirectory.value / "target",
mdocIn := baseDirectory.value / "src",
mdocVariables := Map(
"LAIKA_VERSION" -> "0.19.1"
),
mdocExtraArguments := Seq("--no-link-hygiene")
)
lazy val core = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Full)
.in(file("core"))
.settings(moduleSettings)
.settings(publishSettings)
.settings(
name := "laika-core",
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit" % versions.munit % "test",
"org.typelevel" %%% "cats-core" % versions.catsCore
)
)
.jvmSettings(
libraryDependencies += jTidy
)
.jsSettings(
Test / scalaJSLinkerConfig ~= {
_.withModuleKind(ModuleKind.CommonJSModule).withESFeatures(_.withESVersion(ESVersion.ES2018))
}
)
lazy val io = project.in(file("io"))
.dependsOn(core.jvm % "compile->compile;test->test")
.settings(moduleSettings)
.settings(publishSettings)
.settings(
name := "laika-io",
libraryDependencies ++= Seq(catsEffect, fs2IO, munit, munitCE3)
)
lazy val pdf = project.in(file("pdf"))
.dependsOn(core.jvm % "compile->compile;test->test", io % "compile->compile;test->test")
.settings(moduleSettings)
.settings(publishSettings)
.settings(
name := "laika-pdf",
libraryDependencies ++= Seq(fop, munit)
)
lazy val preview = project.in(file("preview"))
.dependsOn(core.jvm, io % "compile->compile;test->test", pdf)
.settings(moduleSettings)
.settings(publishSettings)
.settings(
name := "laika-preview",
libraryDependencies ++= (http4s :+ munit)
)
lazy val plugin = project.in(file("sbt"))
.dependsOn(core.jvm, io, pdf, preview)
.enablePlugins(SbtPlugin)
.settings(basicSettings)
.settings(previousArtifacts)
.settings(publishSettings)
.settings(
name := "laika-sbt",
sbtPlugin := true,
crossScalaVersions := Seq(versions.scala2_12),
scriptedLaunchOpts ++= Seq(
"-Xmx1024M",
"-Dplugin.version=" + version.value,
"-Duser.language=en",
"-Duser.country=GB"
),
scriptedBufferLog := false
)
lazy val demo = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Full)
.in(file("demo"))
.dependsOn(core)
.enablePlugins(sbtdocker.DockerPlugin, JavaAppPackaging)
.settings(basicSettings)
.settings(
name := "laika-demo",
version := "0.16.0.0"
)
.jvmSettings(
libraryDependencies ++= http4s,
Universal / javaOptions ++= Seq(
"-J-Xms512M",
"-J-Xmx896M"
),
docker / buildOptions := BuildOptions(
cache = false,
removeIntermediateContainers = BuildOptions.Remove.Always,
pullBaseImage = BuildOptions.Pull.Always
),
docker / dockerfile := {
val appDir: File = stage.value
val targetDir = "/app"
new Dockerfile {
from("openjdk:8")
expose(8080)
env("VERSION", version.value)
entryPoint(s"$targetDir/bin/${executableScriptName.value}")
copy(appDir, targetDir)
}
},
docker / imageNames := Seq(
ImageName(
namespace = None,
repository = name.value,
tag = Some(version.value)
)
)
)
.jsSettings(
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule) },
Compile / fastOptJS / artifactPath :=
(ThisBuild / baseDirectory).value / "demo" / "client" / "src" / "transformer" / "transformer.mjs",
Compile / fullOptJS / artifactPath :=
(ThisBuild / baseDirectory).value / "demo" / "client" / "src" / "transformer" / "transformer-opt.mjs"
)