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
Forced version in some cross operations #5497
Comments
I took some time to narrow this down, and have a 'reproducer' at https://github.com/raboof/sbt-reproduce-5497/blob/master/build.sbt#L6 - Turns out this use of This reproducer shows a scenario that 'worked' up until and including sbt 1.3.4, and no longer after that. It does not really motivate that this should work 😄 . The 1.3.4 behavior happened to be convenient in Akka gRPC, but perhaps the new behavior is actually more reasonable - I haven't looked into that yet. |
But the |
It definitely is, in project/ReflectiveCodeGen.scala - which I'll admit is
a bit exotic, here be dragons, you have been warned :D
…On Thu, 16 Apr 2020, 18:29 Ignasi Marimon-Clos, ***@***.***> wrote:
Turns out this use of ProjectRef here was essential in reproducing the
behavior.
But the akka-grpc build is not using ProjectRef, is it? There are muliple
<https://github.com/sbt/sbt/pull/5494/files> places where the version is
forced and I wonder if your reproducer just raised another bug. 😅
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5497 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABAGEEJ2AX6JVFD3QNTCLLRM4W7VANCNFSM4MCLXQ7Q>
.
|
When Roper brought over my sbt-doge into sbt 1.x in #2613 there were no sbt 0.13 cross buildingsbt 0.13, https://github.com/sbt/sbt/blob/v0.13.18/main/src/main/scala/sbt/Cross.scala#L106-L115 lazy val crossBuild = Command.arb(requireSession(crossParser), crossHelp) { (state, command) =>
val x = Project.extract(state)
import x._
val versions = crossVersions(state)
val current = scalaVersion in currentRef get structure.data map (SwitchCommand + " " + _) toList;
if (versions.isEmpty) command :: state
else {
versions.map(v => s"$SwitchCommand $v $command") ::: current ::: state
}
} So given
Note that in sbt 0.13
And also note that this happened regardless of the individual subprojects' doge bitesHowever sbt-doge was not without fault. When we moved to the new sbt-doge system, heterogenous cross building improved but it also lost the ability to run commands, aliases, and input tasks, because in sbt-doge I've made an assumption that the cross arguments are tasks. This was reported as #2776. Roper came to the rescue again in #3446. To increase the backward compatibility of sbt 0.13 (This was still in 2017 so that was important), he came up with dual system in which cross argument would be parsed to see if it was a command or a task: // Detect whether a task or command has been issued
val allCommands = Parser.parse(aggCommand, Act.aggregatedKeyParser(x)) match {
case Left(_) =>
// It's definitely not a task
.... This is a code path emulating sbt 0.13
// Execute using a blanket switch
projCrossVersions.toMap.apply(currentRef).flatMap { version =>
// Force scala version
Seq(s"$SwitchCommand $verbose $version!", aggCommand)
}
case Right(_) =>
// We have a key, we're likely to be able to cross build this using the per project behaviour.
.... This is a code path emulating sbt-doge
} Because we're emulating sbt 0.13 behavior on input task support and !#3446 added the command support, but what about input tasks like Ethan contributed #5265 to restore the input task support, which was released as part of 1.3.5. This regressed in parallel task processing so Ethan later sent in #5329 as well. These two PRs together introduced commandsByVersion.flatMap {
case (v, commands) =>
commands match {
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
}
} In all of these cases, I am guessing that What we should aim for I think is figuring out the exact corner cases for these |
Here are some tests I added - #5512 |
(I think this is a regression introduced in some of the changes in
Cross
in version1.3.5
and forward)steps
Given a project with 3 modules:
a
hascrossScalaVersions := Seq("2.12.10")
andscalaVersion := "2.12.10"
b
hascrossScalaVersions := Seq("2.12.10", "2.13.1")
andscalaVersion := "2.12.10"
c
hascrossScalaVersions := Seq("2.12.10")
andscalaVersion := "2.12.10"
.c
also depends ona
And a
root
which aggregates all the modules above and setscrossScalaVersions := Nil
andscalaVersion := "2.12.10"
.When running
+publishLocal
botha
andc
are published for2.12.10
and2.13.1
.See akka/akka-grpc#907 for a reproducer. That PR executes
+publishLocal
as expected when run on sbt1.3.4
but fails when run on any version after1.3.5
.problem
Starting sbt
1.3.5
using+
will oftenForce
the scala version instead ofSetting
it. The implication is that some projects that don't define a particular scala versionin the
crossScalaVersions
are added to the task anyway.expectation
Given the project above, I would expect the following artifacts only:
notes
1.6.x
branch build. The Lagom1.6.x
branch build has an even more complex cross-version setup since it support not only2.12
and2.13
but also sbt0.13
and1.0
(which requires some artifacts to be built for scala2.10
.c
I refer to in my examples above is actually anSbtPlugin
(no surprise there). The particularity of theSbtPlugin
inakka-grpc
is that it depends on another, externalSbtPlugin
.The text was updated successfully, but these errors were encountered: