mirror of https://github.com/sbt/sbt.git
Merge pull request #42 from sbt/wip/scala3
Use Scala's ABI version to generate suffix
This commit is contained in:
commit
756855ae8b
|
|
@ -1,6 +1,6 @@
|
|||
package sbt
|
||||
|
||||
import sbt.librarymanagement.CrossVersion.partialVersion
|
||||
import sbt.librarymanagement.CrossVersion.{ binaryScalaVersion, partialVersion }
|
||||
|
||||
/** Virtual Axis represents a parameter to a project matrix row. */
|
||||
sealed abstract class VirtualAxis {
|
||||
|
|
@ -106,6 +106,9 @@ object VirtualAxis {
|
|||
case Some((m, n)) => scalaVersionAxis(scalaVersion, s"$m.$n")
|
||||
case _ => scalaVersionAxis(scalaVersion, scalaVersion)
|
||||
}
|
||||
def scalaABIVersion(scalaVersion: String): ScalaVersionAxis =
|
||||
scalaVersionAxis(scalaVersion, binaryScalaVersion(scalaVersion))
|
||||
|
||||
def scalaVersionAxis(scalaVersion: String, value: String) =
|
||||
ScalaVersionAxis(scalaVersion, value)
|
||||
|
||||
|
|
|
|||
|
|
@ -280,34 +280,22 @@ object ProjectMatrix {
|
|||
val ref = thisProjectRef.value
|
||||
val data = settingsData.value
|
||||
val deps = buildDependencies.value
|
||||
val sbtV = VersionNumber(sbtVersion.value)
|
||||
|
||||
if (sbtV._1.getOrElse(0L) == 1 && (sbtV._2.getOrElse(0L) < 4)) {
|
||||
deps.classpath(ref) flatMap { dep =>
|
||||
val depProjIdOpt = (dep.project / projectID).get(data)
|
||||
val depSVOpt = (dep.project / scalaVersion).get(data)
|
||||
val depSBVOpt = (dep.project / scalaBinaryVersion).get(data)
|
||||
val depCrossOpt = (dep.project / crossVersion).get(data)
|
||||
(depProjIdOpt, depSVOpt, depSBVOpt, depCrossOpt) match {
|
||||
case (Some(depProjId), Some(depSV), Some(depSBV), Some(depCross)) =>
|
||||
if (sbv == depSBV || depCross != CrossVersion.binary)
|
||||
Some(
|
||||
depProjId.withConfigurations(dep.configuration)
|
||||
.withExplicitArtifacts(Vector.empty)
|
||||
)
|
||||
else if (VirtualAxis.isScala2Scala3Sandwich(sbv, depSBV) && depCross == CrossVersion.binary)
|
||||
Some(
|
||||
depProjId
|
||||
.withCrossVersion(CrossVersion.constant(depSBV))
|
||||
.withConfigurations(dep.configuration)
|
||||
.withExplicitArtifacts(Vector.empty)
|
||||
)
|
||||
else sys.error(s"scalaBinaryVersion mismatch: expected $sbv but found ${depSBV} in $depProjId")
|
||||
case _ => None
|
||||
deps.classpath(ref) flatMap { dep =>
|
||||
for {
|
||||
depProjId <- (dep.project / projectID).get(data)
|
||||
depSBV <- (dep.project / scalaBinaryVersion).get(data)
|
||||
depCross <- (dep.project / crossVersion).get(data)
|
||||
} yield {
|
||||
depCross match {
|
||||
case b: CrossVersion.Binary if VirtualAxis.isScala2Scala3Sandwich(sbv, depSBV) =>
|
||||
depProjId
|
||||
.withCrossVersion(CrossVersion.constant(depSBV))
|
||||
.withConfigurations(dep.configuration)
|
||||
.withExplicitArtifacts(Vector.empty)
|
||||
case _ =>
|
||||
depProjId.withConfigurations(dep.configuration).withExplicitArtifacts(Vector.empty)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
orig
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -446,7 +434,7 @@ object ProjectMatrix {
|
|||
private final class AxisBaseProjectFinder(axisValues: Seq[VirtualAxis]) extends ProjectFinder {
|
||||
def get: Seq[Project] = filterProjects(axisValues)
|
||||
def apply(sv: String): Project =
|
||||
filterProjects(true, axisValues ++ Seq(VirtualAxis.scalaPartialVersion(sv))).headOption
|
||||
filterProjects(true, axisValues ++ Seq(VirtualAxis.scalaABIVersion(sv))).headOption
|
||||
.getOrElse(sys.error(s"project matching $axisValues and $sv was not found"))
|
||||
def apply(autoScalaLibrary: Boolean): Project =
|
||||
filterProjects(autoScalaLibrary, axisValues).headOption
|
||||
|
|
@ -479,7 +467,7 @@ object ProjectMatrix {
|
|||
): ProjectMatrix =
|
||||
if (autoScalaLibrary) {
|
||||
scalaVersions.foldLeft(this: ProjectMatrix) { (acc, sv) =>
|
||||
acc.customRow(autoScalaLibrary, axisValues ++ Seq(VirtualAxis.scalaPartialVersion(sv)), process)
|
||||
acc.customRow(autoScalaLibrary, axisValues ++ Seq(VirtualAxis.scalaABIVersion(sv)), process)
|
||||
}
|
||||
} else {
|
||||
customRow(autoScalaLibrary, Seq(VirtualAxis.jvm), process)
|
||||
|
|
@ -530,7 +518,7 @@ object ProjectMatrix {
|
|||
|
||||
// called by macro
|
||||
def apply(id: String, base: sbt.File): ProjectMatrix = {
|
||||
val defaultDefAxes = Seq(VirtualAxis.jvm, VirtualAxis.scalaPartialVersion("2.13.3"))
|
||||
val defaultDefAxes = Seq(VirtualAxis.jvm, VirtualAxis.scalaABIVersion("2.13.3"))
|
||||
val matrix = unresolved(id, base, Nil, Nil, Nil, Nil, Nil, Nil, Plugins.Empty, Nil, defaultDefAxes)
|
||||
allMatrices(id) = matrix
|
||||
matrix
|
||||
|
|
|
|||
|
|
@ -1,16 +1,19 @@
|
|||
lazy val check = taskKey[Unit]("")
|
||||
|
||||
val dottyVersion = "3.0.0-M1"
|
||||
ThisBuild / resolvers += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/"
|
||||
// TODO use 2.13.4 when it's out
|
||||
lazy val scala213 = "2.13.4-bin-aeee8f0"
|
||||
lazy val scala3M1 = "3.0.0-M1"
|
||||
lazy val scala3M2 = "3.0.0-M2"
|
||||
lazy val scala213 = "2.13.4"
|
||||
|
||||
lazy val fooApp = (projectMatrix in file("foo-app"))
|
||||
.dependsOn(fooCore)
|
||||
.settings(
|
||||
name := "foo app",
|
||||
)
|
||||
.jvmPlatform(scalaVersions = Seq(dottyVersion))
|
||||
.jvmPlatform(scalaVersions = Seq(scala3M1, scala3M2))
|
||||
|
||||
lazy val fooApp3 = fooApp.jvm(scala3M1)
|
||||
.settings(
|
||||
test := { () },
|
||||
)
|
||||
|
||||
lazy val fooCore = (projectMatrix in file("foo-core"))
|
||||
.settings(
|
||||
|
|
@ -29,7 +32,7 @@ lazy val barCore = (projectMatrix in file("bar-core"))
|
|||
.settings(
|
||||
name := "bar core",
|
||||
)
|
||||
.jvmPlatform(scalaVersions = Seq(dottyVersion))
|
||||
.jvmPlatform(scalaVersions = Seq(scala3M2))
|
||||
|
||||
// choose 2.13 when bazCore offers both 2.13 and Dotty
|
||||
lazy val bazApp = (projectMatrix in file("baz-app"))
|
||||
|
|
@ -51,4 +54,4 @@ lazy val bazCore = (projectMatrix in file("baz-core"))
|
|||
name := "baz core",
|
||||
exportJars := true,
|
||||
)
|
||||
.jvmPlatform(scalaVersions = Seq(scala213, dottyVersion))
|
||||
.jvmPlatform(scalaVersions = Seq(scala213, scala3M1))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
> fooApp3_0/compile
|
||||
> projects
|
||||
|
||||
> fooApp3_0_0_M1/compile
|
||||
|
||||
> barApp/compile
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
lazy val check = taskKey[Unit]("")
|
||||
|
||||
val dottyVersion = "3.0.0-M1"
|
||||
ThisBuild / resolvers += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/"
|
||||
// TODO use 2.13.4 when it's out
|
||||
lazy val scala213 = "2.13.4-bin-aeee8f0"
|
||||
lazy val scala3M1 = "3.0.0-M1"
|
||||
lazy val scala3M2 = "3.0.0-M2"
|
||||
lazy val scala213 = "2.13.4"
|
||||
|
||||
lazy val fooApp = (projectMatrix in file("foo-app"))
|
||||
.dependsOn(fooCore)
|
||||
.settings(
|
||||
name := "foo app",
|
||||
)
|
||||
.jvmPlatform(scalaVersions = Seq(dottyVersion))
|
||||
.jvmPlatform(scalaVersions = Seq(scala3M1, scala3M2))
|
||||
|
||||
lazy val fooCore = (projectMatrix in file("foo-core"))
|
||||
.settings(
|
||||
|
|
@ -29,7 +27,7 @@ lazy val barCore = (projectMatrix in file("bar-core"))
|
|||
.settings(
|
||||
name := "bar core",
|
||||
)
|
||||
.jvmPlatform(scalaVersions = Seq(dottyVersion))
|
||||
.jvmPlatform(scalaVersions = Seq(scala3M1))
|
||||
|
||||
// choose 2.13 when bazCore offers both 2.13 and Dotty
|
||||
lazy val bazApp = (projectMatrix in file("baz-app"))
|
||||
|
|
@ -52,4 +50,4 @@ lazy val bazCore = (projectMatrix in file("baz-core"))
|
|||
name := "baz core",
|
||||
exportJars := true,
|
||||
)
|
||||
.jvmPlatform(scalaVersions = Seq(scala213, dottyVersion))
|
||||
.jvmPlatform(scalaVersions = Seq(scala213, scala3M1, scala3M2))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
> fooApp3_0/compile
|
||||
> projects
|
||||
|
||||
> fooApp3_0_0_M1/compile
|
||||
|
||||
> barApp/compile
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue