Repository: karaf
Updated Branches:
  refs/heads/karaf-4.1.x cefe274d7 -> d4c9456c5


[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/d4c9456c
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/d4c9456c
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/d4c9456c

Branch: refs/heads/karaf-4.1.x
Commit: d4c9456c5dee06d43e752608de89f6bff230ad50
Parents: cefe274
Author: Stephen Kitt <[email protected]>
Authored: Fri Oct 13 16:51:56 2017 +0200
Committer: Stephen Kitt <[email protected]>
Committed: Fri Oct 13 17:06:49 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/d4c9456c/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 9f7e07f..a36f191 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
@@ -608,7 +608,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())) {
@@ -633,7 +633,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