Forked run should use unbuffered logger by default

git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@977 d89573ee-9141-11dd-94d4-bdf5e562f29c
This commit is contained in:
dmharrah 2009-08-31 16:52:31 +00:00
parent c19276d7bd
commit 42489b04a1
2 changed files with 10 additions and 8 deletions

View File

@ -28,6 +28,7 @@ trait ForkScalaCompiler extends ForkScala
sealed abstract class OutputStrategy extends NotNull
case object StdoutOutput extends OutputStrategy
case class BufferedOutput(logger: Logger) extends OutputStrategy
case class LoggedOutput(logger: Logger) extends OutputStrategy
case class CustomOutput(output: OutputStream) extends OutputStrategy
import java.lang.{ProcessBuilder => JProcessBuilder}
@ -35,18 +36,18 @@ object Fork
{
private val ScalacMainClass = "scala.tools.nsc.Main"
private val ScalaMainClass = "scala.tools.nsc.MainGenericRunner"
val java = new ForkJava("java")
val javac = new ForkJava("javac")
val scala = new ForkScala(ScalaMainClass)
val scalac = new ForkScala(ScalacMainClass)
private def javaCommand(javaHome: Option[File], name: String): File =
{
val home = javaHome.getOrElse(new File(System.getProperty("java.home")))
new File(new File(home, "bin"), name)
}
final class ForkJava(commandName: String) extends NotNull
{
def apply(javaHome: Option[File], options: Seq[String], log: Logger): Int =
@ -63,11 +64,12 @@ object Fork
outputStrategy match {
case StdoutOutput => Process(builder) !
case BufferedOutput(logger) => Process(builder) ! logger
case LoggedOutput(logger) => Process(builder).run(logger).exitValue()
case CustomOutput(output) => (Process(builder) #> output).run.exitValue()
}
}
}
final class ForkScala(mainClassName: String) extends NotNull
{
def apply(javaHome: Option[File], jvmOptions: Seq[String], scalaJars: Iterable[File], arguments: Seq[String], log: Logger): Int =

View File

@ -29,7 +29,7 @@ class ForkRun(config: ForkScalaRun) extends ScalaRun
val scalaOptions = classpathOption(classpath) ::: mainClass :: options.toList
val exitCode = config.outputStrategy match {
case Some(strategy) => Fork.scala(config.javaHome, config.runJVMOptions, config.scalaJars, scalaOptions, config.workingDirectory, strategy)
case None => Fork.scala(config.javaHome, config.runJVMOptions, config.scalaJars, scalaOptions, config.workingDirectory, log)
case None => Fork.scala(config.javaHome, config.runJVMOptions, config.scalaJars, scalaOptions, config.workingDirectory, LoggedOutput(log))
}
processExitCode(exitCode, "runner")
}
@ -117,7 +117,7 @@ object Run extends ScalaRun
else
Some(command.usageMsg)
}
/** Starts a Scala interpreter session with 'project' bound to the value 'current' in the console
* and the following two lines executed:
* import sbt._
@ -139,7 +139,7 @@ object Run extends ScalaRun
}
}}
}
/** A custom InterpreterLoop with the purpose of creating an interpreter with Project 'project' bound to the value 'current',
/** A custom InterpreterLoop with the purpose of creating an interpreter with Project 'project' bound to the value 'current',
* and the following two lines interpreted:
* import sbt._
* import current._.
@ -156,7 +156,7 @@ object Run extends ScalaRun
val loader = project.getClass.getClassLoader.asInstanceOf[URLClassLoader]
compilerSettings.classpath.value = loader.getURLs.flatMap(ClasspathUtilities.asFile).map(_.getAbsolutePath).mkString(File.pathSeparator)
project.log.debug(" Compiler classpath: " + compilerSettings.classpath.value)
in = InteractiveReader.createDefault()
interpreter = new Interpreter(settings)
{