karaf-commits mailing list archives

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


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

Branch: refs/heads/karaf-4.0.x
Commit: e6403127bed9f0a233d96e0fded94ec9fa10777d
Parents: b970f0f
Author: Stephen Kitt <skitt@redhat.com>
Authored: Fri Feb 24 18:14:38 2017 +0100
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Thu Mar 2 11:20:41 2017 +0100

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


http://git-wip-us.apache.org/repos/asf/karaf/blob/e6403127/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 6000daf..011c734 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
@@ -560,7 +560,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)) {
@@ -578,6 +585,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