1- ThisBuild / crossScalaVersions := Seq (" 2.13.15" , " 3.3.4" )
2- ThisBuild / scalaVersion := ( ThisBuild / crossScalaVersions).value .head
1+ val scalaVersions = Seq (" 2.13.15" , " 3.3.4" )
2+ val defaultScalaVersion = scalaVersions .head
33
4+ // When defining JVM / Scala Native matrix we don't want duplicated projects for Scala 2/3
5+ val matrixScalaVersions = Seq (defaultScalaVersion)
6+
7+ ThisBuild / crossScalaVersions := scalaVersions
8+ ThisBuild / scalaVersion := defaultScalaVersion
9+
10+ Global / concurrentRestrictions += Tags .limit(NativeTags .Link , 1 )
411Global / cancelable := true
512publish / skip := true // in root
613
714lazy val commonSettings : Seq [Setting [_]] =
815 Seq (scalaModuleAutomaticModuleName := Some (" scala.collection.parallel" )) ++
916 ScalaModulePlugin .scalaModuleSettings ++ Seq (
1017 versionPolicyIntention := Compatibility .BinaryAndSourceCompatible ,
18+ crossScalaVersions := scalaVersions,
1119 Compile / compile / scalacOptions --= (CrossVersion .partialVersion(scalaVersion.value) match {
1220 case Some ((3 , _)) => Seq (" -Xlint" )
1321 case _ => Seq ()
@@ -18,43 +26,79 @@ lazy val commonSettings: Seq[Setting[_]] =
1826 }),
1927 )
2028
21- lazy val core = project.in(file(" core" ))
29+ lazy val testNativeSettings : Seq [Setting [_]] = Seq (
30+ // Required by Scala Native testing infrastructure
31+ Test / fork := false ,
32+ )
33+
34+ lazy val core = projectMatrix.in(file(" core" ))
2235 .settings(commonSettings)
2336 .settings(
2437 name := " scala-parallel-collections" ,
2538 Compile / doc / autoAPIMappings := true ,
2639 )
40+ .jvmPlatform(matrixScalaVersions)
41+ .nativePlatform(matrixScalaVersions, settings = testNativeSettings ++ Seq (
42+ versionPolicyPreviousArtifacts := Nil , // TODO: not yet published
43+ mimaPreviousArtifacts := Set .empty
44+ ))
2745
28- lazy val junit = project .in(file(" junit" ))
46+ lazy val junit = projectMatrix .in(file(" junit" ))
2947 .settings(commonSettings)
3048 .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 ,
3549 testOptions += Tests .Argument (TestFrameworks .JUnit , " -a" , " -v" ),
36- Test / fork := true ,
3750 publish / skip := true ,
3851 ).dependsOn(testmacros, core)
52+ .jvmPlatform(matrixScalaVersions,
53+ settings = Seq (
54+ libraryDependencies += " com.github.sbt" % " junit-interface" % " 0.13.3" % Test ,
55+ libraryDependencies += " junit" % " junit" % " 4.13.2" % Test ,
56+ // for javax.xml.bind.DatatypeConverter, used in SerializationStabilityTest
57+ libraryDependencies += " javax.xml.bind" % " jaxb-api" % " 2.3.1" % Test ,
58+ Test / fork := true ,
59+ )
60+ )
61+ .nativePlatform(matrixScalaVersions,
62+ axisValues = Nil ,
63+ configure = _
64+ .enablePlugins(ScalaNativeJUnitPlugin )
65+ .settings(
66+ Test / unmanagedSources/ excludeFilter ~= { _ ||
67+ " SerializationTest.scala" || // requires ObjectOutputStream
68+ " SerializationStability.scala" || // requires jaxb-api
69+ " SerializationStabilityBase.scala" ||
70+ " SerializationStabilityTest.scala"
71+ },
72+ Test / fork := false
73+ )
74+ )
3975
40- lazy val scalacheck = project .in(file(" scalacheck" ))
76+ lazy val scalacheck = projectMatrix .in(file(" scalacheck" ))
4177 .settings(commonSettings)
4278 .settings(
43- libraryDependencies += " org.scalacheck" %% " scalacheck" % " 1.18.1" ,
44- Test / fork := true ,
79+ libraryDependencies += " org.scalacheck" %%% " scalacheck" % " 1.18.1" ,
4580 Test / testOptions += Tests .Argument (TestFrameworks .ScalaCheck , " -workers" , " 1" , " -minSize" , " 0" , " -maxSize" , " 4000" , " -minSuccessfulTests" , " 5" ),
4681 publish / skip := true
47- ).dependsOn(core)
82+ )
83+ .dependsOn(core)
84+ .jvmPlatform(matrixScalaVersions,
85+ settings = Seq (
86+ Test / fork := true
87+ )
88+ )
89+ .nativePlatform(matrixScalaVersions, settings = testNativeSettings)
4890
49- lazy val testmacros = project .in(file(" testmacros" ))
91+ lazy val testmacros = projectMatrix .in(file(" testmacros" ))
5092 .settings(commonSettings)
5193 .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
94+ libraryDependencies ++ = (CrossVersion .partialVersion(scalaVersion.value) match {
95+ case Some ((3 , _)) => Nil
96+ case _ => List ( scalaOrganization.value % " scala-compiler" % scalaVersion.value)
5597 }),
5698 publish / skip := true ,
5799 )
100+ .jvmPlatform(matrixScalaVersions)
101+ .nativePlatform(matrixScalaVersions, settings = testNativeSettings)
58102
59103commands += Command .single(" setScalaVersion" ) { (state, arg) =>
60104 val command = arg match {
@@ -63,3 +107,15 @@ commands += Command.single("setScalaVersion") { (state, arg) =>
63107 }
64108 command :: state
65109}
110+
111+ import sbt .internal .{ProjectMatrix , ProjectFinder }
112+ def testPlatformCommand (name : String , selector : ProjectMatrix => ProjectFinder ): Command =
113+ Command .command(name) { state =>
114+ List (junit, scalacheck, testmacros)
115+ .flatMap(selector(_).get)
116+ .map{ project => s " ${project.id}/test " }
117+ .toList ::: state
118+ }
119+
120+ commands += testPlatformCommand(" testNative" , _.native)
121+ commands += testPlatformCommand(" testJVM" , _.jvm)
0 commit comments