Ignore 'unknown resolver' errors, work with published version of SBinary, work towards fixing OOME:PermGen issues on reload

This commit is contained in:
Mark Harrah 2010-01-26 18:41:03 -05:00
parent e8eae7d7bb
commit 725beacd9a
6 changed files with 53 additions and 16 deletions

View File

@ -46,7 +46,7 @@ private object TrackingFormat
}
def trackingFormat[T](translateProducts: Boolean)(implicit tFormat: Format[T]): Format[DependencyTracking[T]] =
asProduct4((a: DMap[T],b: DMap[T],c: DMap[T], d:TagMap[T]) => new DefaultTracking(translateProducts)(a,b,c,d) : DependencyTracking[T]
)(dt => Some(dt.reverseDependencies, dt.reverseUses, dt.sourceMap, dt.tagMap))
)(dt => (dt.reverseDependencies, dt.reverseUses, dt.sourceMap, dt.tagMap))
}
private final class IndexMap[T] extends NotNull

View File

@ -36,7 +36,9 @@ private final class IvyLoggerInterface(logger: IvyLogger) extends MessageLogger
def info(msg: String) = logger.info(msg)
def rawinfo(msg: String) = info(msg)
def warn(msg: String) = logger.warn(msg)
def error(msg: String) = logger.error(msg)
def error(msg: String) =
if(!msg.startsWith("unknown resolver")) // hack to suppress these kinds of messages
logger.error(msg)
private def emptyList = java.util.Collections.emptyList[T forSome { type T}]
def getProblems = emptyList
@ -52,3 +54,10 @@ private final class IvyLoggerInterface(logger: IvyLogger) extends MessageLogger
def isShowProgress = false
def setShowProgress(progress: Boolean) {}
}
/** This is a hack to filter error messages about 'unknown resolver ...'. */
private final class SbtMessageLoggerEngine extends MessageLoggerEngine
{
override def error(msg: String) = if(acceptError(msg)) super.error(msg)
def acceptError(msg: String) = (msg ne null) && !msg.startsWith("unknown resolver")
}

View File

@ -13,24 +13,30 @@ object Boot
System.clearProperty("scala.home") // avoid errors from mixing Scala versions in the same JVM
CheckProxy()
run(args)
System.exit(0)
}
def run(args: Array[String])
// this arrangement is because Scala 2.7.7 does not properly optimize away
// the tail recursion in a catch statement
final def run(args: Array[String]): Unit = run(runImpl(args))
private def runImpl(args: Array[String]): Array[String] =
{
try { Launch(args.toList) }
try
{
Launch(args.toList)
System.exit(0).asInstanceOf[Nothing]
}
catch
{
case b: BootException => errorAndExit(b.toString)
case r: xsbti.RetrieveException =>errorAndExit("Error: " + r.getMessage)
case r: xsbti.FullReload => run(r.arguments)
case r: xsbti.FullReload => r.arguments
case e =>
e.printStackTrace
errorAndExit(Pre.prefixError(e.toString))
}
}
private def errorAndExit(msg: String)
private def errorAndExit(msg: String): Nothing =
{
System.out.println(msg)
System.exit(1)
System.exit(1).asInstanceOf[Nothing]
}
}

View File

@ -21,7 +21,7 @@ import core.sort.SortEngine
import core.settings.IvySettings
import plugins.matcher.{ExactPatternMatcher, PatternMatcher}
import plugins.resolver.{ChainResolver, FileSystemResolver, IBiblioResolver, URLResolver}
import util.{DefaultMessageLogger, Message}
import util.{DefaultMessageLogger, Message, MessageLoggerEngine}
import BootConfiguration._
@ -49,7 +49,13 @@ final class Update(config: UpdateConfiguration)
settings.setVariable("scala", scalaVersion)
settings
}
private lazy val ivy = Ivy.newInstance(settings)
private lazy val ivy =
{
val ivy = new Ivy() { private val loggerEngine = new SbtMessageLoggerEngine; override def getLoggerEngine = loggerEngine }
ivy.setSettings(settings)
ivy.bind()
ivy
}
/** The main entry point of this class for use by the Update module. It runs Ivy */
def apply(target: UpdateTarget): Boolean =
@ -277,16 +283,32 @@ final class Update(config: UpdateConfiguration)
System.out.println(msg)
}
}
import SbtIvyLogger.{acceptError, acceptMessage}
/** A custom logger for Ivy to ignore the messages about not finding classes
* intentionally filtered using proguard. */
* intentionally filtered using proguard and about 'unknown resolver'. */
private final class SbtIvyLogger(logWriter: PrintWriter) extends DefaultMessageLogger(Message.MSG_INFO) with NotNull
{
private val ignorePrefix = "impossible to define"
override def log(msg: String, level: Int)
{
logWriter.println(msg)
if(level <= getLevel && msg != null && !msg.startsWith(ignorePrefix))
if(level <= getLevel && acceptMessage(msg))
System.out.println(msg)
}
override def rawlog(msg: String, level: Int) { log(msg, level) }
/** This is a hack to filter error messages about 'unknown resolver ...'. */
override def error(msg: String) = if(acceptError(msg)) super.error(msg)
}
private final class SbtMessageLoggerEngine extends MessageLoggerEngine
{
/** This is a hack to filter error messages about 'unknown resolver ...'. */
override def error(msg: String) = if(acceptError(msg)) super.error(msg)
}
private object SbtIvyLogger
{
val IgnorePrefix = "impossible to define"
val UnknownResolver = "unknown resolver"
def acceptError(msg: String) = (msg ne null) && !msg.startsWith(UnknownResolver)
def acceptMessage(msg: String) = (msg ne null) && !msg.startsWith(IgnorePrefix)
}

View File

@ -104,7 +104,7 @@ object Tag
import sbinary.{DefaultProtocol, Format, Operations}
import DefaultProtocol._
private implicit val subclassFormat: Format[DetectedSubclass] =
asProduct4(DetectedSubclass.apply)( ds => Some(ds.source, ds.subclassName, ds.superclassName, ds.isModule))
asProduct4(DetectedSubclass.apply)( ds => (ds.source, ds.subclassName, ds.superclassName, ds.isModule))
def toBytes(applications: List[String], subclasses: List[DetectedSubclass]) = CacheIO.toBytes((applications, subclasses))
def fromBytes(bytes: Array[Byte]) = CacheIO.fromBytes( ( List[String](), List[DetectedSubclass]() ) )(bytes)
}

View File

@ -30,7 +30,7 @@ object SyncTest
}
object CompileTest
{
def apply(dir: String, scalaVersion: String, options: Seq[String], supers: Set[String])
def apply(dir: String, scalaVersion: String, options: Seq[String])
{
def test()
{
@ -41,7 +41,7 @@ object CompileTest
val classpath = Task( dir / "lib" * "*.jar" )
WithCompiler(scalaVersion) { (compiler, log) =>
temp { cacheDir => temp { outDir =>
val compile = new StandardCompile(sources, classpath, Task(outDir), Task(options), Task(supers), Task(compiler), cacheDir, log)
val compile = AggressiveCompile(sources, classpath, Task(outDir), Task(options), cacheDir, Task(compiler), log)
println("Result: " + TaskRunner(compile.task))
println("Result: " + TaskRunner(compile.task))
TaskRunner(compile.clean)