Merge branch 'develop' into system-property-for-on-changed-build-source

This commit is contained in:
Taichi Yamakawa 2020-11-17 01:42:41 +09:00 committed by GitHub
commit 0557171930
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 18 deletions

View File

@ -15,8 +15,8 @@ import sbt.Exit
import sbt.io.syntax._
import sbt.protocol.ClientSocket
import scala.sys.process.Process
import scala.util.control.NonFatal
import java.lang.ProcessBuilder.Redirect
class BspClient private (sbtServer: Socket) {
private def run(): Exit = Exit(BspClient.bspRun(sbtServer))
@ -90,8 +90,15 @@ object BspClient {
* This instance must be shutdown explicitly via `sbt -client shutdown`
*/
def forkServer(baseDirectory: File, portfile: File): Unit = {
val args = List[String]()
val launchOpts = List("-Xms2048M", "-Xmx2048M", "-Xss2M")
val args = List("--detach-stdio")
val launchOpts = List(
"-Dfile.encoding=UTF-8",
"-Dsbt.io.virtual=true",
"-Xms1024M",
"-Xmx1024M",
"-Xss4M",
"-XX:ReservedCodeCacheSize=128m"
)
val launcherJarString = sys.props.get("java.class.path") match {
case Some(cp) =>
@ -102,10 +109,15 @@ object BspClient {
}
val cmd = "java" :: launchOpts ::: "-jar" :: launcherJarString :: args
val process = Process(cmd, baseDirectory).run()
val processBuilder =
new ProcessBuilder(cmd: _*)
.directory(baseDirectory)
.redirectInput(Redirect.PIPE)
while (process.isAlive() && !portfile.exists) Thread.sleep(100)
val process = processBuilder.start()
if (!process.isAlive()) sys.error("sbt server exited")
while (process.isAlive && !portfile.exists) Thread.sleep(100)
if (!process.isAlive) sys.error("sbt server exited")
}
}

View File

@ -16,6 +16,7 @@ import sbt.nio.Keys._
import sbt.Project._
import sbt.internal.inc.ModuleUtilities
import sbt.internal.inc.classpath.ClasspathUtil
import sbt.internal.librarymanagement.cross.CrossVersionUtil
import sbt.internal.util.complete.{ DefaultParsers, Parser }
import sbt.io._
import sbt.io.syntax._
@ -78,7 +79,7 @@ object ScriptedPlugin extends AutoPlugin {
scriptedClasspath := getJars(ScriptedConf).value,
scriptedTests := scriptedTestsTask.value,
scriptedParallelInstances := 1,
scriptedBatchExecution := true,
scriptedBatchExecution := CrossVersionUtil.binarySbtVersion(scriptedSbt.value) != "0.13",
scriptedRun := scriptedRunTask.value,
scriptedDependencies := {
def use[A](@deprecated("unused", "") x: A*): Unit = () // avoid unused warnings

View File

@ -1,5 +1 @@
lazy val root = (project in file("."))
.settings(
sbtPlugin := true,
resolvers += Resolver.typesafeIvyRepo("releases")
)
enablePlugins(SbtPlugin)

View File

@ -1,5 +1 @@
libraryDependencies += {
"org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
}
offline := true

View File

@ -1,7 +1,6 @@
# This tests that this sbt scripted plugin can launch the previous one
> ++2.10.6
> ^^0.13.16-M1
> ^^0.13.18
$ copy-file changes/A.scala src/sbt-test/a/b/A.scala
> scripted