在编译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.
通过大量的血汗,我能够找到弃用警告的原因,但我无法找到功能警告的原因。
答案 0 :(得分:7)
Sbt is recursive,表示Build.scala
目录中的project
由其父目录中的另一个定义或build.sbt
目录中的project
构建。
因此,您必须在build.sbt
目录中创建project
。在project/build.sbt
中,您应该可以设置scalacOptions ++= Seq("-unchecked", "-feature")
。