Fixes #1752. Fixes cached resolution too verbose.

- Fixes cached resolution being too verbose
- Adds new UpdateLogging named "Default"
- When global logLevel or logLevel in update is Debug, Default will
bump up to Full UpdateLogging.
This commit is contained in:
Eugene Yokota 2014-12-04 12:34:30 -05:00
parent 015c61ad69
commit 607b686cb2
5 changed files with 63 additions and 9 deletions

View File

@ -24,7 +24,13 @@ final class PublishConfiguration(val ivyFile: Option[File], val resolverName: St
this(ivyFile, resolverName, artifacts, checksums, logging, false)
}
final class UpdateConfiguration(val retrieve: Option[RetrieveConfiguration], val missingOk: Boolean, val logging: UpdateLogging.Value)
final class UpdateConfiguration(val retrieve: Option[RetrieveConfiguration], val missingOk: Boolean, val logging: UpdateLogging.Value) {
private[sbt] def copy(
retrieve: Option[RetrieveConfiguration] = this.retrieve,
missingOk: Boolean = this.missingOk,
logging: UpdateLogging.Value = this.logging): UpdateConfiguration =
new UpdateConfiguration(retrieve, missingOk, logging)
}
final class RetrieveConfiguration(val retrieveDirectory: File, val outputPattern: String)
final case class MakePomConfiguration(file: File, moduleInfo: ModuleInfo, configurations: Option[Seq[Configuration]] = None, extra: NodeSeq = NodeSeq.Empty, process: XNode => XNode = n => n, filterRepositories: MavenRepository => Boolean = _ => true, allRepositories: Boolean, includeTypes: Set[String] = Set(Artifact.DefaultType, Artifact.PomType))
// exclude is a map on a restricted ModuleID
@ -44,9 +50,10 @@ object UnresolvedWarningConfiguration {
* `Full` is the default and logs the most.
* `DownloadOnly` only logs what is downloaded.
* `Quiet` only displays errors.
* `Default` uses the current log level of `update` task.
*/
object UpdateLogging extends Enumeration {
val Full, DownloadOnly, Quiet = Value
val Full, DownloadOnly, Quiet, Default = Value
}
object IvyActions {
@ -161,6 +168,7 @@ object IvyActions {
val resolveOptions = new ResolveOptions
val resolveId = ResolveOptions.getDefaultResolveId(md)
resolveOptions.setResolveId(resolveId)
resolveOptions.setLog(ivyLogLevel(configuration.logging))
x.customResolve(md, configuration.missingOk, logicalClock, resolveOptions, depDir getOrElse { sys.error("dependency base directory is not specified") }, log) match {
case Left(x) =>
Left(UnresolvedWarning(x, uwconfig))
@ -303,13 +311,14 @@ object IvyActions {
IvyPatternHelper.substitute(pattern, mid.organization, mid.name, mid.revision, art.name, art.`type`, art.extension, conf, mextra, aextra)
}
import UpdateLogging.{ Quiet, Full, DownloadOnly }
import UpdateLogging.{ Quiet, Full, DownloadOnly, Default }
import LogOptions.{ LOG_QUIET, LOG_DEFAULT, LOG_DOWNLOAD_ONLY }
private def ivyLogLevel(level: UpdateLogging.Value) =
level match {
case Quiet => LOG_QUIET
case DownloadOnly => LOG_DOWNLOAD_ONLY
case Full => LOG_DEFAULT
case Default => LOG_DOWNLOAD_ONLY
}
def publish(module: ModuleDescriptor, artifacts: Seq[(IArtifact, File)], resolver: DependencyResolver, overwrite: Boolean): Unit =

View File

@ -14,7 +14,7 @@ import core.report.{ ResolveReport, ConfigurationResolveReport, DownloadReport }
import core.module.descriptor.{ DefaultModuleDescriptor, ModuleDescriptor, DefaultDependencyDescriptor, DependencyDescriptor, Configuration => IvyConfiguration, ExcludeRule, IncludeRule }
import core.module.descriptor.{ OverrideDependencyDescriptorMediator, DependencyArtifactDescriptor, DefaultDependencyArtifactDescriptor }
import core.{ IvyPatternHelper, LogOptions }
import org.apache.ivy.util.Message
import org.apache.ivy.util.{ Message, MessageLogger }
import org.apache.ivy.plugins.latest.{ ArtifactInfo => IvyArtifactInfo }
import org.apache.ivy.plugins.matcher.{ MapMatcher, PatternMatcher }
@ -297,6 +297,27 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine {
private[sbt] def makeInstance: Ivy
private[sbt] val ignoreTransitiveForce: Boolean = true
def withIvy[A](log: Logger)(f: Ivy => A): A =
withIvy(new IvyLoggerInterface(log))(f)
def withIvy[A](log: MessageLogger)(f: Ivy => A): A =
withDefaultLogger(log) {
val ivy = makeInstance
ivy.pushContext()
ivy.getLoggerEngine.pushLogger(log)
try { f(ivy) }
finally {
ivy.getLoggerEngine.popLogger()
ivy.popContext()
}
}
def withDefaultLogger[A](log: MessageLogger)(f: => A): A =
{
val originalLogger = Message.getDefaultLogger
Message.setDefaultLogger(log)
try { f }
finally { Message.setDefaultLogger(originalLogger) }
}
/**
* This returns sbt's UpdateReport structure.
* missingOk allows sbt to call this with classifiers that may or may not exist, and grab the JARs.
@ -314,8 +335,9 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine {
def doWork(md: ModuleDescriptor): Either[ResolveException, UpdateReport] =
{
val options1 = new ResolveOptions(options0)
val i = makeInstance
var rr = i.resolve(md, options1)
var rr = withIvy(log) { ivy =>
ivy.resolve(md, options1)
}
if (!rr.hasError || missingOk) Right(IvyRetrieve.updateReport(rr, cachedDescriptor))
else {
val messages = rr.getAllProblemMessages.toArray.map(_.toString).distinct

View File

@ -1027,7 +1027,7 @@ object Classpaths {
defaultConfiguration :== Some(Configurations.Compile),
dependencyOverrides :== Set.empty,
libraryDependencies :== Nil,
ivyLoggingLevel :== UpdateLogging.DownloadOnly,
ivyLoggingLevel :== UpdateLogging.Default,
ivyXML :== NodeSeq.Empty,
ivyValidate :== false,
moduleConfigurations :== Nil,
@ -1297,7 +1297,17 @@ object Classpaths {
val st = state.value
val logicalClock = LogicalClock(st.hashCode)
val depDir = dependencyCacheDirectory.value
cachedUpdate(s.cacheDirectory / updateCacheName.value, show, ivyModule.value, updateConfiguration.value, transform,
val uc0 = updateConfiguration.value
// Normally, log would capture log messages at all levels.
// Ivy logs are treated specially using sbt.UpdateConfiguration.logging.
// This code bumps up the sbt.UpdateConfiguration.logging to Full when logLevel is Debug.
import UpdateLogging.{ Full, DownloadOnly, Default }
val uc = (logLevel in update).?.value orElse st.get(logLevel.key) match {
case Some(Level.Debug) if uc0.logging == Default => uc0.copy(logging = Full)
case Some(x) if uc0.logging == Default => uc0.copy(logging = DownloadOnly)
case _ => uc0
}
cachedUpdate(s.cacheDirectory / updateCacheName.value, show, ivyModule.value, uc0, transform,
skip = (skip in update).value, force = isRoot, depsUpdated = depsUpdated,
uwConfig = uwConfig, logicalClock = logicalClock, depDir = Some(depDir), log = s.log)
}

View File

@ -0,0 +1,13 @@
[@cunei]: https://github.com/cunei
[@eed3si9n]: https://github.com/eed3si9n
[@gkossakowski]: https://github.com/gkossakowski
[@jsuereth]: https://github.com/jsuereth
[1752]: https://github.com/sbt/sbt/pull/1752
### Fixes with compatibility implications
### Improvements
### Bug fixes
- Fixes cached resolution being too verbose. [#1752][1752]

View File

@ -1 +1 @@
sbt.version=0.13.5
sbt.version=0.13.7