【问题标题】:Deprecation and feature warnings for SBT project definition filesSBT 项目定义文件的弃用和功能警告
【发布时间】:2014-01-22 18:00:15
【问题描述】:

在编译我的 SBT 项目定义(即project 目录中的文件)时,我收到deprecationfeature 警告。 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

【问题讨论】:

    标签: sbt


    【解决方案1】:

    创建project/build.sbt项目定义文件,内容如下:

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

    由于project 下的任何*.sbt 文件都属于元(构建)项目,它为构建配置设置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.")
    }
    

    【讨论】:

      猜你喜欢
      • 2019-02-12
      • 2022-09-28
      • 1970-01-01
      • 2018-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-04
      相关资源
      最近更新 更多