Last active
August 3, 2018 13:31
-
-
Save MasseGuillaume/b3a4e1ebbb1520f81c40d57335aa47ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._ | |
import Keys._ | |
import KeyRanks.DTask | |
import xsbti.{Reporter, Problem, Position, Severity} | |
object CustomReporter { | |
private lazy val compilerReporter = TaskKey[xsbti.Reporter]( | |
"compilerReporter", | |
"Experimental hook to listen (or send) compilation failure messages.", | |
DTask | |
) | |
private val reporter = | |
new xsbti.Reporter { | |
private val buffer = collection.mutable.ArrayBuffer.empty[Problem] | |
def reset(): Unit = buffer.clear() | |
def hasErrors: Boolean = buffer.exists(_.severity == Severity.Error) | |
def hasWarnings: Boolean = buffer.exists(_.severity == Severity.Warn) | |
def printSummary(): Unit = { | |
print("\033c") | |
if (problems.nonEmpty) { | |
problems.foreach{ p => | |
println("=====================================================") | |
println(p.position) | |
println(p.message) | |
println() | |
println() | |
} | |
println("+++++++++++++++++++++++++++++++++++++++++++++++++++++") | |
println("count: " + problems.size) | |
} | |
buffer.clear() | |
} | |
def problems: Array[Problem] = buffer.toArray | |
def log(problem: Problem): Unit = { | |
if (problem.severity == Severity.Error) { | |
buffer.append(problem) | |
} | |
} | |
def log(pos: Position, msg: String, sev: Severity): Unit = { | |
log(new Problem { | |
def category: String = "foo" | |
def severity: Severity = sev | |
def message: String = msg | |
def position: Position = pos | |
}) | |
} | |
def comment(pos: xsbti.Position, msg: String): Unit = () | |
} | |
val ignoreWarnings = Seq( | |
compilerReporter in (Compile, compile) := reporter, | |
compilerReporter in (Test, compile) := reporter | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment