consoleOptions

This commit is contained in:
Mark Harrah 2010-04-25 13:18:36 -04:00
parent 2e9dfa02be
commit a2f96255eb
5 changed files with 15 additions and 13 deletions

View File

@ -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*)

View File

@ -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

View File

@ -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) )
}
}

View File

@ -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) }

View File

@ -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 =