From a2f96255eb8e7730930c98edfcfac5659ee023a3 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Sun, 25 Apr 2010 13:18:36 -0400 Subject: [PATCH] consoleOptions --- compile/AnalyzingCompiler.scala | 4 ++-- compile/interface/ConsoleInterface.scala | 8 ++++---- sbt/src/main/scala/sbt/Compile.scala | 6 +++--- sbt/src/main/scala/sbt/DefaultProject.scala | 4 +++- sbt/src/main/scala/sbt/ScalaProject.scala | 6 +++--- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/compile/AnalyzingCompiler.scala b/compile/AnalyzingCompiler.scala index cfcccf75f..044b9be0f 100644 --- a/compile/AnalyzingCompiler.scala +++ b/compile/AnalyzingCompiler.scala @@ -24,12 +24,12 @@ class AnalyzingCompiler(val scalaInstance: ScalaInstance, val manager: Component val arguments = (new CompilerArguments(scalaInstance, autoBootClasspath, compilerOnClasspath))(sources, classpath, outputDirectory, options) call("xsbt.ScaladocInterface", log) (classOf[Array[String]], classOf[Int], classOf[xLogger]) (arguments.toArray[String] : Array[String], maximumErrors: java.lang.Integer, log) } - def console(classpath: Set[File], initialCommands: String, log: CompileLogger): Unit = + def console(classpath: Set[File], options: Seq[String], initialCommands: String, log: CompileLogger): Unit = { val arguments = new CompilerArguments(scalaInstance, autoBootClasspath, compilerOnClasspath) val classpathString = CompilerArguments.absString(arguments.finishClasspath(classpath)) val bootClasspath = if(autoBootClasspath) arguments.createBootClasspath else "" - call("xsbt.ConsoleInterface", log) (classOf[String], classOf[String], classOf[String], classOf[xLogger]) (bootClasspath, classpathString, initialCommands, log) + call("xsbt.ConsoleInterface", log) (classOf[Array[String]], classOf[String], classOf[String], classOf[String], classOf[xLogger]) (options.toArray[String]: Array[String], bootClasspath, classpathString, initialCommands, log) } def force(log: CompileLogger): Unit = getInterfaceJar(log) private def call(interfaceClassName: String, log: CompileLogger)(argTypes: Class[_]*)(args: AnyRef*) diff --git a/compile/interface/ConsoleInterface.scala b/compile/interface/ConsoleInterface.scala index ddf0d749d..e5568d3cf 100644 --- a/compile/interface/ConsoleInterface.scala +++ b/compile/interface/ConsoleInterface.scala @@ -8,9 +8,9 @@ import scala.tools.nsc.{GenericRunnerCommand,InterpreterLoop} class ConsoleInterface { - def run(bootClasspathString: String, classpathString: String, initialCommands: String, log: Logger) + def run(args: Array[String], bootClasspathString: String, classpathString: String, initialCommands: String, log: Logger) { - val settings = MakeSettings(log) + val settings = MakeSettings(args.toList, log) if(!bootClasspathString.isEmpty) settings.bootclasspath.value = bootClasspathString settings.classpath.value = classpathString @@ -28,9 +28,9 @@ class ConsoleInterface } object MakeSettings { - def apply(log: Logger) = + def apply(args: List[String], log: Logger) = { - val command = new GenericRunnerCommand(Nil, message => log.error(Message(message))) + val command = new GenericRunnerCommand(args, message => log.error(Message(message))) if(command.ok) command.settings else diff --git a/sbt/src/main/scala/sbt/Compile.scala b/sbt/src/main/scala/sbt/Compile.scala index 406d5b1e4..151852f6d 100644 --- a/sbt/src/main/scala/sbt/Compile.scala +++ b/sbt/src/main/scala/sbt/Compile.scala @@ -134,10 +134,10 @@ final class Console(compiler: AnalyzingCompiler) extends NotNull { /** Starts an interactive scala interpreter session with the given classpath.*/ def apply(classpath: Iterable[Path], log: Logger): Option[String] = - apply(classpath, "", log) - def apply(classpath: Iterable[Path], initialCommands: String, log: Logger): Option[String] = + apply(classpath, Nil, "", log) + def apply(classpath: Iterable[Path], options: Seq[String], initialCommands: String, log: Logger): Option[String] = { - def console0 = compiler.console(Path.getFiles(classpath), initialCommands, log) + def console0 = compiler.console(Path.getFiles(classpath), options, initialCommands, log) JLine.withJLine( Run.executeTrapExit(console0, log) ) } } diff --git a/sbt/src/main/scala/sbt/DefaultProject.scala b/sbt/src/main/scala/sbt/DefaultProject.scala index e92548a80..cbe31f3bc 100644 --- a/sbt/src/main/scala/sbt/DefaultProject.scala +++ b/sbt/src/main/scala/sbt/DefaultProject.scala @@ -67,6 +67,8 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec /** The options provided to the 'compile' action to pass to the Scala compiler.*/ def compileOptions: Seq[CompileOption] = Deprecation :: Nil + /** The options provided to the 'console' action to pass to the Scala interpreter.*/ + def consoleOptions: Seq[CompileOption] = compileOptions /** The options provided to the 'compile' action to pass to the Java compiler. */ def javaCompileOptions: Seq[JavaCompileOption] = Nil /** The options provided to the 'test-compile' action, defaulting to those for the 'compile' action.*/ @@ -264,7 +266,7 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec } } - def basicConsoleTask = consoleTask(consoleClasspath, consoleInit) + def basicConsoleTask = consoleTask(consoleClasspath, consoleOptions, consoleInit) protected def runTask(mainClass: String): MethodTask = task { args => runTask(Some(mainClass), runClasspath, args) dependsOn(compile, copyResources) } diff --git a/sbt/src/main/scala/sbt/ScalaProject.scala b/sbt/src/main/scala/sbt/ScalaProject.scala index 8f7238b4b..bbabf3b96 100644 --- a/sbt/src/main/scala/sbt/ScalaProject.scala +++ b/sbt/src/main/scala/sbt/ScalaProject.scala @@ -138,10 +138,10 @@ trait ScalaProject extends SimpleScalaProject with FileTasks with MultiTaskProje classes.map(_.replace(java.io.File.separatorChar, '.').toList.dropRight(".class".length).mkString).toSeq } - def consoleTask(classpath: PathFinder): Task = consoleTask(classpath, "") - def consoleTask(classpath: PathFinder, initialCommands: => String): Task = + def consoleTask(classpath: PathFinder): Task = consoleTask(classpath, Nil, "") + def consoleTask(classpath: PathFinder, options: => Seq[CompileOption], initialCommands: => String): Task = interactiveTask { - (new Console(buildCompiler))(classpath.get, initialCommands, log) + (new Console(buildCompiler))(classpath.get, options.map(_.asString), initialCommands, log) } def runTask(mainClass: => Option[String], classpath: PathFinder, options: String*)(implicit runner: ScalaRun): Task =