WartRemover is a scalac plugin. Typically it is configured via an sbt plugin.
I'd like to be able to run WartRemover on my sbt project as a separate configuration or task without affecting the usual run of compile.
After adding Wartremover to my plugins.sbt I tried quite a few variations on the following.
lazy val Lint = config("lint").extend(Compile)
project("foo").
configs(Lint)
settings(inConfig(Lint)(Defaults.compileSettings): _*).
settings(inConfig(Linting)(wartremover.wartremoverSettings):_*).
settings(inConfig(Linting)(wartremover.wartremoverErrors := wartremover.Warts.all))
Afterward scalacOptions contained roughly what I expected inside my new lint configuration and in the compile configuration. However, when I ran lint:compile and compile with sbt in debug mode so I could see the command line arguments to scalac, either both or neither commands would result in pass the -P:wartremover:... switches. That was surprising because only lint:scalacOptions showed the -P:wartremover:... switches.
How can I create a separate sbt Configuration or Task to compile with WartRemover without affecting compile:compile?
I think you came really close. Here are some of the details:
Compileconfiguration'supdatetask, which useslibraryDependenciessetting.addCompilerPluginis a shorthand forlibraryDependencieswithCompilerPluginconfiguration.scalaOptionson the configuration that you're interested in.sourcesfromCompileto use them inLint.If you see the implementation of
wartremoverSettingsit's doing bothaddCompilerPluginandscalacOptions. You have two options to disable wartremover onCompile:wartremoverSettings, then manually remove wartremover compiler plugin fromCompile.libraryDependencies.Here's the first option.
project/build.properties
project/wart.sbt
build.sbt
foo/src/main/scala/Foo.scala
sample output