From a1ac6c6eaae0ca16ecd70e3532e81173697fcea3 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 18 Jul 2015 02:17:25 -0400 Subject: [PATCH] Fixes #2105/#1763. Cached resolution: removes duplicate callers during merge --- .../scala/sbt/ivyint/CachedResolutionResolveEngine.scala | 6 ++++-- ivy/src/test/scala/BaseIvySpecification.scala | 5 +++++ ivy/src/test/scala/CachedResolutionSpec.scala | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ivy/src/main/scala/sbt/ivyint/CachedResolutionResolveEngine.scala b/ivy/src/main/scala/sbt/ivyint/CachedResolutionResolveEngine.scala index 2a2b83b86..07a157107 100644 --- a/ivy/src/main/scala/sbt/ivyint/CachedResolutionResolveEngine.scala +++ b/ivy/src/main/scala/sbt/ivyint/CachedResolutionResolveEngine.scala @@ -27,7 +27,7 @@ private[sbt] object CachedResolutionResolveCache { def createID(organization: String, name: String, revision: String) = ModuleRevisionId.newInstance(organization, name, revision) def sbtOrgTemp = JsonUtil.sbtOrgTemp - def graphVersion = "0.13.9B" + def graphVersion = "0.13.9C" val buildStartup: Long = System.currentTimeMillis lazy val todayStr: String = toYyyymmdd(buildStartup) lazy val tomorrowStr: String = toYyyymmdd(buildStartup + (1 day).toMillis) @@ -470,8 +470,10 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine { def mergeModuleReports(org: String, name: String, version: String, xs: Seq[ModuleReport]): ModuleReport = { val completelyEvicted = xs forall { _.evicted } val allCallers = xs flatMap { _.callers } + // Caller info is often repeated across the subprojects. We only need ModuleID info for later, so xs.head is ok. + val distinctByModuleId = allCallers.groupBy({ _.caller }).toList map { case (k, xs) => xs.head } val allArtifacts = (xs flatMap { _.artifacts }).distinct - xs.head.copy(artifacts = allArtifacts, evicted = completelyEvicted, callers = allCallers) + xs.head.copy(artifacts = allArtifacts, evicted = completelyEvicted, callers = distinctByModuleId) } val merged = (modules groupBy { m => (m.module.organization, m.module.name, m.module.revision) }).toSeq.toVector flatMap { case ((org, name, version), xs) => diff --git a/ivy/src/test/scala/BaseIvySpecification.scala b/ivy/src/test/scala/BaseIvySpecification.scala index 385c3abce..55efa60fa 100644 --- a/ivy/src/test/scala/BaseIvySpecification.scala +++ b/ivy/src/test/scala/BaseIvySpecification.scala @@ -59,6 +59,11 @@ trait BaseIvySpecification extends Specification { IvyActions.updateEither(module, config, UnresolvedWarningConfiguration(), LogicalClock.unknown, Some(currentDependency), log) } + def cleanIvyCache: Unit = + { + IO.delete(currentTarget / "cache") + } + def cleanCachedResolutionCache(module: IvySbt#Module): Unit = { IvyActions.cleanCachedResolutionCache(module, log) diff --git a/ivy/src/test/scala/CachedResolutionSpec.scala b/ivy/src/test/scala/CachedResolutionSpec.scala index a64fcb8c8..16021b15c 100644 --- a/ivy/src/test/scala/CachedResolutionSpec.scala +++ b/ivy/src/test/scala/CachedResolutionSpec.scala @@ -28,6 +28,7 @@ class CachedResolutionSpec extends BaseIvySpecification { import ShowLines._ def e1 = { + cleanIvyCache val m = module(ModuleID("com.example", "foo", "0.1.0", Some("compile")), Seq(commonsIo13), Some("2.10.2"), UpdateOptions().withCachedResolution(true)) val report = ivyUpdate(m) @@ -65,7 +66,8 @@ class CachedResolutionSpec extends BaseIvySpecification { // avro:1.4.0 will be evicted by avro:1.7.7. // #2046 says that netty:3.2.0.Final is incorrectly evicted by netty:3.2.1.Final def e3 = { - log.setLevel(Level.Debug) + // log.setLevel(Level.Debug) + cleanIvyCache val m = module(ModuleID("com.example", "foo", "0.3.0", Some("compile")), Seq(avro177, dataAvro1940, netty320), Some("2.10.2"), UpdateOptions().withCachedResolution(true))