fixes #1711, #1716. Fixes configuration remapping

The actual change is one line at line 64. nextConfMap takes dep instead
of dd.
This commit is contained in:
Eugene Yokota 2014-11-10 01:10:37 -05:00
parent 4fd5d505f1
commit 867e2b7a18
2 changed files with 33 additions and 13 deletions

View File

@ -57,15 +57,18 @@ private[sbt] class CachedResolutionResolveCache() {
def expandInternalDeps(dep: DependencyDescriptor, confMap: Map[String, Array[String]]): Vector[DependencyDescriptor] =
internalDependency(dep) match {
case Some(internal) =>
log.debug(s""":::: found internal dependency ${internal.getResolvedModuleRevisionId}""")
val allConfigurations: Vector[String] =
(if (confMap.isEmpty) nextConfMap(dep, confMap)
else confMap).values.flatten.toList.distinct.toVector
directDependencies(internal) filter { dd =>
val next = nextConfMap(dep, confMap)
val directs = directDependencies(internal) filter { dd =>
allConfigurations exists { conf => !dd.getDependencyConfigurations(conf).isEmpty }
} flatMap { dd => expandInternalDeps(dd, nextConfMap(dd, confMap)) }
}
directs flatMap { dd => expandInternalDeps(dd, next) }
case _ =>
if (confMap.isEmpty) Vector(dep)
else Vector(remapConfigurations(dep, confMap))
else Vector(remapConfigurations(dep, confMap, log))
}
def internalDependency(dep: DependencyDescriptor): Option[ModuleDescriptor] =
prOpt match {
@ -90,15 +93,17 @@ private[sbt] class CachedResolutionResolveCache() {
}
})
}
def remapConfigurations(dd0: DependencyDescriptor, confMap: Map[String, Array[String]]): DependencyDescriptor =
def remapConfigurations(dd0: DependencyDescriptor, confMap: Map[String, Array[String]], log: Logger): DependencyDescriptor =
{
log.debug(s""":::: remapping configuration of ${dd0} with ${confMap.toList map { case (k, v) => (k, v.toList) }}""")
val dd = new DefaultDependencyDescriptor(md0, dd0.getDependencyRevisionId, dd0.getDynamicConstraintDependencyRevisionId,
dd0.isForce, dd0.isChanging, dd0.isTransitive)
val moduleConfigurations = dd0.getModuleConfigurations.toVector
for {
moduleConf <- dd0.getModuleConfigurations.toVector
moduleConf <- moduleConfigurations
(rootModuleConf, vs) <- confMap.toSeq
} if (vs contains moduleConf) {
// moduleConf in dd0 maps to rootModuleConf in dd
log.debug(s""":::: ${dd0}: $moduleConf maps to $rootModuleConf""")
dd0.getDependencyConfigurations(moduleConf) foreach { conf =>
dd.addDependencyConfiguration(rootModuleConf, conf)
}
@ -112,6 +117,7 @@ private[sbt] class CachedResolutionResolveCache() {
dd.addDependencyArtifact(rootModuleConf, dad)
}
}
log.debug(s""":::: remapped dd: $dd""")
dd
}
directDependencies(md0) flatMap { dep => expandInternalDeps(dep, Map()) }

View File

@ -16,8 +16,16 @@ lazy val classifierTest = project.
)
)
lazy val transitiveTest = project.
settings(commonSettings: _*).
settings(
libraryDependencies := Seq(
"junit" % "junit" % "4.11" % "test"
)
)
lazy val a = project.
dependsOn(classifierTest).
dependsOn(classifierTest, transitiveTest % "test->test").
settings(commonSettings: _*).
settings(
updateOptions := updateOptions.value.withCachedResolution(true),
@ -26,21 +34,19 @@ lazy val a = project.
"com.typesafe.akka" %% "akka-remote" % "2.3.4" exclude("com.typesafe.akka", "akka-actor_2.10"),
"net.databinder" %% "unfiltered-uploads" % "0.8.0",
"commons-io" % "commons-io" % "1.3",
"com.typesafe" % "config" % "0.4.9-SNAPSHOT",
"junit" % "junit" % "4.11" % "test"
"com.typesafe" % "config" % "0.4.9-SNAPSHOT"
)
)
lazy val b = project.
dependsOn(classifierTest).
dependsOn(classifierTest, transitiveTest % "test->test").
settings(commonSettings: _*).
settings(
libraryDependencies := Seq(
"com.typesafe.akka" %% "akka-remote" % "2.3.4" exclude("com.typesafe.akka", "akka-actor_2.10"),
"net.databinder" %% "unfiltered-uploads" % "0.8.0",
"commons-io" % "commons-io" % "1.3",
"com.typesafe" % "config" % "0.4.9-SNAPSHOT",
"junit" % "junit" % "4.11" % "test"
"com.typesafe" % "config" % "0.4.9-SNAPSHOT"
)
)
@ -59,6 +65,9 @@ lazy val root = (project in file(".")).
val acp = (externalDependencyClasspath in Compile in a).value.sortBy {_.data.getName}
val bcp = (externalDependencyClasspath in Compile in b).value.sortBy {_.data.getName}
val ccp = (externalDependencyClasspath in Compile in c).value.sortBy {_.data.getName} filterNot { _.data.getName == "demo_2.10.jar"}
val atestcp = (externalDependencyClasspath in Test in a).value.sortBy {_.data.getName}
val btestcp = (externalDependencyClasspath in Test in b).value.sortBy {_.data.getName}
val ctestcp = (externalDependencyClasspath in Test in c).value.sortBy {_.data.getName} filterNot { _.data.getName == "demo_2.10.jar"}
if (ctestcp exists { _.data.getName contains "junit-4.11.jar" }) {
sys.error("junit found when it should be excluded: " + ctestcp.toString)
@ -67,6 +76,11 @@ lazy val root = (project in file(".")).
else sys.error("Different classpaths are found:" +
"\n - a (cached) " + acp.toString +
"\n - b (plain) " + bcp.toString +
"\n - c (inter-project) " + ccp.toString)
"\n - c (inter-project) " + ccp.toString)
if (atestcp == btestcp) ()
else sys.error("Different classpaths are found:" +
"\n - a test (cached) " + atestcp.toString +
"\n - b test (plain) " + btestcp.toString)
}
)