scala - sbt 编译失败,选项错误:'-Ywarn-macros:after'
问题描述
使用 build.sbt 文件,例如:
ThisBuild / organization := "com.company"
ThisBuild / version := "1.0.0-SNAPSHOT"
ThisBuild / scalaVersion := "2.11.12"
Global / concurrentRestrictions += Tags.limit(Tags.Test, 1)
Global / scalacOptions ++= Seq("-Ypartial-unification",
"-unchecked",
"-Xfatal-warnings",
"-Ywarn-dead-code",
"-Ywarn-inaccessible",
"-Ywarn-unused",
"-Ywarn-unused-import",
"-Ywarn-macros:after")
我[error] bad option: '-Ywarn-macros:none'
跑步后得到sbt clean compile
如果没有-Ywarn-macros:after
,未使用的导入警告会在使用 Circe 宏的文件中引发虚假警告,例如:import io.circe.{ Decoder, Encoder }
.
解决方案
-Ywarn-macros
直到 Scala 2.12 才添加,因此该错误是意料之中的。
你能升级到 Scala 2.12 吗?如果你被困在 2.11 上,也许你需要在没有-Ywarn-unused-import
. (由于 Som Snytt 的不懈努力,随着 2.12.x 系列的进展,未使用的警告总体上得到了极大的改进。)
您可以将使用 Circe 的代码限制在子项目中,然后仅在该子项目中禁用未使用的警告,以便在代码库的其余部分中启用它们。
另一种可能性是尝试https://github.com/ghik/silencer。
推荐阅读
- java - 如何将第二个值连接到 For 循环下的字符串变量
- php - 如何在 php 中将 .DDF 文件转换为 tiff
- angular - 如何使用Angular 6进行数据绑定onclick按钮
- entity-framework - 带有 2 个孩子的 Microsoft Entity Framework Core 父级
- python - 为什么这个 subprocess.check_output 行会使我的脚本崩溃?
- c# - 按顺序验证
- express - 将不记名令牌从仅服务器 cookie 安全地传递到标头
- azure - 使用本地缓存功能时如何清除 Azure Web 应用上的诊断日志?
- java - 如何创建与卡片滑动动画平行的 Android 按钮动画
- ios - INSearchForNotebookItemsIntentResponse 与单个任务列表