Scala SBT: How to “re-run with -deprecation” (or -feature)

Scala FAQ: When compiling a Scala application with SBT, I get warning messages like these:

$ sbt compile

[warn] there were 6 deprecation warnings; re-run with -deprecation for details
[warn] there were 4 feature warnings; re-run with -feature for details

How do I “re-run with -deprecation” or “re-run with -feature”?

Solution

Add a line like this to your build.sbt file to see the deprecation and feature warning messages:

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

If you just want to add one setting, you don’t need a Seq, just use this syntax:

scalacOptions += "-deprecation"

If you don’t want to modify your build.sbt file and just want this in your current SBT session, run this command from the SBT command line to get the same effect:

sbt> set scalacOptions in ThisBuild ++= Seq("-deprecation", "-feature")

More information

You can find more answers to questions like this in the Scala Cookbook.

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.