I generate code with the scalaxb-sbt plugin that, when compiled, generates a good number of warning messages. Is there any way to hide compilation warnings for generated code or by package?
Recent versions of the Scala compiler integrate the silencer plugin, see configurable warnings.
So now you don't need any plugin, just add the following line to build.sbt
:
ThisBuild / scalacOptions += "-Wconf:src=src_managed/.*:silent"
Using this option will suppress warnings for generated code that lives under a directory called src_managed
anywhere in your source tree.
This solved my problem with code generated by zio-grpc
, where the compiler emitted warnings like parameter value evidence$3 in method live is never used
(adding this info only for better searchability).
I found that I needed to do set logLevel in Compile := Level.Error
in my sbt console session in order for this to work. This is with a capital C
in Compile
. This is with sbt version 0.13.11
. This is also to turn all warnings off, though.
The silencer compiler plugin allows to suppress compiler warnings. It supports filtering out files by path. This will filter out all generated files from warnings:
scalacOptions += "-P:silencer:pathFilters=src_managed"
In your sbt console you could try the following:
set logLevel in compile := Level.Error
or eventually set logLevel in sourceGenerators := Level.Error
and experiment with different settings. Once you are happy you could apply this setting in your build.sbt
.
More detailed information can be found in the sbt documentation: http://www.scala-sbt.org/release/docs/Howto/logging.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With