mirror of https://github.com/sbt/sbt.git
Add bspConfig task
This commit is contained in:
parent
31dc975ec7
commit
97b0347c15
|
|
@ -97,7 +97,10 @@ private[sbt] object Server {
|
|||
}
|
||||
log.info(s"sbt server started at ${connection.shortName}")
|
||||
writePortfile()
|
||||
writeBspConnectionDetails()
|
||||
BuildServerConnection.writeConnectionFile(
|
||||
appConfiguration.provider.id.version,
|
||||
appConfiguration.baseDirectory
|
||||
)
|
||||
running.set(true)
|
||||
p.success(())
|
||||
while (running.get()) {
|
||||
|
|
@ -215,14 +218,6 @@ private[sbt] object Server {
|
|||
IO.write(portfile, CompactPrinter(json))
|
||||
}
|
||||
|
||||
private[this] def writeBspConnectionDetails(): Unit = {
|
||||
import bsp.codec.JsonProtocol._
|
||||
val sbtVersion = appConfiguration.provider.id.version
|
||||
val details = BuildServerConnection.details(sbtVersion)
|
||||
val json = Converter.toJson(details).get
|
||||
IO.write(bspConnectionFile, CompactPrinter(json), append = false)
|
||||
}
|
||||
|
||||
private[sbt] def prepareSocketfile(): Unit = {
|
||||
if (socketfile.exists) {
|
||||
IO.delete(socketfile)
|
||||
|
|
@ -241,7 +236,6 @@ private[sbt] case class ServerConnection(
|
|||
tokenfile: File,
|
||||
socketfile: File,
|
||||
pipeName: String,
|
||||
bspConnectionFile: File,
|
||||
appConfiguration: AppConfiguration,
|
||||
windowsServerSecurityLevel: Int
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -385,6 +385,7 @@ object Keys {
|
|||
val usePipelining = settingKey[Boolean]("Use subproject pipelining for compilation.").withRank(BSetting)
|
||||
val exportPipelining = settingKey[Boolean]("Product early output so downstream subprojects can do pipelining.").withRank(BSetting)
|
||||
|
||||
val bspConfig = taskKey[Unit]("Create or update the BSP connection files").withRank(DSetting)
|
||||
val bspTargetIdentifier = settingKey[BuildTargetIdentifier]("Id for BSP build target.").withRank(DSetting)
|
||||
val bspWorkspace = settingKey[Map[BuildTargetIdentifier, Scope]]("Mapping of BSP build targets to sbt scopes").withRank(DSetting)
|
||||
val bspInternalDependencyConfigurations = settingKey[Seq[(ProjectRef, Set[ConfigKey])]]("The project configurations that this configuration depends on, possibly transitivly").withRank(DSetting)
|
||||
|
|
|
|||
|
|
@ -28,9 +28,10 @@ import sbt.internal.util._
|
|||
import sbt.io.syntax._
|
||||
import sbt.io.{ Hash, IO }
|
||||
import sbt.nio.Watch.NullLogger
|
||||
import sbt.protocol.Serialization.attach
|
||||
import sbt.protocol.{ ExecStatusEvent, LogEvent }
|
||||
import sbt.util.Logger
|
||||
import sbt.protocol.Serialization.attach
|
||||
import sjsonnew.JsonFormat
|
||||
|
||||
import scala.annotation.tailrec
|
||||
import scala.collection.mutable.ListBuffer
|
||||
|
|
@ -38,8 +39,6 @@ import scala.concurrent.Await
|
|||
import scala.concurrent.duration._
|
||||
import scala.util.{ Failure, Success, Try }
|
||||
|
||||
import sjsonnew.JsonFormat
|
||||
|
||||
/**
|
||||
* The command exchange merges multiple command channels (e.g. network and console),
|
||||
* and acts as the central multiplexing point.
|
||||
|
|
@ -214,7 +213,6 @@ private[sbt] final class CommandExchange {
|
|||
val tokenfile = serverDir / h / "token.json"
|
||||
val socketfile = serverDir / h / "sock"
|
||||
val pipeName = "sbt-server-" + h
|
||||
val bspConnectionFile = s.baseDir / ".bsp" / "sbt.json"
|
||||
val connection = ServerConnection(
|
||||
connectionType,
|
||||
host,
|
||||
|
|
@ -224,7 +222,6 @@ private[sbt] final class CommandExchange {
|
|||
tokenfile,
|
||||
socketfile,
|
||||
pipeName,
|
||||
bspConnectionFile,
|
||||
s.configuration,
|
||||
win32Level,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@ object BuildServerProtocol {
|
|||
)
|
||||
|
||||
lazy val globalSettings: Seq[Def.Setting[_]] = Seq(
|
||||
bspConfig := BuildServerConnection.writeConnectionFile(
|
||||
sbtVersion.value,
|
||||
(ThisBuild / baseDirectory).value
|
||||
),
|
||||
bspWorkspace := bspWorkspaceSetting.value,
|
||||
bspWorkspaceBuildTargets := Def.taskDyn {
|
||||
val workspace = Keys.bspWorkspace.value
|
||||
|
|
|
|||
|
|
@ -7,12 +7,20 @@
|
|||
|
||||
package sbt.internal.bsp
|
||||
|
||||
import java.io.File
|
||||
|
||||
import sbt.internal.bsp
|
||||
import sbt.io.IO
|
||||
import sjsonnew.support.scalajson.unsafe.{ CompactPrinter, Converter }
|
||||
|
||||
object BuildServerConnection {
|
||||
final val name = "sbt"
|
||||
final val bspVersion = "2.0.0-M5"
|
||||
final val languages = Vector("scala")
|
||||
|
||||
private[sbt] def details(sbtVersion: String): BspConnectionDetails = {
|
||||
private[sbt] def writeConnectionFile(sbtVersion: String, baseDir: File): Unit = {
|
||||
import bsp.codec.JsonProtocol._
|
||||
val bspConnectionFile = new File(baseDir, ".bsp/sbt.json")
|
||||
val javaHome = System.getProperty("java.home")
|
||||
val classPath = System.getProperty("java.class.path")
|
||||
val argv =
|
||||
|
|
@ -25,6 +33,8 @@ object BuildServerConnection {
|
|||
"xsbt.boot.Boot",
|
||||
"-bsp"
|
||||
)
|
||||
BspConnectionDetails(name, sbtVersion, bspVersion, languages, argv)
|
||||
val details = BspConnectionDetails(name, sbtVersion, bspVersion, languages, argv)
|
||||
val json = Converter.toJson(details).get
|
||||
IO.write(bspConnectionFile, CompactPrinter(json), append = false)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue