From 7aac5f023cfdfbd1439eb3347f4135043c3977d5 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Wed, 14 Feb 2018 18:11:03 -0800 Subject: Add fatal warnings checking that doesn't consider deprecations --- src/main/scala/xyz.driver.sbt/FatalWarnings.scala | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main/scala/xyz.driver.sbt/FatalWarnings.scala (limited to 'src/main/scala/xyz.driver.sbt/FatalWarnings.scala') diff --git a/src/main/scala/xyz.driver.sbt/FatalWarnings.scala b/src/main/scala/xyz.driver.sbt/FatalWarnings.scala new file mode 100644 index 0000000..b7fc585 --- /dev/null +++ b/src/main/scala/xyz.driver.sbt/FatalWarnings.scala @@ -0,0 +1,31 @@ +package xyz.driver.sbt + +import sbt.{Def, _} +import sbt.Keys._ +import xsbti.compile.CompileAnalysis + +import scala.collection.JavaConverters._ + +object FatalWarnings extends AutoPlugin { + + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override def projectSettings: Seq[Def.Setting[_]] = Seq( + compile in Compile := { + val compiled: CompileAnalysis = (compile in Compile).value + val problems = compiled.readSourceInfos().getAllSourceInfos.asScala.flatMap { + case (_, info) => + info.getReportedProblems + } + + val deprecationsOnly = problems.forall { problem => + problem.message().contains("is deprecated") + } + + if (!deprecationsOnly) sys.error("Fatal warnings: some warnings other than deprecations were found.") + compiled + } + ) + +} -- cgit v1.2.3