Merge pull request #6939 from eed3si9n/wip/cross-fix

[1.7.x] Filter incompatible Scala 3 projects in cross switch commands, take 2
This commit is contained in:
eugene yokota 2022-06-27 00:08:29 -04:00 committed by GitHub
commit 7cc6ad3d00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 5 deletions

View File

@ -339,16 +339,18 @@ object Cross {
)
}
}
} else {
val binaryVersion = CrossVersion.binaryScalaVersion(version)
} else
// This is the default implementation for ++ <sv> <command1>
// It checks that <sv> is backward compatible with one of the Scala versions listed
// in crossScalaVersions setting. Note this must account for the fact that in Scala 3.x
// 3.1.0 is not compatible with 3.0.0.
projectScalaVersions.map {
case (project, scalaVersions) =>
if (scalaVersions.exists(v => CrossVersion.binaryScalaVersion(v) == binaryVersion))
if (scalaVersions.exists(CrossVersion.isScalaBinaryCompatibleWith(version, _)))
(project, Some(version), scalaVersions)
else
(project, None, scalaVersions)
}
}
}
val included = projects.collect {

View File

@ -0,0 +1,8 @@
[@ruippeixotog]: https://github.com/ruippeixotog
[#6915]: https://github.com/sbt/sbt/issues/6915
[#6926]: https://github.com/sbt/sbt/pull/6926
### Bug Fixes
- Make `++ <scala-version> <command>` run `<command>` only on compatible Scala 3 subprojects. [#6915][]/[#6926][] by [@ruippeixotog][]

View File

@ -14,7 +14,7 @@ object Dependencies {
// sbt modules
private val ioVersion = nightlyVersion.getOrElse("1.6.0")
private val lmVersion =
sys.props.get("sbt.build.lm.version").orElse(nightlyVersion).getOrElse("1.7.0-M1")
sys.props.get("sbt.build.lm.version").orElse(nightlyVersion).getOrElse("1.7.0-M3")
val zincVersion = nightlyVersion.getOrElse("1.7.0-M2")
private val sbtIO = "org.scala-sbt" %% "io" % ioVersion

View File

@ -0,0 +1,14 @@
scalaVersion := "2.12.16"
lazy val core = project
.settings(
crossScalaVersions := Seq("2.12.16", "3.0.2", "3.1.2")
)
lazy val subproj = project
.dependsOn(core)
.settings(
crossScalaVersions := Seq("2.12.16", "3.1.2"),
// a random library compiled against Scala 3.1
libraryDependencies += "org.http4s" %% "http4s-core" % "0.23.12"
)

View File

@ -0,0 +1,6 @@
import org.http4s.Uri
object A {
// Just using something from http4s
Uri.fromString("example.com")
}

View File

@ -0,0 +1,14 @@
> ++3.0.2 compile
$ exists core/target/scala-3.0.2
-$ exists core/target/scala-3.1.2
-$ exists subproj/target/scala-3.0.2
-$ exists subproj/target/scala-3.1.2
> clean
> ++3.1.2 compile
-$ exists core/target/scala-3.0.2
$ exists core/target/scala-3.1.2
-$ exists subproj/target/scala-3.0.2
$ exists subproj/target/scala-3.1.2