我喜歡在頂層定義scalacOptions
像這樣(作爲一個例子,忽略項目軸現在):在sbt中,如何在所有配置中覆蓋控制檯的scalacOptions?
scalacOptions += "-Ywarn-unused-import"
但後來我意識到這是過於嚴格的console
。所以我嘗試設置:
scalacOptions in console ~= (_ filterNot (_ == "-Ywarn-unused-import"))
但是,這沒有奏效(在REPL中仍然有(致命的)警告)。
我用inspect
,試圖理解爲什麼:
> inspect console
[info] Task: Unit
[info] Description:
[info] Starts the Scala interpreter with the project classes on the classpath.
[info] Provided by:
[info] {file:/a/}b/compile:console
[info] Defined at:
[info] (sbt.Defaults) Defaults.scala:261
[info] Dependencies:
[info] compile:console::compilers
[info] compile:console::initialCommands
[info] compile:console::fullClasspath
[info] compile:console::taskTemporaryDirectory
[info] compile:console::scalaInstance
[info] compile:console::streams
[info] compile:console::cleanupCommands
[info] compile:console::scalacOptions
[info] Delegates:
[info] compile:console
[info] *:console
[info] {.}/compile:console
[info] {.}/*:console
[info] */compile:console
[info] */*:console
[info] Related:
[info] test:console
注:console
是compile:console
- 取決於
compile:console::scalacOptions
則:
> inspect compile:console::scalacOptions
[info] Task: scala.collection.Seq[java.lang.String]
[info] Description:
[info] Options for the Scala compiler.
[info] Provided by:
[info] {file:/a/}b/compile:scalacOptions
[info] Defined at:
[info] (sbt.Classpaths) Defaults.scala:1593
[info] Reverse dependencies:
[info] compile:console
[info] Delegates:
[info] compile:console::scalacOptions
[info] compile:scalacOptions
[info] *:console::scalacOptions
[info] *:scalacOptions
[info] {.}/compile:console::scalacOptions
[info] {.}/compile:scalacOptions
[info] {.}/*:console::scalacOptions
[info] {.}/*:scalacOptions
[info] */compile:console::scalacOptions
[info] */compile:scalacOptions
[info] */*:console::scalacOptions
[info] */*:scalacOptions
[info] Related:
[info] *:console::scalacOptions
[info] compile:scalacOptions
[info] *:scalacOptions
[info] */*:scalacOptions
[info] test:scalacOptions
注:compile:console::scalacOptions
是compile:scalacOptions
*:console::scalacOptions
(這是我所定義的)
我的問題是怎麼做的我爲控制檯的所有配置覆蓋scalacOptions
?是否可以更改委派鏈?
我想避免必須設置scalacOptions in (Compile, console)
(因爲它將複製(Test, console)
)或定義一個scalac選項的值。
另請參閱https:// github。com/typelevel/wartremover/issues/131 – 2014-11-27 20:23:21