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?)
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?)
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.
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.
Instead of ThisBuild/scalacOptions
use scalacOptions in ThisBuild
in Global
instead of in ThisBuild
also works equally well with subprojects—but why is the latter preferred? or is it even? –
Melva scalacOptions := Seq("-unchecked", "-deprecation")
Add this setting to your build.sbt, and, if you have a multi-module project, add it to every project's settings.
As times flows new solutions are emerged. So, now you could re-run the scala compiler without issuing entire project rebuild.
You need to install ensime-sbt plugin:
addSbtPlugin("org.ensime" % "sbt-ensime" % "1.0.0")
After that you could use the ensimeCompileOnly
task to compile single file. SBT allows per tasks settings configuration, so you could change for that tasks only:
set scalacOptions in (Compile, EnsimeKeys.ensimeCompileOnly) += "-deprecation"
ensimeCompileOnly src/main/scala/MyFile.scala
-deprecation
is a terrible idea. Ensime is for supporting on-the-fly annotation in editors. Besides which, Ensime itself has a host of problems with some kinds of projects (most notably those that use macros heavily). –
Sherer © 2022 - 2024 — McMap. All rights reserved.