mirror of https://github.com/sbt/sbt.git
support warn fatal options in 2.8.0.RC2
This commit is contained in:
parent
ead0c5a68f
commit
33e957a47c
|
|
@ -20,4 +20,11 @@ object Command
|
|||
constr(classOf[List[_]], classOf[Settings], classOf[Function1[_, _]], classOf[Boolean]).newInstance(arguments, settings, error _, false.asInstanceOf[AnyRef])
|
||||
}
|
||||
}
|
||||
|
||||
def getWarnFatal(settings: Settings): Boolean =
|
||||
{
|
||||
implicit def compat27(settings: Settings): SettingsCompat = new SettingsCompat
|
||||
class SettingsCompat { def Xwarnfatal = this; def value = false }
|
||||
settings.Xwarnfatal.value
|
||||
}
|
||||
}
|
||||
|
|
@ -15,10 +15,10 @@ class CompilerInterface
|
|||
|
||||
debug(log, "Interfacing (CompilerInterface) with Scala compiler " + scala.tools.nsc.Properties.versionString)
|
||||
|
||||
val reporter = new LoggerReporter(maximumErrors, log)
|
||||
val settings = new Settings(reporter.error)
|
||||
|
||||
val settings = new Settings(Log.settingsError(log))
|
||||
val command = Command(args.toList, settings)
|
||||
val reporter = LoggerReporter(settings, maximumErrors, log)
|
||||
def noErrors = !reporter.hasErrors && command.ok
|
||||
|
||||
val phasesSet = new scala.collection.mutable.HashSet[Any] // 2.7 compatibility
|
||||
object compiler extends Global(command.settings, reporter)
|
||||
|
|
@ -74,14 +74,14 @@ class CompilerInterface
|
|||
}
|
||||
trait Compat27 { val runsBefore: List[String] = Nil }
|
||||
}
|
||||
if(!reporter.hasErrors)
|
||||
if(noErrors)
|
||||
{
|
||||
val run = new compiler.Run
|
||||
debug(log, args.mkString("Calling Scala compiler with arguments (CompilerInterface):\n\t", "\n\t", ""))
|
||||
run compile command.files
|
||||
}
|
||||
reporter.printSummary()
|
||||
if(reporter.hasErrors)
|
||||
if(!noErrors)
|
||||
{
|
||||
debug(log, "Compilation failed (CompilerInterface)")
|
||||
throw new InterfaceCompileFailed(args, "Compilation failed")
|
||||
|
|
|
|||
|
|
@ -6,4 +6,6 @@ package xsbt
|
|||
object Log
|
||||
{
|
||||
def debug(log: xsbti.Logger, msg: => String) = log.debug(Message(msg))
|
||||
def settingsError(log: xsbti.Logger): String => Unit =
|
||||
s => log.error(Message(s))
|
||||
}
|
||||
|
|
@ -5,10 +5,16 @@ package xsbt
|
|||
|
||||
import xsbti.{F0,Logger}
|
||||
|
||||
private object LoggerReporter
|
||||
{
|
||||
def apply(settings: scala.tools.nsc.Settings, maximumErrors: Int, log: Logger): LoggerReporter =
|
||||
new LoggerReporter(Command.getWarnFatal(settings), maximumErrors, log)
|
||||
}
|
||||
|
||||
// The following code is based on scala.tools.nsc.reporters.{AbstractReporter, ConsoleReporter}
|
||||
// Copyright 2002-2009 LAMP/EPFL
|
||||
// Original author: Martin Odersky
|
||||
private final class LoggerReporter(maximumErrors: Int, log: Logger) extends scala.tools.nsc.reporters.Reporter
|
||||
private final class LoggerReporter(warnFatal: Boolean, maximumErrors: Int, log: Logger) extends scala.tools.nsc.reporters.Reporter
|
||||
{
|
||||
import scala.tools.nsc.util.{FakePos,NoPosition,Position}
|
||||
private val positions = new scala.collection.mutable.HashMap[Position, Severity]
|
||||
|
|
@ -40,7 +46,7 @@ private final class LoggerReporter(maximumErrors: Int, log: Logger) extends scal
|
|||
})
|
||||
}
|
||||
|
||||
// the help keep source compatibility with the changes in 2.8 : Position.{source,line,column} are no longer Option[X]s, just plain Xs
|
||||
// this helps keep source compatibility with the changes in 2.8 : Position.{source,line,column} are no longer Option[X]s, just plain Xs
|
||||
// so, we normalize to Option[X]
|
||||
private def o[T](t: Option[T]): Option[T] = t
|
||||
private def o[T](t: T): Option[T] = Some(t)
|
||||
|
|
@ -82,8 +88,10 @@ private final class LoggerReporter(maximumErrors: Int, log: Logger) extends scal
|
|||
positions.clear
|
||||
}
|
||||
|
||||
protected def info0(pos: Position, msg: String, severity: Severity, force: Boolean)
|
||||
|
||||
protected def info0(pos: Position, msg: String, rawSeverity: Severity, force: Boolean)
|
||||
{
|
||||
val severity = if(warnFatal && rawSeverity == WARNING) ERROR else rawSeverity
|
||||
severity match
|
||||
{
|
||||
case WARNING | ERROR =>
|
||||
|
|
@ -13,22 +13,23 @@ class ScaladocInterface
|
|||
private class Runner(args: Array[String], maximumErrors: Int, log: Logger)
|
||||
{
|
||||
import scala.tools.nsc.{doc, Global}
|
||||
val reporter = new LoggerReporter(maximumErrors, log)
|
||||
val docSettings: doc.Settings = new doc.Settings(reporter.error)
|
||||
val docSettings: doc.Settings = new doc.Settings(Log.settingsError(log))
|
||||
val command = Command(args.toList, docSettings)
|
||||
val reporter = LoggerReporter(docSettings, maximumErrors, log)
|
||||
def noErrors = !reporter.hasErrors && command.ok
|
||||
|
||||
import forScope._
|
||||
def run()
|
||||
{
|
||||
debug(log, "Calling Scaladoc with arguments:\n\t" + args.mkString("\n\t"))
|
||||
if(!reporter.hasErrors)
|
||||
if(noErrors)
|
||||
{
|
||||
import doc._ // 2.8 trunk and Beta1-RC4 have doc.DocFactory. For other Scala versions, the next line creates forScope.DocFactory
|
||||
val processor = new DocFactory(reporter, docSettings)
|
||||
processor.document(command.files)
|
||||
}
|
||||
reporter.printSummary()
|
||||
if(reporter.hasErrors) throw new InterfaceCompileFailed(args, "Scaladoc generation failed")
|
||||
if(!noErrors) throw new InterfaceCompileFailed(args, "Scaladoc generation failed")
|
||||
}
|
||||
|
||||
object forScope
|
||||
|
|
|
|||
Loading…
Reference in New Issue