How to make SBT not reporting compilation warnings for generated code?

For Scala 2.12.13+ or 2.13.2+

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).


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"

Tags:

Scala

Sbt