karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [1/2] karaf git commit: [KARAF-4997] Deal with POM dependencies in generated features.xml using generate Maven plugin
Date Thu, 02 Mar 2017 10:20:21 GMT
Repository: karaf
Updated Branches:
  refs/heads/master aa89b54e5 -> 96b8617c8


[KARAF-4997] Deal with POM dependencies in generated features.xml using generate Maven plugin


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

Branch: refs/heads/master
Commit: 9141f445960b7b48ab18175249760bac91a22fdc
Parents: aa89b54
Author: Stephen Kitt <skitt@redhat.com>
Authored: Fri Feb 24 18:14:38 2017 +0100
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Wed Mar 1 16:16:44 2017 +0100

----------------------------------------------------------------------
 .../features/GenerateDescriptorMojo.java        | 31 +++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/9141f445/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 5a152ff..329280d 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
@@ -580,7 +580,14 @@ public class GenerateDescriptorMojo extends MojoSupport {
                 Dependency dependency = new Dependency(includedFeature.getName(), includedFeature.getVersion());
                 dependency.setPrerequisite(prerequisiteFeatures.contains(dependency.getName()));
                 dependency.setDependency(dependencyFeatures.contains(dependency.getName()));
-                // We musn't de-duplicate here, we may have seen a feature in !add mode
+                // Determine what dependency we're actually going to use
+                Dependency matchingDependency = findMatchingDependency(feature.getFeature(),
dependency);
+                if (matchingDependency != null) {
+                    // The feature already has a matching dependency, merge
+                    mergeDependencies(matchingDependency, dependency);
+                    dependency = matchingDependency;
+                }
+                // We mustn't de-duplicate here, we may have seen a feature in !add mode
                 otherFeatures.put(dependency, includedFeature);
                 if (add) {
                     if (!feature.getFeature().contains(dependency)) {
@@ -598,6 +605,28 @@ public class GenerateDescriptorMojo extends MojoSupport {
         }
     }
 
+    private Dependency findMatchingDependency(List<Dependency> dependencies, Dependency
reference) {
+        String referenceName = reference.getName();
+        for (Dependency dependency : dependencies) {
+            if (referenceName.equals(dependency.getName())) {
+                return dependency;
+            }
+        }
+        return null;
+    }
+
+    private void mergeDependencies(Dependency target, Dependency source) {
+        if (target.getVersion() == null || Feature.DEFAULT_VERSION.equals(target.getVersion()))
{
+            target.setVersion(source.getVersion());
+        }
+        if (source.isDependency()) {
+            target.setDependency(true);
+        }
+        if (source.isPrerequisite()) {
+            target.setPrerequisite(true);
+        }
+    }
+
     private boolean isBundleIncludedTransitively(Feature feature, Map<Dependency, Feature>
otherFeatures,
                                                  Bundle bundle) {
         for (Dependency dependency : feature.getFeature()) {


Mime
View raw message