Repository: karaf
Updated Branches:
  refs/heads/master 2aeb00bdb -> 226f9e8ed


[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]>


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

Branch: refs/heads/master
Commit: 226f9e8ed087c57b4ace236cb3fcc578a2720401
Parents: 0f836ac
Author: Stephen Kitt <[email protected]>
Authored: Fri Oct 13 16:51:56 2017 +0200
Committer: Stephen Kitt <[email protected]>
Committed: Fri Oct 13 16:53:42 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/226f9e8e/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 d84b2a1..896c128 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
@@ -604,7 +604,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())) {
@@ -629,7 +629,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