mirror of https://github.com/sbt/sbt.git
trim update and add updateFull
Fixes #4438 This slims down update's UpdateReport by removing evicted modules caller information. The larger the graph, the effect would be more pronounced. For example, I saw a graph reduce from 5.9MB to 1.1MB in JSON file.
This commit is contained in:
parent
4074cb32d3
commit
6c7faf2b86
|
|
@ -2278,7 +2278,8 @@ object Classpaths {
|
||||||
unresolvedWarningConfiguration in update := UnresolvedWarningConfiguration(
|
unresolvedWarningConfiguration in update := UnresolvedWarningConfiguration(
|
||||||
dependencyPositions.value
|
dependencyPositions.value
|
||||||
),
|
),
|
||||||
update := (updateTask tag (Tags.Update, Tags.Network)).value,
|
updateFull := (updateTask tag (Tags.Update, Tags.Network)).value,
|
||||||
|
update := (updateWithoutDetails("update") tag (Tags.Update, Tags.Network)).value,
|
||||||
update := {
|
update := {
|
||||||
val report = update.value
|
val report = update.value
|
||||||
val log = streams.value.log
|
val log = streams.value.log
|
||||||
|
|
@ -2656,9 +2657,23 @@ object Classpaths {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def updateTask: Initialize[Task[UpdateReport]] = Def.task {
|
def updateTask: Initialize[Task[UpdateReport]] = updateTask0("updateFull", true, true)
|
||||||
|
def updateWithoutDetails(label: String): Initialize[Task[UpdateReport]] =
|
||||||
|
updateTask0(label, false, false)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cacheLabel - label to identify an update cache
|
||||||
|
* includeCallers - include the caller information
|
||||||
|
* includeDetails - include module reports for the evicted modules
|
||||||
|
*/
|
||||||
|
private def updateTask0(
|
||||||
|
cacheLabel: String,
|
||||||
|
includeCallers: Boolean,
|
||||||
|
includeDetails: Boolean
|
||||||
|
): Initialize[Task[UpdateReport]] = Def.task {
|
||||||
val s = streams.value
|
val s = streams.value
|
||||||
val cacheDirectory = streams.value.cacheDirectory
|
val cacheDirectory = crossTarget.value / cacheLabel / updateCacheName.value
|
||||||
|
val cacheStoreFactory: CacheStoreFactory = CacheStoreFactory.directory(cacheDirectory)
|
||||||
|
|
||||||
val isRoot = executionRoots.value contains resolvedScoped.value
|
val isRoot = executionRoots.value contains resolvedScoped.value
|
||||||
val shouldForce = isRoot || {
|
val shouldForce = isRoot || {
|
||||||
|
|
@ -2721,7 +2736,7 @@ object Classpaths {
|
||||||
lm = dependencyResolution.value,
|
lm = dependencyResolution.value,
|
||||||
// Ivy-free ModuleDescriptor
|
// Ivy-free ModuleDescriptor
|
||||||
module = ivyModule.value,
|
module = ivyModule.value,
|
||||||
s.cacheStoreFactory.sub(updateCacheName.value),
|
cacheStoreFactory = cacheStoreFactory,
|
||||||
label = label,
|
label = label,
|
||||||
updateConf,
|
updateConf,
|
||||||
substituteScalaFiles(scalaOrganization.value, _)(providedScalaJars),
|
substituteScalaFiles(scalaOrganization.value, _)(providedScalaJars),
|
||||||
|
|
@ -2732,6 +2747,8 @@ object Classpaths {
|
||||||
ewo = evictionOptions,
|
ewo = evictionOptions,
|
||||||
mavenStyle = publishMavenStyle.value,
|
mavenStyle = publishMavenStyle.value,
|
||||||
compatWarning = compatibilityWarningOptions.value,
|
compatWarning = compatibilityWarningOptions.value,
|
||||||
|
includeCallers = includeCallers,
|
||||||
|
includeDetails = includeDetails,
|
||||||
log = s.log
|
log = s.log
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -370,6 +370,7 @@ object Keys {
|
||||||
val ivyModule = taskKey[IvySbt#Module]("Provides the sbt interface to a configured Ivy module.").withRank(CTask)
|
val ivyModule = taskKey[IvySbt#Module]("Provides the sbt interface to a configured Ivy module.").withRank(CTask)
|
||||||
val updateCacheName = taskKey[String]("Defines the directory name used to store the update cache files (inside the streams cacheDirectory).").withRank(DTask)
|
val updateCacheName = taskKey[String]("Defines the directory name used to store the update cache files (inside the streams cacheDirectory).").withRank(DTask)
|
||||||
val update = taskKey[UpdateReport]("Resolves and optionally retrieves dependencies, producing a report.").withRank(ATask)
|
val update = taskKey[UpdateReport]("Resolves and optionally retrieves dependencies, producing a report.").withRank(ATask)
|
||||||
|
val updateFull = taskKey[UpdateReport]("Resolves and optionally retrieves dependencies, producing a full report with callers.").withRank(CTask)
|
||||||
val evicted = taskKey[EvictionWarning]("Display detailed eviction warnings.").withRank(CTask)
|
val evicted = taskKey[EvictionWarning]("Display detailed eviction warnings.").withRank(CTask)
|
||||||
val evictionWarningOptions = settingKey[EvictionWarningOptions]("Options on eviction warnings after resolving managed dependencies.").withRank(DSetting)
|
val evictionWarningOptions = settingKey[EvictionWarningOptions]("Options on eviction warnings after resolving managed dependencies.").withRank(DSetting)
|
||||||
val transitiveUpdate = taskKey[Seq[UpdateReport]]("UpdateReports for the internal dependencies of this project.").withRank(DTask)
|
val transitiveUpdate = taskKey[Seq[UpdateReport]]("UpdateReports for the internal dependencies of this project.").withRank(DTask)
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ private[sbt] object LibraryManagement {
|
||||||
ewo: EvictionWarningOptions,
|
ewo: EvictionWarningOptions,
|
||||||
mavenStyle: Boolean,
|
mavenStyle: Boolean,
|
||||||
compatWarning: CompatibilityWarningOptions,
|
compatWarning: CompatibilityWarningOptions,
|
||||||
|
includeCallers: Boolean,
|
||||||
|
includeDetails: Boolean,
|
||||||
log: Logger
|
log: Logger
|
||||||
): UpdateReport = {
|
): UpdateReport = {
|
||||||
|
|
||||||
|
|
@ -50,15 +52,15 @@ private[sbt] object LibraryManagement {
|
||||||
throw unresolvedWarning.resolveException
|
throw unresolvedWarning.resolveException
|
||||||
}
|
}
|
||||||
log.debug(s"Done updating $label")
|
log.debug(s"Done updating $label")
|
||||||
val finalReport = transform(report)
|
val report1 = transform(report)
|
||||||
|
|
||||||
// Warn of any eviction and compatibility warnings
|
// Warn of any eviction and compatibility warnings
|
||||||
val ew = EvictionWarning(module, ewo, finalReport)
|
val ew = EvictionWarning(module, ewo, report1)
|
||||||
ew.lines.foreach(log.warn(_))
|
ew.lines.foreach(log.warn(_))
|
||||||
ew.infoAllTheThings.foreach(log.info(_))
|
ew.infoAllTheThings.foreach(log.info(_))
|
||||||
CompatibilityWarning.run(compatWarning, module, mavenStyle, log)
|
CompatibilityWarning.run(compatWarning, module, mavenStyle, log)
|
||||||
|
val report2 = transformDetails(report1, includeCallers, includeDetails)
|
||||||
finalReport
|
report2
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if a update report is still up to date or we must resolve again. */
|
/* Check if a update report is still up to date or we must resolve again. */
|
||||||
|
|
@ -90,7 +92,9 @@ private[sbt] object LibraryManagement {
|
||||||
import sbt.librarymanagement.LibraryManagementCodec._
|
import sbt.librarymanagement.LibraryManagementCodec._
|
||||||
val cachedResolve = Tracked.lastOutput[UpdateInputs, UpdateReport](cache) {
|
val cachedResolve = Tracked.lastOutput[UpdateInputs, UpdateReport](cache) {
|
||||||
case (_, Some(out)) if upToDate(inChanged, out) => markAsCached(out)
|
case (_, Some(out)) if upToDate(inChanged, out) => markAsCached(out)
|
||||||
case _ => resolve
|
case pair =>
|
||||||
|
log.debug(s""""not up to date. inChanged = $inChanged, force = $force""")
|
||||||
|
resolve
|
||||||
}
|
}
|
||||||
import scala.util.control.Exception.catching
|
import scala.util.control.Exception.catching
|
||||||
catching(classOf[NullPointerException], classOf[OutOfMemoryError])
|
catching(classOf[NullPointerException], classOf[OutOfMemoryError])
|
||||||
|
|
@ -150,4 +154,24 @@ private[sbt] object LibraryManagement {
|
||||||
.withExtraAttributes(m.extraAttributes)
|
.withExtraAttributes(m.extraAttributes)
|
||||||
.withConfigurations(if (confs) m.configurations else None)
|
.withConfigurations(if (confs) m.configurations else None)
|
||||||
.branch(m.branchName)
|
.branch(m.branchName)
|
||||||
|
|
||||||
|
private[this] def transformDetails(
|
||||||
|
ur: UpdateReport,
|
||||||
|
includeCallers: Boolean,
|
||||||
|
includeDetails: Boolean
|
||||||
|
): UpdateReport = {
|
||||||
|
val crs0 = ur.configurations
|
||||||
|
val crs1 =
|
||||||
|
if (includeDetails) crs0
|
||||||
|
else crs0 map { _.withDetails(Vector()) }
|
||||||
|
val crs2 =
|
||||||
|
if (includeCallers) crs1
|
||||||
|
else
|
||||||
|
crs1 map { cr =>
|
||||||
|
val mrs0 = cr.modules
|
||||||
|
val mrs1 = mrs0 map { _.withCallers(Vector()) }
|
||||||
|
cr.withModules(mrs1)
|
||||||
|
}
|
||||||
|
ur.withConfigurations(crs2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,9 @@ lazy val root = (project in file("."))
|
||||||
// sbt resolves dependencies every compile when using %% with dependencyOverrides
|
// sbt resolves dependencies every compile when using %% with dependencyOverrides
|
||||||
TaskKey[Unit]("check") := {
|
TaskKey[Unit]("check") := {
|
||||||
val s = (streams in update).value
|
val s = (streams in update).value
|
||||||
val cacheStoreFactory = s.cacheStoreFactory sub updateCacheName.value
|
|
||||||
|
val cacheDirectory = crossTarget.value / "update" / updateCacheName.value
|
||||||
|
val cacheStoreFactory = sbt.util.CacheStoreFactory.directory(cacheDirectory)
|
||||||
val module = ivyModule.value
|
val module = ivyModule.value
|
||||||
val updateConfig = updateConfiguration.value
|
val updateConfig = updateConfiguration.value
|
||||||
val extraInputHash0 = module.extraInputHash
|
val extraInputHash0 = module.extraInputHash
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue