Skip to content

Commit

Permalink
Allow using a projectref across scala versions with cross building
Browse files Browse the repository at this point in the history
Reproduces sbt#5497 and contains the fix by @ignasi35 from sbt#5494 - I'm not seeing
actions/cross-test-only fail here
  • Loading branch information
raboof committed Apr 23, 2020
1 parent 56cf50f commit fa9557d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main/src/main/scala/sbt/Cross.scala
Expand Up @@ -158,8 +158,8 @@ object Cross {

// Execute using a blanket switch
projCrossVersions.toMap.apply(extracted.currentRef).flatMap { version =>
// Force scala version
Seq(s"$SwitchCommand $verbose $version!", aggCommand)
// Set scala version
Seq(s"$SwitchCommand $verbose $version", aggCommand)
}
case Right((keys, taskArgs)) =>
def project(key: ScopedKey[_]): Option[ProjectRef] = key.scope.project.toOption match {
Expand Down Expand Up @@ -195,11 +195,11 @@ object Cross {
commandsByVersion.flatMap {
case (v, commands) =>
commands match {
case Seq(c) => Seq(s"$SwitchCommand $verbose $v! $c")
case Seq(c) => Seq(s"$SwitchCommand $verbose $v $c")
case Seq() => Nil // should be unreachable
case multi if fullArgs.isEmpty =>
Seq(s"$SwitchCommand $verbose $v! all ${multi.mkString(" ")}")
case multi => Seq(s"$SwitchCommand $verbose $v!") ++ multi
case multi => Seq(s"$SwitchCommand $verbose $v") ++ multi
}
}
}
Expand Down
25 changes: 25 additions & 0 deletions sbt/src/sbt-test/actions/cross-build-with-projectref/build.sbt
@@ -0,0 +1,25 @@
val b = Project("b", file("b"))
.settings(
crossScalaVersions := Seq("2.12.10", "2.13.1"),
compile in Compile := {
// We'd like to be able to inspect to this 2.12-only project
// even while compiling the 2.13 version of 'b'
(fullClasspath in Compile in ProjectRef(file("."), "c")).value
(compile in Compile).value
}
)

val c = Project("c", file("c"))
.enablePlugins(SbtPlugin)
.settings(
crossScalaVersions := Seq("2.12.10"),
libraryDependencies +=
// Some library that is not available on 2.13
"com.typesafe.akka" %% "akka-actor" % "2.5.0"
)

val root = Project("reproduce-5497", file("."))
.aggregate(b, c)
.settings(
crossScalaVersions := Nil
)
1 change: 1 addition & 0 deletions sbt/src/sbt-test/actions/cross-build-with-projectref/test
@@ -0,0 +1 @@
> +compile

0 comments on commit fa9557d

Please sign in to comment.