mirror of https://github.com/sbt/sbt.git
Add --close-io-streams flag to sbt
When we start sbt with the thin client, we want to close the server io streams after it loads so that the client exiting won't crash the server. When we are running the server as part of the server tests, it is nice to have the server output. By setting the --close-io-streams flag when we launch the server in the client, we are able to achieve both.
This commit is contained in:
parent
18cb839c47
commit
a7cb186924
|
|
@ -203,6 +203,7 @@ $AliasCommand name=
|
|||
"Provides an interactive prompt from which commands can be run on a server."
|
||||
def DashClient: String = "-client"
|
||||
def DashDashClient: String = "--client"
|
||||
def CloseIOStreams: String = "--close-io-streams"
|
||||
|
||||
def StashOnFailure: String = "sbtStashOnFailure"
|
||||
def PopOnFailure: String = "sbtPopOnFailure"
|
||||
|
|
|
|||
|
|
@ -114,6 +114,11 @@ object BasicKeys {
|
|||
"List of template resolver infos.",
|
||||
1000
|
||||
)
|
||||
private[sbt] val closeIOStreams = AttributeKey[Boolean](
|
||||
"close-io-streams",
|
||||
"Toggles wheter or not to close system in, out and error when the server starts.",
|
||||
1000
|
||||
)
|
||||
}
|
||||
|
||||
case class TemplateResolverInfo(module: ModuleID, implementationClass: String)
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ class NetworkClient(
|
|||
else Nil
|
||||
|
||||
val args = color ++ superShell ++ arguments.sbtArguments
|
||||
val cmd = arguments.sbtScript +: args
|
||||
val cmd = arguments.sbtScript +: args :+ BasicCommandStrings.CloseIOStreams
|
||||
val process =
|
||||
new ProcessBuilder(cmd: _*)
|
||||
.directory(arguments.baseDirectory)
|
||||
|
|
|
|||
|
|
@ -68,11 +68,14 @@ private[sbt] object xMain {
|
|||
NetworkClient.run(configuration, args)
|
||||
Exit(0)
|
||||
} else {
|
||||
val state = StandardMain.initialState(
|
||||
configuration,
|
||||
Seq(defaults, early),
|
||||
runEarly(DefaultsCommand) :: runEarly(InitCommand) :: BootCommand :: Nil
|
||||
)
|
||||
val closeStreams = userCommands.exists(_ == BasicCommandStrings.CloseIOStreams)
|
||||
val state = StandardMain
|
||||
.initialState(
|
||||
configuration,
|
||||
Seq(defaults, early),
|
||||
runEarly(DefaultsCommand) :: runEarly(InitCommand) :: BootCommand :: Nil
|
||||
)
|
||||
.put(BasicKeys.closeIOStreams, closeStreams)
|
||||
StandardMain.runManaged(state)
|
||||
}
|
||||
}
|
||||
|
|
@ -183,7 +186,8 @@ object StandardMain {
|
|||
sys.props.put("jna.nosys", "true")
|
||||
|
||||
import BasicCommandStrings.isEarlyCommand
|
||||
val userCommands = configuration.arguments.map(_.trim)
|
||||
val userCommands =
|
||||
configuration.arguments.map(_.trim).filterNot(_ == BasicCommandStrings.CloseIOStreams)
|
||||
val (earlyCommands, normalCommands) = (preCommands ++ userCommands).partition(isEarlyCommand)
|
||||
val commands = (earlyCommands ++ normalCommands).toList map { x =>
|
||||
Exec(x, None)
|
||||
|
|
|
|||
|
|
@ -217,6 +217,7 @@ private[sbt] final class CommandExchange {
|
|||
server = None
|
||||
firstInstance.set(false)
|
||||
}
|
||||
if (s.get(BasicKeys.closeIOStreams).getOrElse(false)) Terminal.close()
|
||||
}
|
||||
s
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue