From 972e1a7f9a674517c914c7fae166b9a41efd8f83 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Mon, 10 Feb 2020 19:51:35 +0000 Subject: [PATCH] Make signature problems opt-in Set `ThisBuild / mimaReportSignatureProblems := true` to opt-in. --- .../com/typesafe/tools/mima/plugin/MimaKeys.scala | 11 ++++++----- .../com/typesafe/tools/mima/plugin/MimaPlugin.scala | 9 ++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaKeys.scala b/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaKeys.scala index 07a38fec..d30f77c3 100644 --- a/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaKeys.scala +++ b/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaKeys.scala @@ -8,11 +8,12 @@ object MimaKeys extends MimaKeys class MimaKeys { - final val mimaPreviousArtifacts = settingKey[Set[ModuleID]]("Previous released artifacts used to test binary compatibility.") - final val mimaReportBinaryIssues = taskKey[Unit]("Logs all binary incompatibilities to the sbt console/logs.") - final val mimaBinaryIssueFilters = taskKey[Seq[ProblemFilter]]("Filters to apply to binary issues found. Applies both to backward and forward binary compatibility checking.") - final val mimaFailOnProblem = settingKey[Boolean]("if true, fail the build on binary incompatibility detection.") - final val mimaFailOnNoPrevious = settingKey[Boolean]("if true, fail the build if no previous artifacts are set.") + final val mimaPreviousArtifacts = settingKey[Set[ModuleID]]("Previous released artifacts used to test binary compatibility.") + final val mimaReportBinaryIssues = taskKey[Unit]("Logs all binary incompatibilities to the sbt console/logs.") + final val mimaBinaryIssueFilters = taskKey[Seq[ProblemFilter]]("Filters to apply to binary issues found. Applies both to backward and forward binary compatibility checking.") + final val mimaFailOnProblem = settingKey[Boolean]("if true, fail the build on binary incompatibility detection.") + final val mimaFailOnNoPrevious = settingKey[Boolean]("if true, fail the build if no previous artifacts are set.") + final val mimaReportSignatureProblems = settingKey[Boolean]("if true, report `IncompatibleSignatureProblem`s.") final val mimaPreviousClassfiles = taskKey[Map[ModuleID, File]]("Directories or jars containing the previous class files used to test compatibility with a given module.") final val mimaCurrentClassfiles = taskKey[File]("Directory or jar containing the current class files used to test compatibility.") diff --git a/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala b/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala index aed619e0..05d55b2a 100644 --- a/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala +++ b/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala @@ -3,6 +3,7 @@ package plugin import sbt._ import sbt.Keys._ +import com.typesafe.tools.mima.core.{ IncompatibleSignatureProblem, ProblemFilters } /** MiMa's sbt plugin. */ object MimaPlugin extends AutoPlugin { @@ -17,6 +18,7 @@ object MimaPlugin extends AutoPlugin { mimaBinaryIssueFilters := Nil, mimaFailOnProblem := true, mimaFailOnNoPrevious := true, + mimaReportSignatureProblems := false, mimaCheckDirection := "backward", ) @@ -29,7 +31,7 @@ object MimaPlugin extends AutoPlugin { problems._1, problems._2, mimaFailOnProblem.value, - mimaBinaryIssueFilters.value, + binaryIssueFilters.value, mimaBackwardIssueFilters.value, mimaForwardIssueFilters.value, log, @@ -63,6 +65,11 @@ object MimaPlugin extends AutoPlugin { /** Setup MiMa with default settings, applicable for most projects. */ def mimaDefaultSettings: Seq[Setting[_]] = globalSettings ++ buildSettings ++ projectSettings + private def binaryIssueFilters = Def.task { + val noSigs = ProblemFilters.exclude[IncompatibleSignatureProblem]("*") + mimaBinaryIssueFilters.value ++ (if (mimaReportSignatureProblems.value) Nil else Seq(noSigs)) + } + // Allows reuse between mimaFindBinaryIssues and mimaReportBinaryIssues // without blowing up the Akka build's heap private def binaryIssuesIterator = Def.task {