sbt

How to "re-run with -deprecation for details" in sbt?


When I compile Scala code, by running sbt compile, SBT says:

$ sbt compile
...
[warn] there were 5 deprecation warnings; re-run with -deprecation for details
...

How do I do that? (From within SBT?)


Solution

  • sbt shell

    While in sbt shell (if you don't want to change your build.sbt):

    $ sbt
    > set ThisBuild/scalacOptions ++= Seq("-unchecked", "-deprecation")
    > compile
    > exit
    

    Due to in ThisBuild, set applies the settings to all sub-projects, as well.

    Command Line

    You could also run the above as a single command on command line.

    sbt '; set ThisBuild/scalacOptions ++= Seq("-unchecked", "-deprecation") ; compile' 
    

    The trick is to use ; (semicolons) to separate commands and ' (ticks) to include all ;-separated commands as a single argument to sbt.

    sbt < 1.x

    Instead of ThisBuild/scalacOptions use scalacOptions in ThisBuild