From cb72b1e9f128524990b318a991628b2cb641291c Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 2 Dec 2020 00:28:57 -0500 Subject: [PATCH] Port fix for sandwich and Scala.JS Ref https://github.com/sbt/sbt/pull/5984 --- .../scala/sbt/internal/ProjectMatrix.scala | 40 +++++++------------ .../jvm-sandwich-sbt-1.3/build.sbt | 18 +++++---- .../projectMatrix/jvm-sandwich/build.sbt | 13 +++--- 3 files changed, 29 insertions(+), 42 deletions(-) diff --git a/src/main/scala/sbt/internal/ProjectMatrix.scala b/src/main/scala/sbt/internal/ProjectMatrix.scala index 9793b949d..9ec11ad8b 100644 --- a/src/main/scala/sbt/internal/ProjectMatrix.scala +++ b/src/main/scala/sbt/internal/ProjectMatrix.scala @@ -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 } } diff --git a/src/sbt-test/projectMatrix/jvm-sandwich-sbt-1.3/build.sbt b/src/sbt-test/projectMatrix/jvm-sandwich-sbt-1.3/build.sbt index 50014c4b8..5d0889dd8 100644 --- a/src/sbt-test/projectMatrix/jvm-sandwich-sbt-1.3/build.sbt +++ b/src/sbt-test/projectMatrix/jvm-sandwich-sbt-1.3/build.sbt @@ -1,16 +1,18 @@ 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 scala3 = "3.0.0-M1" +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(scala3)) + +lazy val fooApp3 = fooApp.jvm(scala3) + .settings( + test := { () }, + ) lazy val fooCore = (projectMatrix in file("foo-core")) .settings( @@ -29,7 +31,7 @@ lazy val barCore = (projectMatrix in file("bar-core")) .settings( name := "bar core", ) - .jvmPlatform(scalaVersions = Seq(dottyVersion)) + .jvmPlatform(scalaVersions = Seq(scala3)) // choose 2.13 when bazCore offers both 2.13 and Dotty lazy val bazApp = (projectMatrix in file("baz-app")) @@ -51,4 +53,4 @@ lazy val bazCore = (projectMatrix in file("baz-core")) name := "baz core", exportJars := true, ) - .jvmPlatform(scalaVersions = Seq(scala213, dottyVersion)) + .jvmPlatform(scalaVersions = Seq(scala213, scala3)) diff --git a/src/sbt-test/projectMatrix/jvm-sandwich/build.sbt b/src/sbt-test/projectMatrix/jvm-sandwich/build.sbt index 144beadf5..cb883a837 100644 --- a/src/sbt-test/projectMatrix/jvm-sandwich/build.sbt +++ b/src/sbt-test/projectMatrix/jvm-sandwich/build.sbt @@ -1,16 +1,13 @@ 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 scala3 = "3.0.0-M1" +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(scala3)) lazy val fooCore = (projectMatrix in file("foo-core")) .settings( @@ -29,7 +26,7 @@ lazy val barCore = (projectMatrix in file("bar-core")) .settings( name := "bar core", ) - .jvmPlatform(scalaVersions = Seq(dottyVersion)) + .jvmPlatform(scalaVersions = Seq(scala3)) // choose 2.13 when bazCore offers both 2.13 and Dotty lazy val bazApp = (projectMatrix in file("baz-app")) @@ -52,4 +49,4 @@ lazy val bazCore = (projectMatrix in file("baz-core")) name := "baz core", exportJars := true, ) - .jvmPlatform(scalaVersions = Seq(scala213, dottyVersion)) + .jvmPlatform(scalaVersions = Seq(scala213, scala3))