使用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 }
。
在Scala 2.12之前没有添加-Ywarn-macros
,因此错误是预期的。
你能升级到Scala 2.12吗?如果你被困在2.11,也许你需要没有-Ywarn-unused-import
。 (由于Som Snytt的不懈努力,2.12.x系列已取得进展,未使用的警告总体上有了很大的改进。)
您可以将使用Circe的代码限制在子项目中,然后仅在该子项目中禁用未使用的警告,以便在代码库的其余部分中启用它们。
另一种可能性是尝试https://github.com/ghik/silencer。