Better handling of properties in dependency management / profiles

Test fix in the next commit prevents regressions
This commit is contained in:
Alexandre Archambault 2016-07-03 16:34:12 +02:00
parent 5146be5c39
commit 3a6cdb20fb
No known key found for this signature in database
GPG Key ID: 14640A6839C263A9
1 changed files with 23 additions and 17 deletions

View File

@ -851,17 +851,27 @@ final case class Resolution(
// 1.2 made from Pom.scala (TODO look at the very details?)
// 1.3 & 1.4 (if only vaguely so)
val dependencies0 = addDependencies(
(project.dependencies +: profiles0.map(_.dependencies)).map(withProperties(_, approxProperties))
)
val dependenciesMgmt0 = addDependencies(
(project.dependencyManagement +: profiles0.map(_.dependencyManagement)).map(withProperties(_, approxProperties))
)
val properties0 =
(project.properties /: profiles0) { (acc, p) =>
acc ++ p.properties
}
val project0 = project.copy(
properties = project.parent // belongs to 1.5 & 1.6
.filter(projectCache.contains)
.map(projectCache(_)._2.properties)
.fold(properties0)(_ ++ properties0)
)
val propertiesMap0 = propertiesMap(projectProperties(project0))
val dependencies0 = addDependencies(
(project0.dependencies +: profiles0.map(_.dependencies)).map(withProperties(_, propertiesMap0))
)
val dependenciesMgmt0 = addDependencies(
(project0.dependencyManagement +: profiles0.map(_.dependencyManagement)).map(withProperties(_, propertiesMap0))
)
val deps0 =
dependencies0
.collect { case ("import", dep) =>
@ -871,7 +881,7 @@ final case class Resolution(
.collect { case ("import", dep) =>
dep.moduleVersion
} ++
project.parent // belongs to 1.5 & 1.6
project0.parent // belongs to 1.5 & 1.6
val deps = deps0.filter(projectCache.contains)
@ -879,35 +889,31 @@ final case class Resolution(
.map(projectCache(_)._2)
val depMgmt = (
project.dependencyManagement +: (
project0.dependencyManagement +: (
profiles0.map(_.dependencyManagement) ++
projs.map(_.dependencyManagement)
)
)
.map(withProperties(_, approxProperties))
.map(withProperties(_, propertiesMap0))
.foldLeft(Map.empty[DepMgmt.Key, (String, Dependency)])(DepMgmt.addSeq)
val depsSet = deps.toSet
project.copy(
version = substituteProps(project.version, approxProperties),
project0.copy(
version = substituteProps(project0.version, propertiesMap0),
dependencies =
dependencies0
.filterNot{case (config, dep) =>
config == "import" && depsSet(dep.moduleVersion)
} ++
project.parent // belongs to 1.5 & 1.6
project0.parent // belongs to 1.5 & 1.6
.filter(projectCache.contains)
.toSeq
.flatMap(projectCache(_)._2.dependencies),
dependencyManagement = depMgmt.values.toSeq
.filterNot{case (config, dep) =>
config == "import" && depsSet(dep.moduleVersion)
},
properties = project.parent // belongs to 1.5 & 1.6
.filter(projectCache.contains)
.map(projectCache(_)._2.properties)
.fold(properties0)(properties0 ++ _)
}
)
}