mirror of https://github.com/sbt/sbt.git
Remove ProcessExtra and the use of java.lang.ProcessBuilder
Fixes #2736.
This commit is contained in:
parent
4765990995
commit
1f2c00cc56
|
|
@ -12,6 +12,7 @@ Migration notes
|
|||
- Removes no-longer-documented old operators `<<=`, `<+=`, and `<++=`.
|
||||
- Renames early command feature from `--<command>` to `early(<command>)`.
|
||||
- Log options `-error`, `-warn`, `-info`, `-debug` are added as shorthand for `"early(error)"` etc.
|
||||
- `sbt.Process` and `sbt.ProcessExtra` are gone. Use `scala.sys.process` instead.
|
||||
|
||||
#### Additional import required
|
||||
|
||||
|
|
|
|||
|
|
@ -46,8 +46,6 @@ case class LoggedOutput(logger: Logger) extends OutputStrategy
|
|||
*/
|
||||
case class CustomOutput(output: OutputStream) extends OutputStrategy
|
||||
|
||||
import java.lang.{ ProcessBuilder => JProcessBuilder }
|
||||
|
||||
/**
|
||||
* Represents a commad that can be forked.
|
||||
*
|
||||
|
|
@ -75,20 +73,16 @@ final class Fork(val commandName: String, val runnerClass: Option[String]) {
|
|||
val executable = Fork.javaCommand(javaHome, commandName).getAbsolutePath
|
||||
val preOptions = makeOptions(runJVMOptions, bootJars, arguments)
|
||||
val (classpathEnv, options) = Fork.fitClasspath(preOptions)
|
||||
val command = (executable +: options).toArray
|
||||
val builder = new JProcessBuilder(command: _*)
|
||||
workingDirectory.foreach(wd => builder.directory(wd))
|
||||
val environment = builder.environment
|
||||
for ((key, value) <- env)
|
||||
environment.put(key, value)
|
||||
for (cpenv <- classpathEnv)
|
||||
// overriding, not appending, is correct due to the specified priorities of -classpath and CLASSPATH
|
||||
environment.put(Fork.ClasspathEnvKey, cpenv)
|
||||
val command = executable +: options
|
||||
|
||||
val environment = env ++ classpathEnv.map(value => Fork.ClasspathEnvKey -> value)
|
||||
val process = Process(command, workingDirectory, environment.toList: _*)
|
||||
|
||||
outputStrategy.getOrElse(StdoutOutput) match {
|
||||
case StdoutOutput => Process(builder).run(connectInput)
|
||||
case BufferedOutput(logger) => logger.buffer { Process(builder).run(logger, connectInput) }
|
||||
case LoggedOutput(logger) => Process(builder).run(logger, connectInput)
|
||||
case CustomOutput(output) => (Process(builder) #> output).run(connectInput)
|
||||
case StdoutOutput => process.run(connectInput)
|
||||
case BufferedOutput(logger) => logger.buffer { process.run(logger, connectInput) }
|
||||
case LoggedOutput(logger) => process.run(logger, connectInput)
|
||||
case CustomOutput(output) => (process #> output).run(connectInput)
|
||||
}
|
||||
}
|
||||
private[this] def makeOptions(jvmOptions: Seq[String], bootJars: Iterable[File], arguments: Seq[String]): Seq[String] =
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
package sbt
|
||||
|
||||
import java.lang.{ ProcessBuilder => JProcessBuilder }
|
||||
|
||||
trait ProcessExtra {
|
||||
import scala.sys.process._
|
||||
import scala.sys.process.Process._
|
||||
implicit def builderToProcess(builder: JProcessBuilder): ProcessBuilder = apply(builder)
|
||||
implicit def fileToProcess(file: File): ProcessBuilder.FileBuilder = apply(file)
|
||||
implicit def urlToProcess(url: URL): ProcessBuilder.URLBuilder = apply(url)
|
||||
implicit def buildersToProcess[T](builders: Seq[T])(implicit convert: T => ProcessBuilder.Source): Seq[ProcessBuilder.Source] = applySeq(builders)
|
||||
|
||||
implicit def stringToProcess(command: String): ProcessBuilder = apply(command)
|
||||
implicit def stringSeqToProcess(command: Seq[String]): ProcessBuilder = apply(command)
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ import sbt.internal.util.Eval
|
|||
|
||||
object syntax extends syntax
|
||||
|
||||
abstract class syntax extends IOSyntax0 with sbt.std.TaskExtra with sbt.internal.util.Types with sbt.ProcessExtra
|
||||
abstract class syntax extends IOSyntax0 with sbt.std.TaskExtra with sbt.internal.util.Types
|
||||
with sbt.internal.librarymanagement.impl.DependencyBuilders with sbt.ProjectExtra
|
||||
with sbt.internal.librarymanagement.DependencyFilterExtra with sbt.BuildExtra with sbt.TaskMacroExtra
|
||||
with sbt.ScopeFilter.Make {
|
||||
|
|
|
|||
Loading…
Reference in New Issue