forked from scalameta/munit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
310 lines (299 loc) · 9.44 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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
import com.typesafe.tools.mima.core.DirectMissingMethodProblem
import com.typesafe.tools.mima.core.ProblemFilters
import com.typesafe.tools.mima.core.MissingTypesProblem
import sbtcrossproject.CrossPlugin.autoImport.crossProject
import sbtcrossproject.CrossPlugin.autoImport.CrossType
import scala.collection.mutable
val scalaJSVersion = "1.6.0"
val scalaNativeVersion = "0.4.0"
def previousVersion = "0.7.0"
def scala213 = "2.13.6"
def scala212 = "2.12.14"
def scala211 = "2.11.12"
def scala3 = "3.0.1"
def junitVersion = "4.13.2"
def gcp = "com.google.cloud" % "google-cloud-storage" % "1.115.0"
inThisBuild(
List(
version ~= { old =>
if ("true" == System.getProperty("CI") && old.contains("+0-")) {
old.replaceAll("\\+0-.*", "")
} else {
old
}
},
organization := "org.scalameta",
homepage := Some(url("https://github.com/scalameta/munit")),
licenses := List(
"Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")
),
developers := List(
Developer(
"olafurpg",
"Ólafur Páll Geirsson",
url("https://geirsson.com")
)
),
scalaVersion := scala213,
useSuperShell := false
)
)
publish / skip := true
mimaPreviousArtifacts := Set.empty
crossScalaVersions := List()
addCommandAlias(
"scalafixAll",
"; ++2.12.10 ; scalafixEnable ; all scalafix test:scalafix"
)
addCommandAlias(
"scalafixCheckAll",
"; ++2.12.10 ; scalafixEnable ; scalafix --check ; test:scalafix --check"
)
val isPreScala213 = Set[Option[(Long, Long)]](Some((2, 11)), Some((2, 12)))
val scala2Versions = List(scala213, scala212, scala211)
val scala3Versions = List(scala3)
val allScalaVersions = scala2Versions ++ scala3Versions
def isNotScala211(v: Option[(Long, Long)]): Boolean = !v.contains((2, 11))
def isScala2(v: Option[(Long, Long)]): Boolean = v.exists(_._1 == 2)
val isScala3Setting = Def.setting {
isScala3(CrossVersion.partialVersion(scalaVersion.value))
}
def isScala3(v: Option[(Long, Long)]): Boolean = v.exists(_._1 == 3)
// NOTE(olafur): disable Scala.js and Native settings for IntelliJ.
lazy val skipIdeaSettings =
SettingKey[Boolean]("ide-skip-project").withRank(KeyRanks.Invisible) := true
lazy val mimaEnable: List[Def.Setting[_]] = List(
mimaBinaryIssueFilters ++= List(
ProblemFilters.exclude[DirectMissingMethodProblem](
"munit.MUnitRunner.descriptions"
),
ProblemFilters.exclude[DirectMissingMethodProblem](
"munit.MUnitRunner.testNames"
),
ProblemFilters.exclude[DirectMissingMethodProblem](
"munit.MUnitRunner.munitTests"
),
ProblemFilters.exclude[DirectMissingMethodProblem](
"munit.ValueTransforms.munitTimeout"
),
ProblemFilters.exclude[MissingTypesProblem]("munit.FailException"),
ProblemFilters.exclude[MissingTypesProblem]("munit.FailSuiteException"),
ProblemFilters.exclude[MissingTypesProblem](
"munit.TestValues$FlakyFailure"
),
ProblemFilters.exclude[DirectMissingMethodProblem](
"munit.internal.junitinterface.JUnitComputer.this"
)
),
mimaPreviousArtifacts := {
if (crossPaths.value)
Set("org.scalameta" %% moduleName.value % previousVersion)
else Set("org.scalameta" % moduleName.value % previousVersion)
}
)
val sharedJVMSettings: List[Def.Setting[_]] = List(
crossScalaVersions := allScalaVersions
) ++ mimaEnable
val sharedJSSettings: List[Def.Setting[_]] = List(
skipIdeaSettings,
crossScalaVersions := allScalaVersions.filterNot(_.startsWith("0."))
)
val sharedJSConfigure: Project => Project =
_.disablePlugins(MimaPlugin)
val sharedNativeSettings: List[Def.Setting[_]] = List(
skipIdeaSettings,
crossScalaVersions := scala2Versions
)
val sharedNativeConfigure: Project => Project =
_.disablePlugins(ScalafixPlugin, MimaPlugin)
val sharedSettings = List(
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) =>
List(
"-Yrangepos",
"-Xexperimental",
"-Ywarn-unused-import",
"-target:jvm-1.8"
)
case Some((major, _)) if major != 2 =>
List(
"-language:implicitConversions"
)
case _ =>
List(
"-target:jvm-1.8",
"-Yrangepos",
// -Xlint is unusable because of
// https://github.com/scala/bug/issues/10448
"-Ywarn-unused:imports"
)
}
}
)
lazy val junit = project
.in(file("junit-interface"))
.settings(
mimaEnable,
moduleName := "junit-interface",
description := "A Java implementation of sbt's test interface for JUnit 4",
autoScalaLibrary := false,
crossPaths := false,
sbtPlugin := false,
crossScalaVersions := List(allScalaVersions.head),
libraryDependencies ++= List(
"junit" % "junit" % junitVersion,
"org.scala-sbt" % "test-interface" % "1.0"
),
Compile / javacOptions ++= List("-target", "1.8", "-source", "1.8"),
Compile / doc / javacOptions --= List("-target", "1.8")
)
lazy val munit = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.settings(
sharedSettings,
Compile / unmanagedSourceDirectories ++= {
val root = (ThisBuild / baseDirectory).value / "munit"
val base = root / "shared" / "src" / "main"
val result = mutable.ListBuffer.empty[File]
val partialVersion = CrossVersion.partialVersion(scalaVersion.value)
if (isPreScala213(partialVersion)) {
result += base / "scala-pre-2.13"
}
if (isNotScala211(partialVersion)) {
result += base / "scala-post-2.11"
}
if (isScala2(partialVersion)) {
result += base / "scala-2"
}
result.toList
},
libraryDependencies ++= List(
"org.scala-lang" % "scala-reflect" % {
if (isScala3Setting.value) scala213
else scalaVersion.value
} % Provided
)
)
.nativeConfigure(sharedNativeConfigure)
.nativeSettings(
sharedNativeSettings,
libraryDependencies ++= List(
"org.scala-native" %%% "test-interface" % scalaNativeVersion
),
Compile / unmanagedSourceDirectories +=
(ThisBuild / baseDirectory).value / "munit" / "non-jvm" / "src" / "main"
)
.jsConfigure(sharedJSConfigure)
.jsSettings(
sharedJSSettings,
libraryDependencies ++= List(
("org.scala-js" %% "scalajs-test-interface" % scalaJSVersion)
.cross(CrossVersion.for3Use2_13),
("org.scala-js" %% "scalajs-junit-test-runtime" % scalaJSVersion)
.cross(CrossVersion.for3Use2_13)
),
Compile / unmanagedSourceDirectories +=
(ThisBuild / baseDirectory).value / "munit" / "non-jvm" / "src" / "main"
)
.jvmSettings(
sharedJVMSettings,
libraryDependencies ++= List(
"junit" % "junit" % "4.13.1"
)
)
.jvmConfigure(_.dependsOn(junit))
lazy val munitJVM = munit.jvm
lazy val munitJS = munit.js
lazy val munitNative = munit.native
lazy val plugin = project
.in(file("munit-sbt"))
.enablePlugins(BuildInfoPlugin)
.settings(
sharedSettings,
moduleName := "sbt-munit",
sbtPlugin := true,
scalaVersion := scala212,
crossScalaVersions := List(scala212),
buildInfoPackage := "munit.sbtmunit",
buildInfoKeys := Seq[BuildInfoKey](
"munitVersion" -> version.value
),
crossScalaVersions := List(scala212),
libraryDependencies ++= List(
gcp
)
)
.disablePlugins(MimaPlugin)
lazy val munitScalacheck = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.in(file("munit-scalacheck"))
.dependsOn(munit)
.settings(
moduleName := "munit-scalacheck",
sharedSettings,
libraryDependencies += {
val partialVersion = CrossVersion.partialVersion(scalaVersion.value)
if (isNotScala211(partialVersion))
"org.scalacheck" %%% "scalacheck" % "1.15.4"
else
"org.scalacheck" %%% "scalacheck" % "1.15.2"
}
)
.jvmSettings(
sharedJVMSettings
)
.nativeConfigure(sharedNativeConfigure)
.nativeSettings(
sharedNativeSettings
)
.jsConfigure(sharedJSConfigure)
.jsSettings(sharedJSSettings)
lazy val munitScalacheckJVM = munitScalacheck.jvm
lazy val munitScalacheckJS = munitScalacheck.js
lazy val munitScalacheckNative = munitScalacheck.native
lazy val tests = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.dependsOn(munit, munitScalacheck)
.enablePlugins(BuildInfoPlugin)
.settings(
sharedSettings,
buildInfoPackage := "munit",
buildInfoKeys := Seq[BuildInfoKey](
"sourceDirectory" ->
(ThisBuild / baseDirectory).value / "tests" / "shared" / "src" / "main",
scalaVersion
),
publish / skip := true
)
.nativeConfigure(sharedNativeConfigure)
.nativeSettings(sharedNativeSettings)
.jsConfigure(sharedJSConfigure)
.jsSettings(sharedJSSettings)
.jvmSettings(
sharedJVMSettings,
fork := true
)
.disablePlugins(MimaPlugin)
lazy val testsJVM = tests.jvm
lazy val testsJS = tests.js
lazy val testsNative = tests.native
lazy val docs = project
.in(file("munit-docs"))
.dependsOn(munitJVM, munitScalacheckJVM)
.enablePlugins(MdocPlugin, DocusaurusPlugin)
.disablePlugins(MimaPlugin)
.settings(
sharedSettings,
moduleName := "munit-docs",
crossScalaVersions := List(scala213, scala212),
test := {},
mdocOut :=
(ThisBuild / baseDirectory).value / "website" / "target" / "docs",
mdocExtraArguments := List("--no-link-hygiene"),
mdocVariables := Map(
"VERSION" -> version.value.replaceFirst("\\+.*", "")
),
fork := false
)
Global / excludeLintKeys ++= Set(
mimaPreviousArtifacts
)