From 725beacd9ad3da28ca3e20ed0f071408a2106bed Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Tue, 26 Jan 2010 18:41:03 -0500 Subject: [PATCH] Ignore 'unknown resolver' errors, work with published version of SBinary, work towards fixing OOME:PermGen issues on reload --- cache/tracking/TrackingFormat.scala | 2 +- ivy/IvyLogger.scala | 11 ++++++- launch/Boot.scala | 18 +++++++---- launch/Update.scala | 32 +++++++++++++++++--- tasks/standard/TransitiveCompile.scala | 2 +- tasks/standard/src/test/scala/SyncTest.scala | 4 +-- 6 files changed, 53 insertions(+), 16 deletions(-) diff --git a/cache/tracking/TrackingFormat.scala b/cache/tracking/TrackingFormat.scala index c0106d3a0..1318c6096 100644 --- a/cache/tracking/TrackingFormat.scala +++ b/cache/tracking/TrackingFormat.scala @@ -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 diff --git a/ivy/IvyLogger.scala b/ivy/IvyLogger.scala index 7b062d7af..8046a3982 100644 --- a/ivy/IvyLogger.scala +++ b/ivy/IvyLogger.scala @@ -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") +} \ No newline at end of file diff --git a/launch/Boot.scala b/launch/Boot.scala index 4e4f79770..ac98bf7ff 100644 --- a/launch/Boot.scala +++ b/launch/Boot.scala @@ -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] } } diff --git a/launch/Update.scala b/launch/Update.scala index 16f786bf4..ab1f28b41 100644 --- a/launch/Update.scala +++ b/launch/Update.scala @@ -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) } \ No newline at end of file diff --git a/tasks/standard/TransitiveCompile.scala b/tasks/standard/TransitiveCompile.scala index 93852d89c..a82e2f440 100644 --- a/tasks/standard/TransitiveCompile.scala +++ b/tasks/standard/TransitiveCompile.scala @@ -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) } diff --git a/tasks/standard/src/test/scala/SyncTest.scala b/tasks/standard/src/test/scala/SyncTest.scala index e51c53fe4..4ba02fda9 100644 --- a/tasks/standard/src/test/scala/SyncTest.scala +++ b/tasks/standard/src/test/scala/SyncTest.scala @@ -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)