Skip to content

Commit ae2a0a8

Browse files
committed
Cross build with Scala Native
1 parent ca33dfb commit ae2a0a8

File tree

1 file changed

+52
-15
lines changed

1 file changed

+52
-15
lines changed

build.sbt

+52-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
ThisBuild / crossScalaVersions := Seq("2.13.15", "3.3.4")
1+
val scalaVersions = Seq("2.13.15", "3.3.4")
2+
ThisBuild / crossScalaVersions := scalaVersions
23
ThisBuild / scalaVersion := (ThisBuild / crossScalaVersions).value.head
34

5+
Global / concurrentRestrictions += Tags.limit(NativeTags.Link, 1)
46
Global / cancelable := true
57
publish / skip := true // in root
68

@@ -18,43 +20,78 @@ lazy val commonSettings: Seq[Setting[_]] =
1820
}),
1921
)
2022

21-
lazy val core = project.in(file("core"))
23+
lazy val testNativeSettings: Seq[Setting[_]] = Seq(
24+
// Required by Scala Native testing infrastructure
25+
Test / fork := false,
26+
)
27+
28+
lazy val core = projectMatrix.in(file("core"))
2229
.settings(commonSettings)
2330
.settings(
2431
name := "scala-parallel-collections",
2532
Compile / doc / autoAPIMappings := true,
2633
)
34+
.jvmPlatform(scalaVersions)
35+
.nativePlatform(scalaVersions, settings = testNativeSettings ++ Seq(
36+
versionPolicyPreviousArtifacts := Nil, // TODO: not yet published ,
37+
mimaPreviousArtifacts := Set.empty
38+
))
2739

28-
lazy val junit = project.in(file("junit"))
40+
lazy val junit = projectMatrix.in(file("junit"))
2941
.settings(commonSettings)
3042
.settings(
31-
libraryDependencies += "com.github.sbt" % "junit-interface" % "0.13.3" % Test,
32-
libraryDependencies += "junit" % "junit" % "4.13.2" % Test,
33-
// for javax.xml.bind.DatatypeConverter, used in SerializationStabilityTest
34-
libraryDependencies += "javax.xml.bind" % "jaxb-api" % "2.3.1" % Test,
3543
testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-v"),
36-
Test / fork := true,
3744
publish / skip := true,
3845
).dependsOn(testmacros, core)
46+
.jvmPlatform(scalaVersions,
47+
settings = Seq(
48+
libraryDependencies += "com.github.sbt" % "junit-interface" % "0.13.3" % Test,
49+
libraryDependencies += "junit" % "junit" % "4.13.2" % Test,
50+
// for javax.xml.bind.DatatypeConverter, used in SerializationStabilityTest
51+
libraryDependencies += "javax.xml.bind" % "jaxb-api" % "2.3.1" % Test,
52+
Test / fork := true,
53+
)
54+
)
55+
.nativePlatform(scalaVersions = scalaVersions,
56+
axisValues = Nil,
57+
configure = _
58+
.enablePlugins(ScalaNativeJUnitPlugin)
59+
.settings(
60+
Test/unmanagedSources/excludeFilter ~= { _ ||
61+
"SerializationTest.scala" || // requires ObjectOutputStream
62+
"SerializationStability.scala" || // requires jaxb-api
63+
"SerializationStabilityBase.scala" ||
64+
"SerializationStabilityTest.scala"
65+
},
66+
Test / fork := false
67+
)
68+
)
3969

40-
lazy val scalacheck = project.in(file("scalacheck"))
70+
lazy val scalacheck = projectMatrix.in(file("scalacheck"))
4171
.settings(commonSettings)
4272
.settings(
43-
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.18.1",
44-
Test / fork := true,
73+
libraryDependencies += "org.scalacheck" %%% "scalacheck" % "1.18.1",
4574
Test / testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-workers", "1", "-minSize", "0", "-maxSize", "4000", "-minSuccessfulTests", "5"),
4675
publish / skip := true
4776
).dependsOn(core)
77+
.jvmPlatform(scalaVersions,
78+
settings = Seq(
79+
Test / fork := true
80+
)
81+
)
82+
.nativePlatform(scalaVersions, settings = testNativeSettings)
4883

49-
lazy val testmacros = project.in(file("testmacros"))
84+
lazy val testmacros = projectMatrix.in(file("testmacros"))
5085
.settings(commonSettings)
5186
.settings(
52-
libraryDependencies += (CrossVersion.partialVersion(scalaVersion.value) match {
53-
case Some((3, _)) => scalaOrganization.value %% "scala3-compiler" % scalaVersion.value
54-
case _ => scalaOrganization.value % "scala-compiler" % scalaVersion.value
87+
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
88+
case Some((3, _)) => Nil
89+
case _ => List(scalaOrganization.value % "scala-compiler" % scalaVersion.value)
5590
}),
5691
publish / skip := true,
5792
)
93+
.jvmPlatform(scalaVersions)
94+
.nativePlatform(scalaVersions, settings = testNativeSettings)
5895

5996
commands += Command.single("setScalaVersion") { (state, arg) =>
6097
val command = arg match {

0 commit comments

Comments
 (0)