Skip to content

Commit

Permalink
Merge pull request #2613 from jroper/sbt-doge
Browse files Browse the repository at this point in the history
Replaced cross building support with sbt-doge
  • Loading branch information
eed3si9n committed May 17, 2016
2 parents 1d0eda2 + e21c871 commit 5ecbf50
Show file tree
Hide file tree
Showing 10 changed files with 354 additions and 107 deletions.
329 changes: 235 additions & 94 deletions main/src/main/scala/sbt/Cross.scala

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion main/src/main/scala/sbt/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ object BuiltinCommands {
def ScriptCommands: Seq[Command] = Seq(ignore, exit, Script.command, setLogLevel, early, act, nop)
def DefaultCommands: Seq[Command] = Seq(ignore, help, completionsCommand, about, tasks, settingsCommand, loadProject,
projects, project, reboot, read, history, set, sessionCommand, inspect, loadProjectImpl, loadFailed, Cross.crossBuild, Cross.switchVersion,
setOnFailure, clearOnFailure, stashOnFailure, popOnFailure, setLogLevel, plugin, plugins,
Cross.crossRestoreSession, setOnFailure, clearOnFailure, stashOnFailure, popOnFailure, setLogLevel, plugin, plugins,
ifLast, multi, shell, continuous, eval, alias, append, last, lastGrep, export, boot, nop, call, exit, early, initialize, act) ++
compatCommands
def DefaultBootCommands: Seq[String] = LoadProject :: (IfLast + " " + Shell) :: Nil
Expand Down
38 changes: 30 additions & 8 deletions main/src/main/scala/sbt/internal/CommandStrings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -293,38 +293,60 @@ defaults
Nil

val CrossCommand = "+"
val CrossRestoreSessionCommand = "+-"
val SwitchCommand = "++"

def crossHelp: Help = Help.more(CrossCommand, CrossDetailed)
def crossRestoreSessionHelp = Help.more(CrossRestoreSessionCommand, CrossRestoreSessionDetailed)
def switchHelp: Help = Help.more(SwitchCommand, SwitchDetailed)

def CrossDetailed =
s"""$CrossCommand <command>
s"""$CrossCommand [-v] <command>
Runs <command> for each Scala version specified for cross-building.

For each string in `crossScalaVersions` in the current project, this command sets the
`scalaVersion` of all projects to that version, reloads the build, and
executes <command>. When finished, it reloads the build with the original
Scala version.
For each string in `crossScalaVersions` in each project project, this command sets
the `scalaVersion` of all projects that list that Scala version with that Scala
version reloads the build, and then executes <command> for those projects. When
finished, it resets the build to its original state.

If -v is supplied, verbose logging of the Scala version switching is done.

See also `help $SwitchCommand`
"""

def CrossRestoreSessionDetailed =
s"""$CrossRestoreSessionCommand

Restores a session that was captured by the cross command, +.
"""

def SwitchDetailed =
s"""$SwitchCommand <scala-version> [<command>]
s"""$SwitchCommand <scala-version>[!] [-v] [<command>]
Changes the Scala version and runs a command.

Sets the `scalaVersion` of all projects to <scala-version> and reloads the build.
Sets the `scalaVersion` of all projects that define a Scala cross version that is binary
compatible with <scala-version> and reloads the build. If ! is supplied, then the
version is forced on all projects regardless of whether they are binary compatible or
not.

If -v is supplied, verbose logging of the Scala version switching is done.

If <command> is provided, it is then executed.

$SwitchCommand [<scala-version>=]<scala-home> [<command>]
$SwitchCommand [<scala-version>=]<scala-home>[!] [-v] [<command>]
Uses the Scala installation at <scala-home> by configuring the scalaHome setting for
all projects.

If <scala-version> is specified, it is used as the value of the scalaVersion setting.
This is important when using managed dependencies. This version will determine the
cross-version used as well as transitive dependencies.

Only projects that are listed to be binary compatible with the selected Scala version
have their Scala version switched. If ! is supplied, then all projects projects have
their Scala version switched.

If -v is supplied, verbose logging of the Scala version switching is done.

If <command> is provided, it is then executed.

See also `help $CrossCommand`
Expand Down
10 changes: 10 additions & 0 deletions notes/1.0.0/sbt-doge.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[@jroper]: https://github.com/jroper
[2613]: https://github.com/sbt/sbt/pull/2613

### Fixes with compatibility implications

### Improvements

- Replace cross building support with sbt-doge. This allows builds with projects that have multiple different combinations of cross scala versions to be cross built correctly. The behaviour of ++ is changed so that it only updates the Scala version of projects that support that Scala version, but the Scala version can be post fixed with ! to force it to change for all projects. A -v argument has been added that prints verbose information about which projects are having their settings changed along with their cross scala versions. [#2613][2613] by [@jroper][@jroper].

### Bug fixes
18 changes: 18 additions & 0 deletions sbt/src/sbt-test/actions/cross-multiproject/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

lazy val rootProj = (project in file(".")).
aggregate(libProj, fooPlugin)

lazy val libProj = (project in file("lib")).
settings(
name := "foo-lib",
scalaVersion := "2.11.8",
crossScalaVersions := Seq("2.11.8", "2.10.4")
)

lazy val fooPlugin =(project in file("sbt-foo")).
settings(
name := "sbt-foo",
sbtPlugin := true,
scalaVersion := "2.10.4",
crossScalaVersions := Seq("2.10.4")
)
5 changes: 5 additions & 0 deletions sbt/src/sbt-test/actions/cross-multiproject/lib/A.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package foo

object Foo {

}
5 changes: 5 additions & 0 deletions sbt/src/sbt-test/actions/cross-multiproject/sbt-foo/B.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package foo.sbt

object SbtFoo {

}
46 changes: 46 additions & 0 deletions sbt/src/sbt-test/actions/cross-multiproject/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
> + compile

$ exists lib/target/scala-2.11
$ exists lib/target/scala-2.10
$ exists sbt-foo/target/scala-2.10
-$ exists sbt-foo/target/scala-2.11

> clean
> + libProj/compile

$ exists lib/target/scala-2.11
$ exists lib/target/scala-2.10
-$ exists sbt-foo/target/scala-2.10
-$ exists sbt-foo/target/scala-2.11

> clean
> ++ 2.11.1 compile

$ exists lib/target/scala-2.11
-$ exists lib/target/scala-2.10
$ exists sbt-foo/target/scala-2.10
-$ exists sbt-foo/target/scala-2.11

> clean
> ++ 2.10.4 compile

-$ exists lib/target/scala-2.11
$ exists lib/target/scala-2.10
$ exists sbt-foo/target/scala-2.10
-$ exists sbt-foo/target/scala-2.11

> clean
> ++ 2.11.5 compile

$ exists lib/target/scala-2.11
-$ exists lib/target/scala-2.10
$ exists sbt-foo/target/scala-2.10
-$ exists sbt-foo/target/scala-2.11

> clean
> ++ 2.11.5! compile

$ exists lib/target/scala-2.11
-$ exists lib/target/scala-2.10
-$ exists sbt-foo/target/scala-2.10
$ exists sbt-foo/target/scala-2.11
4 changes: 2 additions & 2 deletions sbt/src/sbt-test/actions/cross/test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
> check 2.7.7 2.9.1 2.9.0-1
> ++ 2.8.2
> ++ 2.8.2!
> check 2.8.2 2.8.2 2.8.1
> ++ 2.10.4
> ++ 2.10.4!
> set resolvers ++= Nil
> check 2.10.4 2.10.4 2.10.4
> session clear-all
Expand Down
4 changes: 2 additions & 2 deletions sbt/src/sbt-test/source-dependencies/cross-source/test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# A.scala needs B.scala, it won't be in source list
> ++2.11.4
> ++2.11.4!
-> compile

# A.scala needs B.scala, it would be in source list
> ++2.10.4
> ++2.10.4!
> compile

0 comments on commit 5ecbf50

Please sign in to comment.