-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbuild.sbt
292 lines (272 loc) · 8.86 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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
ThisBuild / organization := "qa.hedgehog"
ThisBuild / developers := List(
Developer("charleso", "Charles O'Farrell", "[email protected]", url("https://github.com/charleso")),
)
ThisBuild / homepage := Some(url("https://hedgehog.qa"))
ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/hedgehogqa/scala-hedgehog"),
"scm:[email protected]:hedgehogqa/scala-hedgehog.git",
),
)
ThisBuild / scalaVersion := props.ProjectScalaVersion
ThisBuild / crossScalaVersions := props.CrossScalaVersions
ThisBuild / licenses := List("Apache-2.0" -> url("https://opensource.org/licenses/Apache-2.0"))
lazy val hedgehog = Project(
id = "hedgehog",
base = file("."),
)
.settings(standardSettings)
.settings(noPublish)
.aggregate(
coreJVM, coreJS, coreNative,
runnerJVM, runnerJS, runnerNative,
sbtTestJVM, sbtTestJS, sbtTestNative,
testJVM, testJS, testNative,
exampleJVM, exampleJS,
minitestJVM, minitestJS,
munitJVM, munitJS,
)
lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("core"))
.settings(
standardSettings ++ Seq(
name := "hedgehog-core",
),
)
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val coreNative = core.native.settings(nativeSettings)
lazy val example = crossProject(JVMPlatform, JSPlatform)
.in(file("example"))
.settings(
standardSettings ++ noPublish ++ Seq(
name := "hedgehog-example",
),
)
.dependsOn(core, runner, sbtTest)
lazy val exampleJVM = example.jvm
lazy val exampleJS = example.js
lazy val runner = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("runner"))
.settings(
standardSettings ++ Seq(
name := "hedgehog-runner",
) ++ Seq(
libraryDependencies ++= Seq(
("org.portable-scala" %%% "portable-scala-reflect" % props.PortableScalaReflectVersion)
.cross(CrossVersion.for3Use2_13),
),
),
)
.dependsOn(core)
lazy val runnerJVM = runner.jvm
lazy val runnerJS = runner.js
lazy val runnerNative = runner.native.settings(nativeSettings)
lazy val sbtTest = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("sbt-test"))
.settings(
standardSettings ++ Seq(
name := "hedgehog-sbt",
libraryDependencies +=
("org.portable-scala" %%% "portable-scala-reflect" % props.PortableScalaReflectVersion)
.cross(CrossVersion.for3Use2_13),
),
)
.jvmSettings(
libraryDependencies +=
"org.scala-sbt" % "test-interface" % "1.0",
)
.jsSettings(
libraryDependencies +=
("org.scala-js" %% "scalajs-test-interface" % "1.10.0")
.cross(CrossVersion.for3Use2_13),
)
.nativeSettings(
libraryDependencies +=
"org.scala-sbt" % "test-interface" % "1.0",
)
.dependsOn(core, runner)
lazy val sbtTestJVM = sbtTest.jvm
lazy val sbtTestJS = sbtTest.js
lazy val sbtTestNative = sbtTest.native.settings(nativeSettings)
lazy val minitest = crossProject(JVMPlatform, JSPlatform)
.in(file("minitest"))
.settings(
standardSettings ++ Seq(
name := "hedgehog-minitest",
) ++ Seq(
libraryDependencies ++= Seq(
("org.portable-scala" %%% "portable-scala-reflect" % props.PortableScalaReflectVersion)
.cross(CrossVersion.for3Use2_13),
) ++ (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2L, 11L)) =>
Seq("io.monix" %%% "minitest" % props.MinitestVersion_2_11)
case _ =>
Seq("io.monix" %%% "minitest" % props.MinitestVersion)
}),
) ++ Seq(
testFrameworks += TestFramework("minitest.runner.Framework"),
),
)
.dependsOn(runner)
lazy val minitestJVM = minitest.jvm
lazy val minitestJS = minitest.js
lazy val munit = crossProject(JVMPlatform, JSPlatform)
.in(file("munit"))
.settings(
standardSettings ++ Seq(
name := "hedgehog-munit",
libraryDependencies ++= Seq("org.scalameta" %%% "munit" % props.MunitVersion) ++
(if (scalaBinaryVersion.value.startsWith("2.11")) {
val silencerVersion = "1.7.8"
Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % "2.7.0",
compilerPlugin("com.github.ghik" % "silencer-plugin" % silencerVersion cross CrossVersion.full),
"com.github.ghik" % "silencer-lib" % silencerVersion % Provided cross CrossVersion.full,
)
} else {
Seq.empty
}),
)
)
.dependsOn(runner)
lazy val munitJVM = munit.jvm
lazy val munitJS = munit.js
lazy val test = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.settings(
standardSettings ++ noPublish ++ Seq(
name := "hedgehog-test",
),
)
.dependsOn(core, runner, sbtTest)
lazy val testJVM = test.jvm
lazy val testJS = test.js
lazy val testNative = test.native.settings(nativeSettings)
lazy val docs = (project in file("generated-docs"))
.enablePlugins(MdocPlugin, DocusaurPlugin, ScalaUnidocPlugin)
.settings(
name := "docs",
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.13.3" cross CrossVersion.full),
mdocVariables := Map(
"VERSION" -> {
import sys.process._
"git fetch --tags".!
val tag = "git rev-list --tags --max-count=1".!!.trim
s"git describe --tags $tag".!!.trim.stripPrefix("v")
},
"SUPPORTED_SCALA_VERSIONS" -> {
val versions = props
.CrossScalaVersions
.map { scalaVersion =>
scalaVersion.split("\\.") match {
case Array("3", "0", _) => "3"
case Array("3", mn, _) => s"3.$mn+"
case _ => CrossVersion.binaryScalaVersion(scalaVersion)
}
}
.map(v => s"`$v`")
if (versions.length > 1)
s"${versions.init.mkString(", ")} and ${versions.last}"
else
versions.mkString
},
),
gitHubPagesPublishRequestTimeout := 60.seconds,
docusaurDir := (ThisBuild / baseDirectory).value / "website",
docusaurBuildDir := docusaurDir.value / "build",
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(coreJVM, runnerJVM, exampleJVM, minitestJVM, munitJVM),
ScalaUnidoc / unidoc / target := docusaurDir.value / "static" / "api",
cleanFiles += (ScalaUnidoc / unidoc / target).value,
docusaurBuild := docusaurBuild.dependsOn(Compile / unidoc).value,
)
.settings(noPublish)
.dependsOn(coreJVM, runnerJVM, exampleJVM, minitestJVM, munitJVM)
lazy val compilationSettings = Seq(
maxErrors := 10,
Compile / scalacOptions ++=
(if (scalaVersion.value.startsWith("3.")) {
Seq(
"-deprecation",
"-unchecked",
"-feature",
"-Xfatal-warnings",
"-source:3.0-migration",
"-Ykind-projector",
"-language:" + List(
"dynamics",
"existentials",
"higherKinds",
"reflectiveCalls",
"experimental.macros",
"implicitConversions",
).mkString(",")
)
} else {
Seq(
"-deprecation",
"-unchecked",
"-feature",
"-language:_",
"-Ywarn-value-discard",
"-Xlint",
"-Xfatal-warnings",
) ++ (
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 10)) =>
Seq("-Yno-adapted-args")
case Some((2, 13)) =>
Seq.empty
case _ =>
Seq("-Yno-adapted-args", "-Ywarn-unused-import")
}
)
}),
Compile / console / scalacOptions := Seq("-language:_", "-feature"),
Test / console / scalacOptions := Seq("-language:_", "-feature"),
Compile / unmanagedSourceDirectories ++= {
(Compile / unmanagedSourceDirectories).value.map { dir =>
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) | Some((3, _)) =>
file(dir.getParent + "/scala-2.13+")
case _ =>
file(dir.getParent + "/scala-2.13-")
}
}
},
libraryDependencies ++= (
if (scalaVersion.value.startsWith("3."))
Seq.empty[ModuleID]
else
Seq(
compilerPlugin("org.typelevel" %% "kind-projector" % "0.13.3" cross CrossVersion.full),
)
),
)
lazy val props = new {
val ProjectScalaVersion = "2.13.10"
val CrossScalaVersions = Seq("2.12.19", ProjectScalaVersion, "3.1.3")
val PortableScalaReflectVersion = "1.1.3"
val MinitestVersion_2_11 = "2.8.2"
val MinitestVersion = "2.9.6"
val MunitVersion = "0.7.27"
}
lazy val projectSettings: Seq[Setting[_]] = Seq(
name := "hedgehog",
run / fork := true,
licenses := List("Apache-2.0" -> url("https://opensource.org/licenses/Apache-2.0")),
)
lazy val standardSettings: Seq[Setting[_]] = Seq(
Defaults.coreDefaultSettings,
projectSettings,
compilationSettings,
).flatten
lazy val nativeSettings: SettingsDefinition = List(
Test / fork := false
)
lazy val noPublish = Seq(
publish := {},
publishLocal := {},
publishArtifact := false,
publish / skip := true,
)