Some helpful changes for update caching

There's a bug in sbt/util#93
This commit is contained in:
Eugene Yokota 2017-07-16 16:45:08 -04:00
parent 6a13287dba
commit bf4901f9ef
4 changed files with 60 additions and 12 deletions

View File

@ -2284,11 +2284,14 @@ object Classpaths {
import UpdateLogging.{ Full, DownloadOnly, Default }
val conf = updateConfiguration.value
val maybeUpdateLevel = (logLevel in update).?.value
maybeUpdateLevel.orElse(state0.get(logLevel.key)) match {
val conf1 = maybeUpdateLevel.orElse(state0.get(logLevel.key)) match {
case Some(Level.Debug) if conf.logging == Default => conf.withLogging(logging = Full)
case Some(_) if conf.logging == Default => conf.withLogging(logging = DownloadOnly)
case _ => conf
}
// logical clock is folded into UpdateConfiguration
conf1.withLogicalClock(LogicalClock(state0.hashCode))
}
val evictionOptions = Def.taskDyn {
@ -2307,7 +2310,6 @@ object Classpaths {
force = shouldForce,
depsUpdated = transitiveUpdate.value.exists(!_.stats.cached),
uwConfig = (unresolvedWarningConfiguration in update).value,
logicalClock = LogicalClock(state0.hashCode),
depDir = Some(dependencyCacheDirectory.value),
ewo = evictionOptions,
mavenStyle = publishMavenStyle.value,

View File

@ -9,14 +9,13 @@ import sbt.internal.util.HListFormats._
import sbt.librarymanagement._
import sbt.librarymanagement.ivy._
import sbt.librarymanagement.syntax._
import sbt.internal.util.HListFormats._
import sbt.util.{ CacheStore, CacheStoreFactory, Logger, Tracked }
object LibraryManagement {
private[sbt] object LibraryManagement {
private type UpdateInputs = IvyConfiguration :+: ModuleSettings :+: UpdateConfiguration :+: HNil
private[sbt] def cachedUpdate(
def cachedUpdate(
cacheStoreFactory: CacheStoreFactory,
label: String,
module: IvySbt#Module,
@ -26,7 +25,6 @@ object LibraryManagement {
force: Boolean,
depsUpdated: Boolean,
uwConfig: UnresolvedWarningConfiguration,
logicalClock: LogicalClock,
depDir: Option[File],
ewo: EvictionWarningOptions,
mavenStyle: Boolean,
@ -118,7 +116,9 @@ object LibraryManagement {
val settings = module.moduleSettings
val outStore = cacheStoreFactory.make("output")
val handler = if (skip && !force) skipResolve(outStore) else doResolve(outStore)
handler(ivyConfig :+: settings :+: updateConfig :+: HNil)
// Remove clock for caching purpose
val withoutClock = updateConfig.withLogicalClock(LogicalClock.unknown)
handler(ivyConfig :+: settings :+: withoutClock :+: HNil)
}
private[this] def fileUptodate(file: File, stamps: Map[File, Long]): Boolean =

View File

@ -261,10 +261,14 @@ trait Import {
type FileRepository = sbt.librarymanagement.FileRepository
val Full = sbt.librarymanagement.Full
type Full = sbt.librarymanagement.Full
val InlineConfiguration = sbt.librarymanagement.ModuleDescriptorConfiguration
type InlineConfiguration = sbt.librarymanagement.ModuleDescriptorConfiguration
val IvyScala = sbt.librarymanagement.ScalaModuleInfo
type IvyScala = sbt.librarymanagement.ScalaModuleInfo
val JCenterRepository = sbt.librarymanagement.Resolver.JCenterRepository
val JavaNet2Repository = sbt.librarymanagement.Resolver.JavaNet2Repository
type LogicalClock = sbt.librarymanagement.LogicalClock
val LogicalClock = sbt.librarymanagement.LogicalClock
type MakePomConfiguration = sbt.librarymanagement.MakePomConfiguration
val MakePomConfiguration = sbt.librarymanagement.MakePomConfiguration
val MavenCache = sbt.librarymanagement.MavenCache
@ -275,12 +279,16 @@ trait Import {
type MavenRepository = sbt.librarymanagement.MavenRepository
val ModuleConfiguration = sbt.librarymanagement.ModuleConfiguration
type ModuleConfiguration = sbt.librarymanagement.ModuleConfiguration
val ModuleDescriptorConfiguration = sbt.librarymanagement.ModuleDescriptorConfiguration
type ModuleDescriptorConfiguration = sbt.librarymanagement.ModuleDescriptorConfiguration
val ModuleID = sbt.librarymanagement.ModuleID
type ModuleID = sbt.librarymanagement.ModuleID
val ModuleInfo = sbt.librarymanagement.ModuleInfo
type ModuleInfo = sbt.librarymanagement.ModuleInfo
val ModuleReport = sbt.librarymanagement.ModuleReport
type ModuleReport = sbt.librarymanagement.ModuleReport
val ModuleSettings = sbt.librarymanagement.ModuleSettings
type ModuleSettings = sbt.librarymanagement.ModuleSettings
val OrganizationArtifactReport = sbt.librarymanagement.OrganizationArtifactReport
type OrganizationArtifactReport = sbt.librarymanagement.OrganizationArtifactReport
val Patterns = sbt.librarymanagement.Patterns
@ -315,7 +323,9 @@ trait Import {
type VersionNumber = sbt.librarymanagement.VersionNumber
type VersionNumberCompatibility = sbt.librarymanagement.VersionNumberCompatibility
// sbt.internal.librarymanagement
// sbt.librarymanagement.ivy
val InlineIvyConfiguration = sbt.librarymanagement.ivy.InlineIvyConfiguration
type InlineIvyConfiguration = sbt.librarymanagement.ivy.InlineIvyConfiguration
type IvyPaths = sbt.librarymanagement.ivy.IvyPaths
val IvyPaths = sbt.librarymanagement.ivy.IvyPaths

View File

@ -33,7 +33,12 @@ lazy val root = (project in file("."))
val s = (streams in update).value
val cacheStoreFactory = s.cacheStoreFactory sub updateCacheName.value
val module = ivyModule.value
val config = updateConfiguration.value
val updateConfig = updateConfiguration.value
val ivyConfiguration0 = module.owner.configuration
val moduleSettings0 = module.moduleSettings
val inline0 = moduleSettings0 match { case x: InlineConfiguration => x }
// Remove clock for caching purpose
val updateConfig0 = updateConfig.withLogicalClock(LogicalClock.unknown)
import sbt.librarymanagement.ivy.IvyConfiguration
import sbt.librarymanagement.{ ModuleSettings, UpdateConfiguration }
@ -47,10 +52,41 @@ lazy val root = (project in file("."))
val f: In => Unit =
Tracked.inputChanged(cacheStoreFactory make "inputs") { (inChanged: Boolean, in: In) =>
if (inChanged)
sys.error(s"Update cache is invalidated: ${module.owner.configuration}, ${module.moduleSettings}, $config")
val ivyConfiguration1 = in.head
val moduleSettings1 = in.tail.head
val inline1 = moduleSettings1 match { case x: InlineConfiguration => x }
val updateConfig1 = in.tail.tail.head
if (inChanged) {
sys.error(s"""
ivyConfiguration1 == ivyConfiguration0: ${ivyConfiguration1 == ivyConfiguration0}
ivyConfiguration1:
$ivyConfiguration1
ivyConfiguration0
$ivyConfiguration0
-----
inline1 == inline0: ${inline1 == inline0}
inline1:
$inline1
inline0
$inline0
-----
updateConfig1 == updateConfig0: ${updateConfig1 == updateConfig0}
updateConfig1:
$updateConfig1
updateConfig0
$updateConfig0
""")
}
}
f(module.owner.configuration :+: module.moduleSettings :+: config :+: HNil)
f(ivyConfiguration0 :+: (inline0: ModuleSettings) :+: updateConfig0 :+: HNil)
},
// https://github.com/sbt/sbt/issues/3226