如何在编译Build.scala时设置SBT使用的scalacOptions?

drs*_*ens 8 scala sbt

scalacOptions在编译时试图弄清楚SBT 如何设置/追加使用时遇到了一些麻烦Build.scala.我团队中的某个人从Akka中复制了一些代码,Build.scala结果是一堆弃用的警告和一个功能警告.

$ reload
[info] Loading global plugins from /Users/xxx/.sbt/0.13/plugins
[info] Loading project definition from /Users/xxx/yyy/zzz/project
[info] Compiling 1 Scala source to /Users/xxx/yyy/zzz/project/target/scala-2.10/sbt-0.13/classes...
[warn] there were 3 deprecation warning(s); re-run with -deprecation for details
[warn] there were 1 feature warning(s); re-run with -feature for details
[warn] two warnings found
Run Code Online (Sandbox Code Playgroud)

我尝试过的事情

  1. 添加scalacOptions ++= Seq("-unchecked", "-feature")build.sbt.我希望在Build.scala编译之前加载它.
  2. 已经有scalacOptions ++= Seq(...., "-unchecked", "-feature")Build.scala
  3. 试图设置scalacOptions之前reload,但它似乎被丢弃

    $ ;set scalacOptions ++= Seq("-feature", "-deprecated") ;reload
    [info] Defining zzz/*:scalacOptions
    [info] The new value will be used by zzz/compile:scalacOptions
    [info] Reapplying settings...
    [info] Set current project to zzz (in build file:/Users/xxx/yyy/zzz/)
    [info] Loading global plugins from /Users/xxx/.sbt/0.13/plugins
    [info] Loading project definition from /Users/xxx/yyy/zzz/project
    [info] Compiling 1 Scala source to /Users/xxx/yyy/zzz/project/target/scala-2.10/sbt-0.13/classes...
    [warn] there were 3 deprecation warning(s); re-run with -deprecation for details
    [warn] there were 1 feature warning(s); re-run with -feature for details
    [warn] two warnings found
    [warn] Discarding 1 session setting.  Use 'session save' to persist session settings.
    
    Run Code Online (Sandbox Code Playgroud)

通过大量的血汗,我能够找到被弃用的警告的原因,但我找不到功能警告的原因.

lpi*_*ora 7

SBT是递归的,这意味着Build.scalaproject目录是由在它的父目录或另一个定义建立build.sbtproject目录中.

因此,您必须build.sbtproject目录中创建.在project/build.sbt你应该能够设置scalacOptions ++= Seq("-unchecked", "-feature").