Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using a projectref across scala versions with cross building #5511

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions main/src/main/scala/sbt/Cross.scala
Original file line number Diff line number Diff line change
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)
Comment on lines -161 to +162
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this ! is necessary for sbt 0.13 emulation - #5497 (comment)

}
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, in #5494 I didn't really know what I was doing and I aggressively removed the use of !. Is it necessary to remove the use of ! in all three code occurrences to fix the issue?

After I sent #5494 I started thinking I might introduce other regressions.

PS: I noticed you didn't edit line 201 which makes me assume you indeed change the minimum occurrences required 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reproducer doesn't need all 3 changes, but it would be quite inconsistent to not change all of these occurrences, as they seems quite similar. I'm definitely not familiar enough with this code to predict all the possible effects of this change, but at least the test suite doesn't appear to signal any regressions.

}
}
}
Expand Down
25 changes: 25 additions & 0 deletions sbt/src/sbt-test/actions/cross-build-with-projectref/build.sbt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
> +compile