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.
This commit is contained in:
Martin Duhem 2015-08-27 09:02:46 +02:00
parent aec1e5fd52
commit ee0f73addb
1 changed files with 10 additions and 8 deletions

View File

@ -94,6 +94,7 @@ private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: Com
private val ivySbt: IvySbt = new IvySbt(ivyConfiguration)
// TODO: The actual sbt version may be different from the component manager's version
private val sbtVersion = ComponentManager.version
private val buffered = new BufferedLogger(FullLogger(log))
def apply(id: String): File = {
val binID = binaryID(id)
@ -115,7 +116,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 =>
@ -126,7 +127,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 =>
@ -135,7 +136,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))
@ -183,10 +185,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(s"Couldn't retrieve module ${dependenciesNames(module)}.")
buffered.debug(s"Couldn't retrieve module ${dependenciesNames(module)}.")
None
case Right(updateReport) =>
@ -197,8 +199,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