Add pseudo --server command

Ref https://github.com/sbt/sbt/issues/5665

This adds `--server` command that is immediately filtered out in Main.scala.
The purpose of `--server` is so we can invoke thin client from `sbt` script at some point in the future when Bash script can parse `project/build.properties`.

`sbtn` would need to call `sbt` again to start the server, and at that point the shell script would need to actually invoke the server. The intent of `--server` is to be used as the tie breaker.

Also build users may want to sometimes call `sbt --server`.
This commit is contained in:
Eugene Yokota 2020-09-07 23:56:46 -04:00
parent 8160035f41
commit bba3d08aac
3 changed files with 10 additions and 3 deletions

View File

@ -200,6 +200,10 @@ $AliasCommand name=
Starts the server if it has not been started. This is intended to be used with
-Dsbt.server.autostart=false."""
def ServerDetailed: String =
"--server always runs sbt in not-daemon mode."
def DashDashServer: String = "--server"
def OldShell: String = "oldshell"
def OldShellDetailed = "Provides an interactive prompt from which commands can be run."

View File

@ -298,7 +298,8 @@ class NetworkClient(
term.isSupershellEnabled
).mkString(",")
val cmd = arguments.sbtScript +: arguments.sbtArguments :+ BasicCommandStrings.CloseIOStreams
val cmd = List(arguments.sbtScript) ++ arguments.sbtArguments ++
List(BasicCommandStrings.CloseIOStreams, BasicCommandStrings.DashDashServer)
val processBuilder =
new ProcessBuilder(cmd: _*)
.directory(arguments.baseDirectory)

View File

@ -59,7 +59,7 @@ private[sbt] object xMain {
}
private[sbt] def run(configuration: xsbti.AppConfiguration): xsbti.MainResult = {
try {
import BasicCommandStrings.{ DashClient, DashDashClient, runEarly }
import BasicCommandStrings.{ DashClient, DashDashClient, DashDashServer, runEarly }
import BasicCommands.early
import BuiltinCommands.defaults
import sbt.internal.CommandStrings.{ BootCommand, DefaultsCommand, InitCommand }
@ -71,7 +71,9 @@ private[sbt] object xMain {
}
// if we detect -Dsbt.client=true or -client, run thin client.
val clientModByEnv = SysProp.client
val userCommands = configuration.arguments.map(_.trim)
val userCommands = configuration.arguments
.map(_.trim)
.filterNot(_ == DashDashServer)
val isClient: String => Boolean = cmd => (cmd == DashClient) || (cmd == DashDashClient)
val isBsp: String => Boolean = cmd => (cmd == "-bsp") || (cmd == "--bsp")
if (userCommands.exists(isBsp)) {