Подтвердить что ты не робот

Как заставить sbt `console` использовать -Yrepl-sync?

Новое в Scala 2.9.1 - это опция -Yrepl-sync, которая предотвращает запуск каждой строки REPL в новом потоке:

scala -Yrepl-sync

Когда я запускаю console из sbt, как мне передать это?

4b9b3361

Ответ 1

Короткий ответ:

set scalacOptions in (Compile, console) += "-Yrepl-sync"

Как это обнаружить:

~/code/scratch/20110930 sbt
[info] Loading global plugins from /Users/jason/.sbt11/plugins
[info] Set current project to default-9c7c16 (in build file:/Users/jason/code/scratch/20110930/)
> inspect console
[info] Task: Unit
[info] Description:
[info]  Starts the Scala interpreter with the project classes on the classpath.
[info] Provided by:
[info]  {file:/Users/jason/code/scratch/20110930/}default-9c7c16/compile:console
[info] Dependencies:
[info]  compile:compilers(for console)
[info]  compile:full-classpath
[info]  compile:scalac-options(for console)
[info]  compile:initial-commands(for console)
[info]  compile:streams(for console)
[info] Delegates:
[info]  compile:console
[info]  *:console
[info]  {.}/compile:console
[info]  {.}/*:console
[info]  */compile:console
[info]  */*:console
[info] Related:
[info]  test:console
> set scalaVersion := "2.9.1"          
[info] Reapplying settings...
[info] Set current project to default-9c7c16 (in build file:/Users/jason/code/scratch/20110930/)
> set scalacOptions in (Compile, console) += "-Yrepl-sync"
[info] Reapplying settings...
[info] Set current project to default-9c7c16 (in build file:/Users/jason/code/scratch/20110930/)
> console
[info] Updating {file:/Users/jason/code/scratch/20110930/}default-9c7c16...
[info] Done updating.
[info] Starting scala interpreter...
[info] 
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :power
** Power User mode enabled - BEEP BOOP SPIZ **
** :phase has been set to 'typer'.          **
** scala.tools.nsc._ has been imported      **
** global._ and definitions._ also imported **
** Try  :help,  vals.<tab>,  power.<tab>    **

scala> settings
res1: scala.tools.nsc.Settings = 
Settings {
  -classpath = /Users/jason/code/scratch/20110930/target/scala-2.9.1/classes:/Users/jason/.sbt11/boot/scala-2.9.1/lib/scala-compiler.jar:/Users/jason/.sbt11/boot/scala-2.9.1/lib/jansi.jar:/Users/jason/.sbt11/boot/scala-2.9.1/lib/jline.jar
  -d = .
  -Yrepl-sync = true
  -encoding = UTF-8
  -bootclasspath = /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsfd.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Resources/Java/JavaRuntimeSupport.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/ui.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/laf.jar:/System/Librar...