in multiversion/src/main/scala/multiversion/commands/ExportCommand.scala [266:288]
private def selectVersionsFromIndex(
thirdparty: ThirdpartyConfig,
index: ResolutionIndex
): ThirdpartyConfig = {
val updatedDependencies = thirdparty.dependencies
.foldLeft(Map.empty[DependencyId, DependencyConfig]) { case (deps, originalDependency) =>
val dep = originalDependency.toCoursierDependency(thirdparty.scala)
val reconciledVersion = index.reconciledVersion(dep)
val reconciledDependency = originalDependency.copy(version = reconciledVersion)
val reconciledId = reconciledDependency.id
// Different dependencies may reconcile to the same version. In this case, make sure
// we don't lose the targets they originate from.
deps.get(reconciledId) match {
case None => deps + (reconciledId -> reconciledDependency)
case Some(existing) =>
val allTargets = (existing.targets ++ reconciledDependency.targets).distinct
deps + (reconciledId -> existing.copy(targets = allTargets))
}
}
.values
.toList
thirdparty.copy(dependencies = updatedDependencies)
}