Add support for JNI implementation of ClientSocket

The JNI implementation is needed in order for a graalvm native-image to
be build of the NetworkClient.
This commit is contained in:
Ethan Atkins 2020-06-22 11:38:48 -07:00
parent af5afef271
commit 41d66abb02
2 changed files with 9 additions and 7 deletions

View File

@ -25,7 +25,7 @@ object Dependencies {
val launcherInterface = "org.scala-sbt" % "launcher-interface" % launcherVersion
val rawLauncher = "org.scala-sbt" % "launcher" % launcherVersion
val testInterface = "org.scala-sbt" % "test-interface" % "1.0"
val ipcSocket = "org.scala-sbt.ipcsocket" % "ipcsocket" % "1.0.1"
val ipcSocket = "org.scala-sbt.ipcsocket" % "ipcsocket" % "1.1.0"
private val compilerInterface = "org.scala-sbt" % "compiler-interface" % zincVersion
private val compilerClasspath = "org.scala-sbt" %% "zinc-classpath" % zincVersion

View File

@ -21,9 +21,10 @@ import org.scalasbt.ipcsocket._
object ClientSocket {
private lazy val fileFormats = new BasicJsonProtocol with PortFileFormats with TokenFileFormats {}
def socket(portfile: File): (Socket, Option[String]) = {
def socket(portfile: File): (Socket, Option[String]) = socket(portfile, false)
def socket(portfile: File, useJNI: Boolean): (Socket, Option[String]) = {
import fileFormats._
val json: JValue = Parser.parseFromFile(portfile).get
val json: JValue = Parser.parseFromString(sbt.io.IO.read(portfile)).get
val p = Converter.fromJson[PortFile](json).get
val uri = new URI(p.uri)
// println(uri)
@ -35,10 +36,11 @@ object ClientSocket {
}
val sk = uri.getScheme match {
case "local" if isWindows =>
(new Win32NamedPipeSocket("""\\.\pipe\""" + uri.getSchemeSpecificPart): Socket)
case "local" => (new UnixDomainSocket(uri.getSchemeSpecificPart): Socket)
case "tcp" => new Socket(InetAddress.getByName(uri.getHost), uri.getPort)
case _ => sys.error(s"Unsupported uri: $uri")
(new Win32NamedPipeSocket("""\\.\pipe\""" + uri.getSchemeSpecificPart, useJNI): Socket)
case "local" =>
(new UnixDomainSocket(uri.getSchemeSpecificPart, useJNI): Socket)
case "tcp" => new Socket(InetAddress.getByName(uri.getHost), uri.getPort)
case _ => sys.error(s"Unsupported uri: $uri")
}
(sk, token)
}