Merge pull request #6248 from adpi2/bsp-launch-jar

Add --sbt-launch-jar in bsp connection details
This commit is contained in:
eugene yokota 2021-01-16 13:00:46 -05:00 committed by GitHub
commit 4b71de0098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -18,11 +18,16 @@ object BuildServerConnection {
final val bspVersion = "2.0.0-M5"
final val languages = Vector("scala")
private final val SbtLaunchJar = "sbt-launch(-.*)?\\.jar".r
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 sbtLaunchJar = classPath
.split(File.pathSeparator)
.find(jar => SbtLaunchJar.findFirstIn(jar).nonEmpty)
val argv =
Vector(
s"$javaHome/bin/java",
@ -32,7 +37,7 @@ object BuildServerConnection {
classPath,
"xsbt.boot.Boot",
"-bsp"
)
) ++ sbtLaunchJar.map(jar => s"--sbt-launch-jar=$jar")
val details = BspConnectionDetails(name, sbtVersion, bspVersion, languages, argv)
val json = Converter.toJson(details).get
IO.write(bspConnectionFile, CompactPrinter(json), append = false)