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
3
3
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 )
4
11
Global / cancelable := true
5
12
publish / skip := true // in root
6
13
7
14
lazy val commonSettings : Seq [Setting [_]] =
8
15
Seq (scalaModuleAutomaticModuleName := Some (" scala.collection.parallel" )) ++
9
16
ScalaModulePlugin .scalaModuleSettings ++ Seq (
10
17
versionPolicyIntention := Compatibility .BinaryAndSourceCompatible ,
18
+ crossScalaVersions := scalaVersions,
11
19
Compile / compile / scalacOptions --= (CrossVersion .partialVersion(scalaVersion.value) match {
12
20
case Some ((3 , _)) => Seq (" -Xlint" )
13
21
case _ => Seq ()
@@ -18,43 +26,79 @@ lazy val commonSettings: Seq[Setting[_]] =
18
26
}),
19
27
)
20
28
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" ))
22
35
.settings(commonSettings)
23
36
.settings(
24
37
name := " scala-parallel-collections" ,
25
38
Compile / doc / autoAPIMappings := true ,
26
39
)
40
+ .jvmPlatform(matrixScalaVersions)
41
+ .nativePlatform(matrixScalaVersions, settings = testNativeSettings ++ Seq (
42
+ versionPolicyPreviousArtifacts := Nil , // TODO: not yet published
43
+ mimaPreviousArtifacts := Set .empty
44
+ ))
27
45
28
- lazy val junit = project .in(file(" junit" ))
46
+ lazy val junit = projectMatrix .in(file(" junit" ))
29
47
.settings(commonSettings)
30
48
.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 ,
35
49
testOptions += Tests .Argument (TestFrameworks .JUnit , " -a" , " -v" ),
36
- Test / fork := true ,
37
50
publish / skip := true ,
38
51
).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
+ )
39
75
40
- lazy val scalacheck = project .in(file(" scalacheck" ))
76
+ lazy val scalacheck = projectMatrix .in(file(" scalacheck" ))
41
77
.settings(commonSettings)
42
78
.settings(
43
- libraryDependencies += " org.scalacheck" %% " scalacheck" % " 1.18.1" ,
44
- Test / fork := true ,
79
+ libraryDependencies += " org.scalacheck" %%% " scalacheck" % " 1.18.1" ,
45
80
Test / testOptions += Tests .Argument (TestFrameworks .ScalaCheck , " -workers" , " 1" , " -minSize" , " 0" , " -maxSize" , " 4000" , " -minSuccessfulTests" , " 5" ),
46
81
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)
48
90
49
- lazy val testmacros = project .in(file(" testmacros" ))
91
+ lazy val testmacros = projectMatrix .in(file(" testmacros" ))
50
92
.settings(commonSettings)
51
93
.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)
55
97
}),
56
98
publish / skip := true ,
57
99
)
100
+ .jvmPlatform(matrixScalaVersions)
101
+ .nativePlatform(matrixScalaVersions, settings = testNativeSettings)
58
102
59
103
commands += Command .single(" setScalaVersion" ) { (state, arg) =>
60
104
val command = arg match {
@@ -63,3 +107,15 @@ commands += Command.single("setScalaVersion") { (state, arg) =>
63
107
}
64
108
command :: state
65
109
}
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