From ee0f73addbd13062c6a46efe89656f766c479d6e Mon Sep 17 00:00:00 2001 From: Martin Duhem Date: Thu, 27 Aug 2015 09:02:46 +0200 Subject: [PATCH 1/2] 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/internal/compile-ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala b/internal/compile-ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala index 5ba9a2d93..ee7e64e50 100644 --- a/internal/compile-ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala +++ b/internal/compile-ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala @@ -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 From 00101022e1e7d42f63179808edef51beac76dbe6 Mon Sep 17 00:00:00 2001 From: Martin Duhem Date: Thu, 27 Aug 2015 09:03:49 +0200 Subject: [PATCH 2/2] Download compiler interface sources in boot directory --- .../main/scala/sbt/compiler/ComponentCompiler.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/compile-ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala b/internal/compile-ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala index ee7e64e50..cf3cc9891 100644 --- a/internal/compile-ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala +++ b/internal/compile-ivy/src/main/scala/sbt/compiler/ComponentCompiler.scala @@ -16,7 +16,7 @@ object ComponentCompiler { val compilerInterfaceSrcID = compilerInterfaceID + srcExtension val javaVersion = System.getProperty("java.class.version") - @deprecated("Use `interfaceProvider(ComponentManager, IvyConfiguration)`.", "0.13.10") + @deprecated("Use `interfaceProvider(ComponentManager, IvyConfiguration, File)`.", "0.13.10") def interfaceProvider(manager: ComponentManager): CompilerInterfaceProvider = new CompilerInterfaceProvider { def apply(scalaInstance: xsbti.compile.ScalaInstance, log: Logger): File = { @@ -27,11 +27,11 @@ object ComponentCompiler { } } - def interfaceProvider(manager: ComponentManager, ivyConfiguration: IvyConfiguration): CompilerInterfaceProvider = new CompilerInterfaceProvider { + def interfaceProvider(manager: ComponentManager, ivyConfiguration: IvyConfiguration, bootDirectory: File): CompilerInterfaceProvider = new CompilerInterfaceProvider { def apply(scalaInstance: xsbti.compile.ScalaInstance, log: Logger): File = { // this is the instance used to compile the interface component - val componentCompiler = new IvyComponentCompiler(new RawCompiler(scalaInstance, ClasspathOptions.auto, log), manager, ivyConfiguration, log) + val componentCompiler = new IvyComponentCompiler(new RawCompiler(scalaInstance, ClasspathOptions.auto, log), manager, ivyConfiguration, bootDirectory, log) log.debug("Getting " + compilerInterfaceID + " from component compiler for Scala " + scalaInstance.version) componentCompiler(compilerInterfaceID) } @@ -86,15 +86,17 @@ class ComponentCompiler(compiler: RawCompiler, manager: ComponentManager) { * The compiled classes are cached using the provided component manager according * to the actualVersion field of the RawCompiler. */ -private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: ComponentManager, ivyConfiguration: IvyConfiguration, log: Logger) { +private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: ComponentManager, ivyConfiguration: IvyConfiguration, bootDirectory: File, log: Logger) { import ComponentCompiler._ + private val incrementalCompilerOrg = xsbti.ArtifactInfo.SbtOrganization + ".incrementalcompiler" private val sbtOrgTemp = JsonUtil.sbtOrgTemp private val modulePrefixTemp = "temp-module-" 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)) + private val retrieveDirectory = new File(s"$bootDirectory/scala-${compiler.scalaInstance.version}/$incrementalCompilerOrg/sbt/$sbtVersion/compiler-interface-srcs") def apply(id: String): File = { val binID = binaryID(id) @@ -181,7 +183,6 @@ private[compiler] class IvyComponentCompiler(compiler: RawCompiler, manager: Com private def update(module: ivySbt.Module)(predicate: File => Boolean): Option[Seq[File]] = { - val retrieveDirectory = new File(ivyConfiguration.baseDirectory, "component") val retrieveConfiguration = new RetrieveConfiguration(retrieveDirectory, Resolver.defaultRetrievePattern, false) val updateConfiguration = new UpdateConfiguration(Some(retrieveConfiguration), true, UpdateLogging.DownloadOnly)