Merge pull request #3551 from eed3si9n/wip/autostart

`sbt.server.autostart` flag and startServer
This commit is contained in:
eugene yokota 2017-09-16 15:25:11 -04:00 committed by GitHub
commit c855f0cd9e
7 changed files with 60 additions and 32 deletions

View File

@ -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."

View File

@ -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 ()

View File

@ -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
}

37
notes/1.0.2.markdown Normal file
View File

@ -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

View File

@ -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

View File

@ -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][]

View File

@ -1,5 +0,0 @@
### Bug fixes
- In some cases sbt server was missing some messages. By [@guillaumebort][@guillaumebort].
[@guillaumebort]: https://github.com/guillaumebort