如何使 SBT 不报告生成代码的编译警告? [英] How to make SBT not reporting compilation warnings for generated code?

查看:22
本文介绍了如何使 SBT 不报告生成代码的编译警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 scalaxb-sbt 插件生成代码,该插件在编译时会生成大量警告消息.有没有办法隐藏生成代码或包的编译警告?

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?

推荐答案

适用于 Scala 2.12.13+ 或 2.13.2+

Scala 编译器的最新版本集成了消音器插件,请参阅 可配置的警告.
所以现在你不需要任何插件,只需将以下行添加到 build.sbt:

ThisBuild / scalacOptions += "-Wconf:src=src_managed/.*:silent"

使用此选项将禁止对位于源代码树中任何位置名为 src_managed 的目录下的生成代码发出警告.

Using this option will suppress warnings for generated code that lives under a directory called src_managed anywhere in your source tree.

这解决了我由 zio-grpc 生成的代码的问题,其中编译器发出警告,如 parameter value evidence$3 in method live is never used(仅添加此信息以便更好地搜索).

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

这篇关于如何使 SBT 不报告生成代码的编译警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆