SBT项目定义文件的弃用和功能警告

时间:2014-01-05 07:31:11

标签: sbt

编译我的SBT项目定义(即project目录中的文件)时,我收到弃用功能警告。 SBT版本为0.13.0。

我没有通过设置scalacOptions := Seq("-feature", "-deprecation")获得有关这些信息的更多信息,这似乎只适用于项目源文件,而不适用于项目定义文件。

任何人都知道如何在编译项目定义时为编译器设置弃用和警告?

[info] Loading project definition from /home/xxx/website/project
[warn] there were 2 deprecation warning(s); re-run with -deprecation for details
[warn] there were 4 feature warning(s); re-run with -feature for details
[warn] two warnings found

1 个答案:

答案 0 :(得分:8)

使用以下内容创建project/build.sbt项目定义文件:

scalacOptions := Seq("-feature", "-deprecation")

由于*.sbt下的任何project文件属于元(构建)项目,因此它为构建配置设置Scala编译器,而不是构建项目的环境。

使用示例sbt多项目测试:

[info] Compiling 1 Scala source to /Users/jacek/sandbox/so/multi-0.13.1/project/target/scala-2.10/sbt-0.13/classes...
[warn] /Users/jacek/sandbox/so/multi-0.13.1/project/Build.scala:4: method error in object Predef is deprecated: Use `sys.error(message)` instead
[warn]   lazy val e = error("Launcher did not provide the Ivy home directory.")
[warn]                ^
[warn] one warning found

...编译以下project/Build.scala时:

import sbt._

object Build extends Build {
  lazy val e = error("Launcher did not provide the Ivy home directory.")
}