gpt4 book ai didi

scala - 如何让 sbt `console` 使用 -Yrepl-sync?

转载 作者:行者123 更新时间:2023-12-03 23:28:49 25 4
gpt4 key购买 nike

Scala 2.9.1 中的新功能是 -Yrepl-sync 选项,它可以防止每个 REPL 行在新线程中运行:

scala -Yrepl-sync

当我跑 console来自 sbt,我如何让它传入?

最佳答案

简短的回答:

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

关于scala - 如何让 sbt `console` 使用 -Yrepl-sync?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7615318/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com