Skip to content

Commit cf7b288

Browse files
committed
Improve problem reporting
Report the summary (previously "found $count potential binary...") at error or warn level, like the problem details themselves. Note that `log`, here, is MiMa's Logging interface, which wires its info level to sbt's _debug_ level. So logging to "info" will mostly never be seen. Therefore, this, in particular, brings to the foreground: * the module version (".. check against org.scala-sbt:main_2.12:1.1.2!") * the number of filtered problems (".. (filtered 111)") Also, don't log the project name with sys.error: sbt's task error reporting prints the message with the project-specific task name, e.g.: [error] (mainProj / mimaReportBinaryIssues) Main: Binary compatibility check failed!
1 parent 4943295 commit cf7b288

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,17 @@ object MimaPlugin extends AutoPlugin {
6868
private def binaryIssuesIterator = Def.task {
6969
val s = streams.value
7070
val previousClassfiles = mimaPreviousClassfiles.value
71-
72-
if (previousClassfiles.isEmpty) {
73-
val projectName = name.value
74-
var msg = s"$projectName: mimaPreviousArtifacts is empty, not analyzing binary compatibility."
75-
if (previousClassfiles eq NoPreviousClassfiles) {
76-
msg = s"$projectName: mimaPreviousArtifacts not set, not analyzing binary compatibility."
77-
if (mimaFailOnNoPrevious.value)
78-
sys.error(msg)
79-
}
80-
s.log.info(msg)
81-
}
82-
8371
val currentClassfiles = mimaCurrentClassfiles.value
8472
val cp = (fullClasspath in mimaFindBinaryIssues).value
8573
val log = new SbtLogger(s)
8674

75+
if (previousClassfiles eq NoPreviousClassfiles) {
76+
val msg = "mimaPreviousArtifacts not set, not analyzing binary compatibility"
77+
if (mimaFailOnNoPrevious.value) sys.error(msg) else s.log.info(s"${name.value}: $msg")
78+
} else if (previousClassfiles.isEmpty) {
79+
s.log.info(s"${name.value}: mimaPreviousArtifacts is empty, not analyzing binary compatibility.")
80+
}
81+
8782
previousClassfiles.iterator.map { case (moduleId, prevClassfiles) =>
8883
moduleId -> SbtMima.runMima(prevClassfiles, currentClassfiles, cp, mimaCheckDirection.value, log)
8984
}

sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/SbtMima.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ object SbtMima {
6464
val count = backErrors.size + forwErrors.size
6565
val filteredCount = backward.size + forward.size - count
6666
val filteredNote = if (filteredCount > 0) s" (filtered $filteredCount)" else ""
67-
log.info(s"$projectName: found $count potential binary incompatibilities while checking against $module$filteredNote")
67+
val msg = s"Failed binary compatibility check against $module! Found $count potential problems$filteredNote"
68+
val doLog = if (count == 0) log.info(_) else if (failOnProblem) log.error(_) else log.warn(_)
6869

69-
(backErrors.iterator.map(pretty("current")) ++ forwErrors.iterator.map(pretty("other"))).foreach { msg =>
70-
if (failOnProblem) log.error(msg)
71-
else log.warn(msg)
72-
}
70+
doLog(s"$projectName: $msg")
71+
for (p <- backErrors) doLog(pretty("current")(p))
72+
for (p <- forwErrors) doLog(pretty("other")(p))
7373

7474
if (failOnProblem && count > 0) {
75-
sys.error(s"$projectName: Binary compatibility check failed!")
75+
sys.error(msg)
7676
}
7777
}
7878

0 commit comments

Comments
 (0)