當我編譯Scala代碼,SBT說:斯卡拉SBT:如何通過運行<code>sbt compile</code> 「與-deprecation重新運行」
$ sbt compile
...
[warn] there were 5 deprecation warnings; re-run with -deprecation for details
...
我該怎麼辦呢? (?從內SBT)
當我編譯Scala代碼,SBT說:斯卡拉SBT:如何通過運行<code>sbt compile</code> 「與-deprecation重新運行」
$ sbt compile
...
[warn] there were 5 deprecation warnings; re-run with -deprecation for details
...
我該怎麼辦呢? (?從內SBT)
如果你不想改變你的build.sbt
:
$ sbt
> set scalacOptions in ThisBuild ++= Seq("-unchecked", "-deprecation")
> compile
> exit
編輯:新增"-unchecked"
和in ThisBuild
每評論。
scalacOptions := Seq("-unchecked", "-deprecation")
將此設置添加到您的build.sbt,並且如果您有多模塊項目,則將其添加到每個項目的設置。
隨着時代的流逝,出現了新的解決方案。所以,現在你可以重新運行scala編譯器而不用發出整個項目重建。
您需要安裝ensime-sbt plugin:
addSbtPlugin("org.ensime" % "sbt-ensime" % "1.0.0")
之後,你可以使用ensimeCompileOnly
任務編譯單個文件。 SBT允許每個任務設置的配置,所以你可以僅針對該任務的變化:
set scalacOptions in (Compile, EnsimeKeys.ensimeCompileOnly) += "-deprecation"
ensimeCompileOnly src/main/scala/MyFile.scala
類似的問題(包括回答你的問題)在http://stackoverflow.com/questions/9415962/how-to- see-all-the-warnings-in-sbt-0-11 – 2012-03-06 06:05:36