diff --git a/main-command/src/main/scala/sbt/BasicCommandStrings.scala b/main-command/src/main/scala/sbt/BasicCommandStrings.scala index 6d7b6c52e..efa853903 100644 --- a/main-command/src/main/scala/sbt/BasicCommandStrings.scala +++ b/main-command/src/main/scala/sbt/BasicCommandStrings.scala @@ -161,6 +161,12 @@ $AliasCommand name= def ShellDetailed = "Provides an interactive prompt and network server from which commands can be run." + def StartServer = "startServer" + def StartServerDetailed = + s"""$StartServer + Starts the server if it has not been started. This is intended to be used with + -Dsbt.server.autostart=false.""" + def OldShell = "oldshell" def OldShellDetailed = "Provides an interactive prompt from which commands can be run." diff --git a/main/src/main/scala/sbt/Main.scala b/main/src/main/scala/sbt/Main.scala index 493f88117..f4043f989 100644 --- a/main/src/main/scala/sbt/Main.scala +++ b/main/src/main/scala/sbt/Main.scala @@ -195,6 +195,7 @@ object BuiltinCommands { multi, shell, oldshell, + startServer, BasicCommands.client, continuous, eval, @@ -737,6 +738,12 @@ object BuiltinCommands { else newState.clearGlobalLog } + def startServer: Command = + Command.command(StartServer, Help.more(StartServer, StartServerDetailed)) { s0 => + val exchange = StandardMain.exchange + exchange.runServer(s0) + } + private val sbtVersionRegex = """sbt\.version\s*=.*""".r private def isSbtVersionLine(s: String) = sbtVersionRegex.pattern matcher s matches () diff --git a/main/src/main/scala/sbt/internal/CommandExchange.scala b/main/src/main/scala/sbt/internal/CommandExchange.scala index 8cc17a909..d56edb245 100644 --- a/main/src/main/scala/sbt/internal/CommandExchange.scala +++ b/main/src/main/scala/sbt/internal/CommandExchange.scala @@ -23,6 +23,9 @@ import scala.util.{ Success, Failure } * this exchange, which could serve command request from either of the channel. */ private[sbt] final class CommandExchange { + private val autoStartServer = sys.props.get("sbt.server.autostart") map { + _.toLowerCase == "true" + } getOrElse true private val lock = new AnyRef {} private var server: Option[ServerInstance] = None private var consoleChannel: Option[ConsoleChannel] = None @@ -61,13 +64,17 @@ private[sbt] final class CommandExchange { consoleChannel = Some(x) subscribe(x) } - runServer(s) + if (autoStartServer) runServer(s) + else s } private def newChannelName: String = s"channel-${nextChannelId.incrementAndGet()}" - private def runServer(s: State): State = { - val port = (s get serverPort) match { + /** + * Check if a server instance is running already, and start one if it isn't. + */ + private[sbt] def runServer(s: State): State = { + def port = (s get serverPort) match { case Some(x) => x case None => 5001 } diff --git a/notes/1.0.2.markdown b/notes/1.0.2.markdown new file mode 100644 index 000000000..44cad0df7 --- /dev/null +++ b/notes/1.0.2.markdown @@ -0,0 +1,37 @@ +This is a hotfix release for sbt 1.0.x series. + +### Bug fixes + +- Fixes terminal echo issue. [#3507][3507] by [@kczulko][@kczulko] +- Fixes `deliver` task, and adds `makeIvyXml` as a more sensibly named task. [#3487][3487] by [@cunei][@cunei] +- Replaces the deprecated use of `OkUrlFactory`, and fixes connection leaks. [lm#164][lm164] by [@dpratt][@dpratt] +- Refixes false positive in DSL checker for setting keys. [#3513][3513] by [@dwijnand][@dwijnand] +- Fixes `run` and `bgRun` not picking up changes to directories in the classpath. [#3517][3517] by [@dwijnand][@dwijnand] +- Fixes `++` so it won't change the value of `crossScalaVersion`. [#3495][3495]/[#3526][3526] by [@dwijnand][@dwijnand] +- Fixes sbt server missing some messages. [#3523][3523] by [@guillaumebort][@guillaumebort] +- Refixes `consoleProject`. [zinc#386][zinc386] by [@dwijnand][@dwijnand] +- Adds JVM flag `sbt.gigahorse` to enable/disable the internal use of Gigahorse to workaround NPE in `JavaNetAuthenticator` when used in conjunction with `repositories` override. [lm#167][lm167] by [@cunei][@cunei] +- Adds JVM flag `sbt.server.autostart` to enable/disable the automatic starting of sbt server with the sbt shell. This also adds new `startServer` command to manually start the server. by [@eed3si9n][@eed3si9n] + +### Internal + +- Fixes unused import warnings. [#3533][3533] by [@razvan-panda][@razvan-panda] + + [@dwijnand]: https://github.com/dwijnand + [@cunei]: https://github.com/cunei + [@eed3si9n]: https://github.com/eed3si9n + [@dpratt]: https://github.com/dpratt + [@kczulko]: https://github.com/kczulko + [@razvan-panda]: https://github.com/razvan-panda + [@guillaumebort]: https://github.com/guillaumebort + [3487]: https://github.com/sbt/sbt/pull/3487 + [lm164]: https://github.com/sbt/librarymanagement/pull/164 + [3495]: https://github.com/sbt/sbt/issues/3495 + [3526]: https://github.com/sbt/sbt/pull/3526 + [3513]: https://github.com/sbt/sbt/pull/3513 + [3517]: https://github.com/sbt/sbt/pull/3517 + [3507]: https://github.com/sbt/sbt/pull/3507 + [3533]: https://github.com/sbt/sbt/pull/3533 + [3523]: https://github.com/sbt/sbt/pull/3523 + [zinc386]: https://github.com/sbt/zinc/pull/386 + [lm167]: https://github.com/sbt/librarymanagement/pull/167 diff --git a/notes/1.0.2/lm.markdown b/notes/1.0.2/lm.markdown deleted file mode 100644 index dfab65977..000000000 --- a/notes/1.0.2/lm.markdown +++ /dev/null @@ -1,12 +0,0 @@ - -### Fixes with compatibility implications - -### Improvements - - -### Bug fixes - -- Replaces the deprecated use of `OkUrlFactory`, and fixes connection leaks. [lm#164][lm164] by [@dpratt][@dpratt] - - [lm164]: https://github.com/sbt/librarymanagement/pull/164 - [@dpratt]: https://github.com/dpratt diff --git a/notes/1.0.2/plusplus-not-changing-crossScalaVersions.md b/notes/1.0.2/plusplus-not-changing-crossScalaVersions.md deleted file mode 100644 index 58e368794..000000000 --- a/notes/1.0.2/plusplus-not-changing-crossScalaVersions.md +++ /dev/null @@ -1,12 +0,0 @@ -[@dwijnand]: https://github.com/dwijnand - -[#3495]: https://github.com/sbt/sbt/issues/3495 -[#3526]: https://github.com/sbt/sbt/pull/3526 - -### Fixes with compatibility implications - -### Improvements - -### Bug fixes - -- Fixes `++` so it don't change the value of `crossScalaVersion`. [#3495][]/[#3526][] by [@dwijnand][] diff --git a/notes/1.0.2/server-issue.markdown b/notes/1.0.2/server-issue.markdown deleted file mode 100644 index 631237f80..000000000 --- a/notes/1.0.2/server-issue.markdown +++ /dev/null @@ -1,5 +0,0 @@ -### Bug fixes - -- In some cases sbt server was missing some messages. By [@guillaumebort][@guillaumebort]. - - [@guillaumebort]: https://github.com/guillaumebort