diff --git a/build.sbt b/build.sbt index a25c4adc0..9d8b039c7 100644 --- a/build.sbt +++ b/build.sbt @@ -176,6 +176,7 @@ lazy val actionsProj = (project in file("main-actions")). // General command support and core commands not specific to a build system lazy val commandProj = (project in file("main-command")). + dependsOn(serverProj). settings( testedBaseSettings, name := "Command", diff --git a/main-command/src/main/scala/sbt/BasicCommands.scala b/main-command/src/main/scala/sbt/BasicCommands.scala index 68503fda4..937de57bb 100644 --- a/main-command/src/main/scala/sbt/BasicCommands.scala +++ b/main-command/src/main/scala/sbt/BasicCommands.scala @@ -13,6 +13,7 @@ import BasicCommandStrings._ import CommandUtil._ import BasicKeys._ +import sbt.server.Server import java.io.File import sbt.io.IO @@ -179,6 +180,9 @@ object BasicCommands { } def shell = Command.command(Shell, Help.more(Shell, ShellDetailed)) { s => + // TODO hook it in, start in the right place, shutdown on termination + val server = Server.start("127.0.0.1", 12700) + val history = (s get historyPath) getOrElse Some(new File(s.baseDir, ".history")) val prompt = (s get shellPrompt) match { case Some(pf) => pf(s); case None => "> " } val reader = new FullReader(history, s.combinedParser) diff --git a/main/server/src/main/scala/sbt/server/Server.scala b/main/server/src/main/scala/sbt/server/Server.scala index 15a99f3a1..0d8b46941 100644 --- a/main/server/src/main/scala/sbt/server/Server.scala +++ b/main/server/src/main/scala/sbt/server/Server.scala @@ -7,12 +7,12 @@ import java.net.{ SocketTimeoutException, InetAddress, ServerSocket } import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.atomic.AtomicBoolean +sealed trait ServerInstance { + def shutdown(): Unit + def nextCommand(): Option[Command] +} + object Server { - - trait ServerInstance { - def shutdown(): Unit - } - def start(host: String, port: Int): ServerInstance = new ServerInstance { diff --git a/main/src/main/scala/sbt/Main.scala b/main/src/main/scala/sbt/Main.scala index 5945e222b..279da153a 100644 --- a/main/src/main/scala/sbt/Main.scala +++ b/main/src/main/scala/sbt/Main.scala @@ -84,9 +84,6 @@ object StandardMain { /** The common interface to standard output, used for all built-in ConsoleLoggers. */ val console = ConsoleOut.systemOutOverwrite(ConsoleOut.overwriteContaining("Resolving ")) - // TODO hook it in, start in the right place, shutdown on termination - val server = sbt.server.Server.start("127.0.0.1", 12700) - def initialGlobalLogging: GlobalLogging = GlobalLogging.initial(MainLogging.globalDefault(console), File.createTempFile("sbt", ".log"), console) def initialState(configuration: xsbti.AppConfiguration, initialDefinitions: Seq[Command], preCommands: Seq[String]): State =