Repository: karaf
Updated Branches:
  refs/heads/karaf-4.0.x 51f340673 -> 4dca9d734


[KARAF-5414] Handle varying feature dependency versions

When a feature stub specifies a feature dependency, and the POM
contains a slight variant of the dependency (e.g., the former
specifies a version range, the latter specifies a single version), we
currently ignore the latter when resolving the former. This patch
changes the behaviour so that feature dependencies are matched more
generously, which allows dependency information to be correctly
analysed.

Signed-off-by: Stephen Kitt <[email protected]>
(cherry picked from commit 226f9e8ed087c57b4ace236cb3fcc578a2720401)


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/4dca9d73
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/4dca9d73
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/4dca9d73

Branch: refs/heads/karaf-4.0.x
Commit: 4dca9d73400e1ad4e911e9f50e3d927fb3a42fc4
Parents: 51f3406
Author: Stephen Kitt <[email protected]>
Authored: Fri Oct 13 16:51:56 2017 +0200
Committer: Stephen Kitt <[email protected]>
Committed: Fri Oct 13 17:07:29 2017 +0200

----------------------------------------------------------------------
 .../apache/karaf/tooling/features/GenerateDescriptorMojo.java  | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/4dca9d73/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
----------------------------------------------------------------------
diff --git 
a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
 
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
index 3d7c0ad..666532a 100644
--- 
a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
+++ 
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java
@@ -589,7 +589,7 @@ public class GenerateDescriptorMojo extends MojoSupport {
         }
     }
 
-    private static Dependency findMatchingDependency(List<Dependency> 
dependencies, Dependency reference) {
+    private static Dependency findMatchingDependency(Collection<Dependency> 
dependencies, Dependency reference) {
         String referenceName = reference.getName();
         for (Dependency dependency : dependencies) {
             if (referenceName.equals(dependency.getName())) {
@@ -614,7 +614,9 @@ public class GenerateDescriptorMojo extends MojoSupport {
     private boolean isBundleIncludedTransitively(Feature feature, 
Map<Dependency, Feature> otherFeatures,
                                                  Bundle bundle) {
         for (Dependency dependency : feature.getFeature()) {
-            Feature otherFeature = otherFeatures.get(dependency);
+            // Match dependencies “generously” (we might be matching 
single-version dependencies with version ranges)
+            Dependency otherDependency = 
findMatchingDependency(otherFeatures.keySet(), dependency);
+            Feature otherFeature = otherDependency != null ? 
otherFeatures.get(otherDependency) : null;
             if (otherFeature != null) {
                 if (otherFeature.getBundle().contains(bundle) || 
isBundleIncludedTransitively(otherFeature,
                     otherFeatures, bundle)) {

Reply via email to