Skip to content

Commit 9d0b207

Browse files
authored
Merge pull request #490 from lrytz/noNative3
Remove the `compat30Native` project from sbt
2 parents ff903a4 + 846300d commit 9d0b207

File tree

2 files changed

+23
-29
lines changed

2 files changed

+23
-29
lines changed

build.sbt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ lazy val scala212 = "2.12.15"
5454
lazy val scala213 = "2.13.6"
5555
lazy val scala30 = "3.0.2"
5656

57-
lazy val compat = MultiScalaCrossProject(JSPlatform, JVMPlatform, NativePlatform)(
57+
lazy val compat = new MultiScalaCrossProject(
5858
"compat",
5959
_.settings(ScalaModulePlugin.scalaModuleSettings)
6060
.settings(commonSettings)
@@ -85,7 +85,8 @@ lazy val compat = MultiScalaCrossProject(JSPlatform, JVMPlatform, NativePlatform
8585
)
8686
},
8787
)
88-
.jsSettings(
88+
.disablePlugins(ScalafixPlugin),
89+
_.jsSettings(
8990
scalacOptions ++= {
9091
val x = (LocalRootProject / baseDirectory).value.toURI.toString
9192
val y = "https://raw.githubusercontent.com/scala/scala-collection-compat/" + sys.process
@@ -100,9 +101,8 @@ lazy val compat = MultiScalaCrossProject(JSPlatform, JVMPlatform, NativePlatform
100101
},
101102
Test / fork := false // Scala.js cannot run forked tests
102103
)
103-
.jsEnablePlugins(ScalaJSJUnitPlugin)
104-
.disablePlugins(ScalafixPlugin)
105-
.nativeSettings(
104+
.jsEnablePlugins(ScalaJSJUnitPlugin),
105+
_.nativeSettings(
106106
nativeLinkStubs := true,
107107
addCompilerPlugin(
108108
"org.scala-native" % "junit-plugin" % nativeVersion cross CrossVersion.full
@@ -112,10 +112,10 @@ lazy val compat = MultiScalaCrossProject(JSPlatform, JVMPlatform, NativePlatform
112112
)
113113
)
114114

115-
val compat211 = compat(scala211)
116-
val compat212 = compat(scala212)
117-
val compat213 = compat(scala213)
118-
val compat30 = compat(scala30)
115+
val compat211 = compat(Seq(JSPlatform, JVMPlatform, NativePlatform), scala211)
116+
val compat212 = compat(Seq(JSPlatform, JVMPlatform, NativePlatform), scala212)
117+
val compat213 = compat(Seq(JSPlatform, JVMPlatform, NativePlatform), scala213)
118+
val compat30 = compat(Seq(JSPlatform, JVMPlatform), scala30)
119119

120120
lazy val compat211JVM = compat211.jvm
121121
lazy val compat211JS = compat211.js

project/MultiScalaProject.scala

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,39 +59,33 @@ trait MultiScala {
5959
}
6060
}
6161

62-
object MultiScalaCrossProject {
63-
def apply(platforms: Platform*)(name: String,
64-
configure: CrossProject => CrossProject): MultiScalaCrossProject =
65-
new MultiScalaCrossProject(platforms, name, configure)
66-
}
67-
68-
class MultiScalaCrossProject(platforms: Seq[Platform],
69-
name: String,
70-
configure: CrossProject => CrossProject)
62+
class MultiScalaCrossProject(name: String,
63+
configureCommonJvm: CrossProject => CrossProject,
64+
configureJs: CrossProject => CrossProject,
65+
configureNative: CrossProject => CrossProject)
7166
extends MultiScala {
72-
73-
def apply(scalaV: String): CrossProject = apply(scalaV, scalaV, x => x)
74-
7567
def apply(
76-
scalaV: String,
77-
scalaVJs: String,
78-
configurePerScala: CrossProject => CrossProject = x => x
68+
platforms: Seq[Platform],
69+
scalaV: String
7970
): CrossProject = {
71+
val hasJs = platforms.contains(JSPlatform)
72+
val hasNative = platforms.contains(NativePlatform)
8073
val projectId = projectIdPerScala(name, scalaV)
81-
val resultingProject =
74+
val res =
8275
CrossProject(
8376
id = projectId,
8477
base = file(s".cross/$projectId")
8578
)(platforms: _*)
8679
.crossType(CrossType.Full)
8780
.withoutSuffixFor(JVMPlatform)
8881
.settings(moduleName := name)
89-
.jvmSettings(scalaVersion := scalaV)
90-
.jsSettings(scalaVersion := scalaVJs)
91-
.nativeSettings(scalaVersion := scalaV)
82+
.settings(scalaVersion := scalaV)
9283
.settings(srcFull(name))
9384

94-
configurePerScala(configure(resultingProject))
85+
val conf = configureCommonJvm
86+
.andThen(if (hasJs) configureJs else identity)
87+
.andThen(if (hasNative) configureNative else identity)
88+
conf(res)
9589
}
9690
}
9791

0 commit comments

Comments
 (0)