From 2bc3b884349b618969e8e5e69ad01f85a93a9d71 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 9 Jul 2015 01:52:00 -0400 Subject: [PATCH] Reproduce #2046 --- ivy/src/test/scala/BaseIvySpecification.scala | 5 +++ ivy/src/test/scala/CachedResolutionSpec.scala | 35 +++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/ivy/src/test/scala/BaseIvySpecification.scala b/ivy/src/test/scala/BaseIvySpecification.scala index 00cbfc013..385c3abce 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 cleanCachedResolutionCache(module: IvySbt#Module): Unit = + { + IvyActions.cleanCachedResolutionCache(module, log) + } + def ivyUpdate(module: IvySbt#Module) = ivyUpdateEither(module) match { case Right(r) => r diff --git a/ivy/src/test/scala/CachedResolutionSpec.scala b/ivy/src/test/scala/CachedResolutionSpec.scala index 8ac88740e..a64fcb8c8 100644 --- a/ivy/src/test/scala/CachedResolutionSpec.scala +++ b/ivy/src/test/scala/CachedResolutionSpec.scala @@ -12,27 +12,38 @@ class CachedResolutionSpec extends BaseIvySpecification { Resolving the unsolvable module should not work $e2 + + Resolving a module with a pseudo-conflict should + work $e3 """ def commonsIo13 = ModuleID("commons-io", "commons-io", "1.3", Some("compile")) def mavenCayennePlugin302 = ModuleID("org.apache.cayenne.plugins", "maven-cayenne-plugin", "3.0.2", Some("compile")) + def avro177 = ModuleID("org.apache.avro", "avro", "1.7.7", Some("compile")) + def dataAvro1940 = ModuleID("com.linkedin.pegasus", "data-avro", "1.9.40", Some("compile")) + def netty320 = ModuleID("org.jboss.netty", "netty", "3.2.0.Final", Some("compile")) def defaultOptions = EvictionWarningOptions.default import ShowLines._ def e1 = { - val m = module(ModuleID("com.example", "foo", "0.1.0", Some("compile")), Seq(commonsIo13), Some("2.10.2"), UpdateOptions().withCachedResolution(true)) + 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) + cleanCachedResolutionCache(m) val report2 = ivyUpdate(m) + // first resolution creates the minigraph println(report) + // second resolution reads from the minigraph println(report.configurations.head.modules.head.artifacts) report.configurations.size must_== 3 } def e2 = { - log.setLevel(Level.Debug) - val m = module(ModuleID("com.example", "foo", "0.2.0", Some("compile")), Seq(mavenCayennePlugin302), Some("2.10.2"), UpdateOptions().withCachedResolution(true)) + // log.setLevel(Level.Debug) + val m = module(ModuleID("com.example", "foo", "0.2.0", Some("compile")), + Seq(mavenCayennePlugin302), Some("2.10.2"), UpdateOptions().withCachedResolution(true)) ivyUpdateEither(m) match { case Right(_) => sys.error("this should've failed") case Left(uw) => @@ -48,4 +59,22 @@ class CachedResolutionSpec extends BaseIvySpecification { "\t\t +- com.example:foo:0.2.0")) } } + + // https://github.com/sbt/sbt/issues/2046 + // data-avro:1.9.40 depends on avro:1.4.0, which depends on netty:3.2.1.Final. + // 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) + val m = module(ModuleID("com.example", "foo", "0.3.0", Some("compile")), + Seq(avro177, dataAvro1940, netty320), + Some("2.10.2"), UpdateOptions().withCachedResolution(true)) + // first resolution creates the minigraph + val report0 = ivyUpdate(m) + cleanCachedResolutionCache(m) + // second resolution reads from the minigraph + val report = ivyUpdate(m) + val modules = report.configurations.head.modules + modules must containMatch("""org\.jboss\.netty:netty:3\.2\.0.Final""") + } }