mirror of https://github.com/sbt/sbt.git
Merge pull request #3970 from retronym/ticket/3737
Use Java's redirectInput rather than sys.process's connectInput
This commit is contained in:
commit
27bbde810d
|
|
@ -8,10 +8,14 @@
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.lang.ProcessBuilder.Redirect
|
||||||
|
|
||||||
import scala.sys.process.Process
|
import scala.sys.process.Process
|
||||||
import OutputStrategy._
|
import OutputStrategy._
|
||||||
import sbt.internal.util.Util
|
import sbt.internal.util.Util
|
||||||
|
|
||||||
|
import java.lang.{ ProcessBuilder => JProcessBuilder }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a command that can be forked.
|
* Represents a command that can be forked.
|
||||||
*
|
*
|
||||||
|
|
@ -45,13 +49,19 @@ final class Fork(val commandName: String, val runnerClass: Option[String]) {
|
||||||
(classpathEnv map { value =>
|
(classpathEnv map { value =>
|
||||||
Fork.ClasspathEnvKey -> value
|
Fork.ClasspathEnvKey -> value
|
||||||
})
|
})
|
||||||
val process = Process(command, workingDirectory, environment.toList: _*)
|
val jpb = new JProcessBuilder(command.toArray: _*)
|
||||||
|
workingDirectory foreach (jpb directory _)
|
||||||
|
environment foreach { case (k, v) => jpb.environment.put(k, v) }
|
||||||
|
if (connectInput)
|
||||||
|
jpb.redirectInput(Redirect.INHERIT)
|
||||||
|
val process = Process(jpb)
|
||||||
|
|
||||||
outputStrategy.getOrElse(StdoutOutput) match {
|
outputStrategy.getOrElse(StdoutOutput) match {
|
||||||
case StdoutOutput => process.run(connectInput)
|
case StdoutOutput => process.run(connectInput = false)
|
||||||
case out: BufferedOutput => out.logger.buffer { process.run(out.logger, connectInput) }
|
case out: BufferedOutput =>
|
||||||
case out: LoggedOutput => process.run(out.logger, connectInput)
|
out.logger.buffer { process.run(out.logger, connectInput = false) }
|
||||||
case out: CustomOutput => (process #> out.output).run(connectInput)
|
case out: LoggedOutput => process.run(out.logger, connectInput = false)
|
||||||
|
case out: CustomOutput => (process #> out.output).run(connectInput = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private[this] def makeOptions(jvmOptions: Seq[String],
|
private[this] def makeOptions(jvmOptions: Seq[String],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue