mirror of https://github.com/sbt/sbt.git
Implement 'suppressServer' setting, for builds and plugins that prefer to be conservative about exposure to other processes.
This commit is contained in:
parent
cbf7d92488
commit
0aa133d276
|
|
@ -39,6 +39,12 @@ object BasicKeys {
|
||||||
"The wire protocol for the server command.",
|
"The wire protocol for the server command.",
|
||||||
10000)
|
10000)
|
||||||
|
|
||||||
|
val suppressServer =
|
||||||
|
AttributeKey[Boolean](
|
||||||
|
"suppressServer",
|
||||||
|
"Running the server will be suppressed if 'suppressServer is explicitly set to true.",
|
||||||
|
10000)
|
||||||
|
|
||||||
// Unlike other BasicKeys, this is not used directly as a setting key,
|
// Unlike other BasicKeys, this is not used directly as a setting key,
|
||||||
// and severLog / logLevel is used instead.
|
// and severLog / logLevel is used instead.
|
||||||
private[sbt] val serverLogLevel =
|
private[sbt] val serverLogLevel =
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,7 @@ object Defaults extends BuildCommon {
|
||||||
.getOrElse(GCUtil.defaultForceGarbageCollection),
|
.getOrElse(GCUtil.defaultForceGarbageCollection),
|
||||||
minForcegcInterval :== GCUtil.defaultMinForcegcInterval,
|
minForcegcInterval :== GCUtil.defaultMinForcegcInterval,
|
||||||
interactionService :== CommandLineUIService,
|
interactionService :== CommandLineUIService,
|
||||||
|
suppressServer := false,
|
||||||
serverHost := "127.0.0.1",
|
serverHost := "127.0.0.1",
|
||||||
serverPort := 5000 + (Hash
|
serverPort := 5000 + (Hash
|
||||||
.toHex(Hash(appConfiguration.value.baseDirectory.toString))
|
.toHex(Hash(appConfiguration.value.baseDirectory.toString))
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,7 @@ object Keys {
|
||||||
// Command keys
|
// Command keys
|
||||||
val historyPath = SettingKey(BasicKeys.historyPath)
|
val historyPath = SettingKey(BasicKeys.historyPath)
|
||||||
val shellPrompt = SettingKey(BasicKeys.shellPrompt)
|
val shellPrompt = SettingKey(BasicKeys.shellPrompt)
|
||||||
|
val suppressServer = SettingKey(BasicKeys.suppressServer)
|
||||||
val serverPort = SettingKey(BasicKeys.serverPort)
|
val serverPort = SettingKey(BasicKeys.serverPort)
|
||||||
val serverHost = SettingKey(BasicKeys.serverHost)
|
val serverHost = SettingKey(BasicKeys.serverHost)
|
||||||
val serverAuthentication = SettingKey(BasicKeys.serverAuthentication)
|
val serverAuthentication = SettingKey(BasicKeys.serverAuthentication)
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import Keys.{
|
||||||
sessionSettings,
|
sessionSettings,
|
||||||
shellPrompt,
|
shellPrompt,
|
||||||
templateResolverInfos,
|
templateResolverInfos,
|
||||||
|
suppressServer,
|
||||||
serverHost,
|
serverHost,
|
||||||
serverLog,
|
serverLog,
|
||||||
serverPort,
|
serverPort,
|
||||||
|
|
@ -462,6 +463,7 @@ object Project extends ProjectExtra {
|
||||||
val prompt = get(shellPrompt)
|
val prompt = get(shellPrompt)
|
||||||
val trs = (templateResolverInfos in Global get structure.data).toList.flatten
|
val trs = (templateResolverInfos in Global get structure.data).toList.flatten
|
||||||
val watched = get(watch)
|
val watched = get(watch)
|
||||||
|
val suppressSvr: Option[Boolean] = get(suppressServer)
|
||||||
val host: Option[String] = get(serverHost)
|
val host: Option[String] = get(serverHost)
|
||||||
val port: Option[Int] = get(serverPort)
|
val port: Option[Int] = get(serverPort)
|
||||||
val authentication: Option[Set[ServerAuthentication]] = get(serverAuthentication)
|
val authentication: Option[Set[ServerAuthentication]] = get(serverAuthentication)
|
||||||
|
|
@ -474,6 +476,7 @@ object Project extends ProjectExtra {
|
||||||
s.attributes
|
s.attributes
|
||||||
.setCond(Watched.Configuration, watched)
|
.setCond(Watched.Configuration, watched)
|
||||||
.put(historyPath.key, history)
|
.put(historyPath.key, history)
|
||||||
|
.setCond(suppressServer.key, suppressSvr)
|
||||||
.setCond(serverPort.key, port)
|
.setCond(serverPort.key, port)
|
||||||
.setCond(serverHost.key, host)
|
.setCond(serverHost.key, host)
|
||||||
.setCond(serverAuthentication.key, authentication)
|
.setCond(serverAuthentication.key, authentication)
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import java.util.concurrent.atomic._
|
||||||
import scala.collection.mutable.ListBuffer
|
import scala.collection.mutable.ListBuffer
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import BasicKeys.{
|
import BasicKeys.{
|
||||||
|
suppressServer,
|
||||||
serverHost,
|
serverHost,
|
||||||
serverPort,
|
serverPort,
|
||||||
serverAuthentication,
|
serverAuthentication,
|
||||||
|
|
@ -87,7 +88,11 @@ private[sbt] final class CommandExchange {
|
||||||
consoleChannel = Some(x)
|
consoleChannel = Some(x)
|
||||||
subscribe(x)
|
subscribe(x)
|
||||||
}
|
}
|
||||||
if (autoStartServer) runServer(s)
|
val suppress = (s get suppressServer) match {
|
||||||
|
case Some(bool) => bool
|
||||||
|
case None => false
|
||||||
|
}
|
||||||
|
if (autoStartServer && !suppress) runServer(s)
|
||||||
else s
|
else s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue