forked from paulbutcher/ScalaMock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
65 lines (60 loc) · 2.23 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
import sbtcrossproject.CrossPlugin.autoImport.crossProject
lazy val scalatest = Def.setting("org.scalatest" %%% "scalatest" % "3.2.19")
lazy val specs2 = Def.setting("org.specs2" %%% "specs2-core" % "4.20.8")
val commonSettings = Defaults.coreDefaultSettings ++ Seq(
/**
* Symbol.newClass is marked experimental, so we should use @experimental annotation in every test suite.
* 3.3.0 has a bug so we can omit this annotation
*/
scalaVersion := "3.3.0",
scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature", "-release:8")
)
lazy val scalamock = crossProject(JSPlatform, JVMPlatform) in file(".") settings(
commonSettings,
crossScalaSettings,
name := "scalamock",
Compile / packageBin / publishArtifact := true,
Compile / packageDoc / publishArtifact := true,
Compile / packageSrc / publishArtifact := true,
Test / publishArtifact := false,
Compile / doc / scalacOptions ++= Opts.doc.title("ScalaMock") ++
Opts.doc.version(version.value) ++ Seq("-doc-root-content", "rootdoc.txt", "-version"),
libraryDependencies ++= Seq(
scalatest.value % Optional,
specs2.value % Optional
)
)
lazy val examples = project in file("examples") settings(
commonSettings,
crossScalaSettings,
name := "ScalaMock Examples",
publish / skip := true,
libraryDependencies ++= Seq(
scalatest.value % Test,
specs2.value % Test
)
) dependsOn scalamock.jvm
def crossScalaSettings = {
def addDirsByScalaVersion(path: String): Def.Initialize[Seq[sbt.File]] =
scalaVersion.zip(baseDirectory) { case (v, base) =>
CrossVersion.partialVersion(v) match {
case Some((v, _)) if Set(2L, 3L).contains(v) =>
Seq(base / path / s"scala-$v")
case _ =>
Seq.empty
}
}
Seq(
crossScalaVersions := Seq("2.12.20", "2.13.14", scalaVersion.value),
Compile / unmanagedSourceDirectories ++= addDirsByScalaVersion("src/main").value,
Test / unmanagedSourceDirectories ++= addDirsByScalaVersion("src/test").value,
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) =>
Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)
case _ =>
Seq.empty
}
}
)
}