From 41b7208a36ccd2cd91403d30e14ccf5a70aa6fc6 Mon Sep 17 00:00:00 2001 From: Martin Duhem Date: Wed, 26 Aug 2015 09:40:53 +0200 Subject: [PATCH] Hide Ivy logs in compiler-interface sources retrieval Because in most cases there aren't version-specific sources, we expect the retrieval to fail a number of times before succeeding. This generates a lot of noise in sbt's log, so the logs will now be shown if and only all the versions fail. --- .../scala/sbt/compiler/ComponentCompiler.scala | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/compile/ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala b/compile/ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala index f203c58ca..11499ddc0 100644 --- a/compile/ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala +++ b/compile/ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala @@ -92,6 +92,7 @@ private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: Com private val modulePrefixTemp = "temp-module-" private val ivySbt: IvySbt = new IvySbt(ivyConfiguration) private val sbtVersion = ComponentManager.version + private val buffered = new BufferedLogger(FullLogger(log)) def apply(id: String): File = { val binID = binaryID(id) @@ -113,7 +114,7 @@ private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: Com sourcesJar } getOrElse (throw new InvalidComponent(s"Couldn't retrieve default sources: module '$id'")) - log.debug(s"Fetching default sources: module '$id'") + buffered.debug(s"Fetching default sources: module '$id'") manager.files(id)(new IfMissing.Fallback(getAndDefineDefaultSources())) case version +: rest => @@ -124,7 +125,7 @@ private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: Com sourcesJar } getOrElse interfaceSources(rest) - log.debug(s"Fetching version-specific sources: module '$moduleName'") + buffered.debug(s"Fetching version-specific sources: module '$moduleName'") manager.files(moduleName)(new IfMissing.Fallback(getAndDefineVersionSpecificSources())) } IO.withTemporaryDirectory { binaryDirectory => @@ -133,7 +134,8 @@ private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: Com val xsbtiJars = manager.files(xsbtiID)(IfMissing.Fail) val sourceModuleVersions = VersionNumber(compiler.scalaInstance.actualVersion).cascadingVersions - AnalyzingCompiler.compileSources(interfaceSources(sourceModuleVersions), targetJar, xsbtiJars, id, compiler, log) + val sources = buffered bufferQuietly interfaceSources(sourceModuleVersions) + AnalyzingCompiler.compileSources(sources, targetJar, xsbtiJars, id, compiler, log) manager.define(binID, Seq(targetJar)) @@ -181,10 +183,10 @@ private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: Com val retrieveConfiguration = new RetrieveConfiguration(retrieveDirectory, Resolver.defaultRetrievePattern, false) val updateConfiguration = new UpdateConfiguration(Some(retrieveConfiguration), true, UpdateLogging.DownloadOnly) - log.info(s"Attempting to fetch ${dependenciesNames(module)}. This operation may fail.") - IvyActions.updateEither(module, updateConfiguration, UnresolvedWarningConfiguration(), LogicalClock.unknown, None, log) match { + buffered.info(s"Attempting to fetch ${dependenciesNames(module)}. This operation may fail.") + IvyActions.updateEither(module, updateConfiguration, UnresolvedWarningConfiguration(), LogicalClock.unknown, None, buffered) match { case Left(unresolvedWarning) => - log.debug("Couldn't retrieve module ${dependenciesNames(module)}.") + buffered.debug("Couldn't retrieve module ${dependenciesNames(module)}.") None case Right(updateReport) => @@ -195,8 +197,8 @@ private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: Com (_, f) <- m.artifacts } yield f - log.debug(s"Files retrieved for ${dependenciesNames(module)}:") - log.debug(allFiles mkString ", ") + buffered.debug(s"Files retrieved for ${dependenciesNames(module)}:") + buffered.debug(allFiles mkString ", ") allFiles filter predicate match { case Seq() => None