我在试图弄清楚如何设置/附加到 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
我尝试过的事情
scalacOptions ++= Seq("-unchecked", "-feature")
至 build.sbt
.我希望它会在 Build.scala
之前加载被编译。 scalacOptions ++= Seq(...., "-unchecked", "-feature")
在 Build.scala
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.
通过大量的汗水,我能够找到已弃用警告的原因,但我找不到功能警告的原因。
最佳答案
Sbt is recursive ,这意味着 Build.scala
在 project
目录由其父目录或 build.sbt
中的另一个定义构建在 project
目录。
因此你必须创建 build.sbt
在 project
目录。在 project/build.sbt
你应该可以设置 scalacOptions ++= Seq("-unchecked", "-feature")
.
关于scala - 编译Build.scala时如何设置SBT使用的scalacOptions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24289776/