mirror of https://github.com/sbt/sbt.git
Merge pull request #3995 from ruippeixotog/cross-strict-aggregation
Filter incompatible aggregates in cross switch commands
This commit is contained in:
commit
80d342a811
|
|
@ -216,12 +216,30 @@ object Cross {
|
|||
Command.arb(requireSession(switchParser), switchHelp)(switchCommandImpl)
|
||||
|
||||
private def switchCommandImpl(state: State, args: Switch): State = {
|
||||
val switchedState = switchScalaVersion(args, state)
|
||||
val x = Project.extract(state)
|
||||
val (switchedState, affectedRefs) = switchScalaVersion(args, state)
|
||||
|
||||
args.command.toList ::: switchedState
|
||||
val strictCmd =
|
||||
if (args.version.force) {
|
||||
// The Scala version was forced on the whole build, run as is
|
||||
args.command
|
||||
} else {
|
||||
args.command.map { rawCmd =>
|
||||
parseCommand(rawCmd) match {
|
||||
case Right(_) => rawCmd // A project is specified, run as is
|
||||
case Left(cmd) =>
|
||||
resolveAggregates(x)
|
||||
.intersect(affectedRefs)
|
||||
.collect { case ProjectRef(_, proj) => s"$proj/$cmd" }
|
||||
.mkString("all ", " ", "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
strictCmd.toList ::: switchedState
|
||||
}
|
||||
|
||||
private def switchScalaVersion(switch: Switch, state: State): State = {
|
||||
private def switchScalaVersion(switch: Switch, state: State): (State, Seq[ResolvedReference]) = {
|
||||
val extracted = Project.extract(state)
|
||||
import extracted._
|
||||
|
||||
|
|
@ -291,7 +309,7 @@ object Cross {
|
|||
}
|
||||
}
|
||||
|
||||
setScalaVersionForProjects(version, instance, projects, state, extracted)
|
||||
(setScalaVersionForProjects(version, instance, projects, state, extracted), projects.map(_._1))
|
||||
}
|
||||
|
||||
private def setScalaVersionForProjects(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
[@ruippeixotog]: https://github.com/ruippeixotog
|
||||
|
||||
[#3698]: https://github.com/sbt/sbt/issues/3698
|
||||
[#3995]: https://github.com/sbt/sbt/pull/3995
|
||||
|
||||
### Improvements
|
||||
|
||||
- Make `++ <scala-version> <command>` run `<command>` only on compatible subprojects. [#3698][]/[#3995][] by [@ruippeixotog][]
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
lazy val root = (project in file("."))
|
||||
.aggregate(core, module)
|
||||
|
||||
lazy val core = (project in file("core"))
|
||||
.settings(
|
||||
scalaVersion := "2.12.4",
|
||||
crossScalaVersions := Seq("2.11.11", "2.12.4"))
|
||||
|
||||
lazy val module = (project in file("module"))
|
||||
.dependsOn(core)
|
||||
.settings(
|
||||
scalaVersion := "2.12.4",
|
||||
crossScalaVersions := Seq("2.12.4"))
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package foo
|
||||
|
||||
object Foo {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package foo.module
|
||||
|
||||
object FooModule {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
> ++2.11.11 compile
|
||||
|
||||
$ exists core/target/scala-2.11
|
||||
-$ exists module/target/scala-2.11
|
||||
-$ exists module/target/scala-2.12
|
||||
Loading…
Reference in New Issue