You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:16:16 UTC

[sling-maven-launchpad-plugin] 04/29: SLING-2212 : When merging bundle lists, the highest version should win

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag maven-launchpad-plugin-2.1.2
in repository https://gitbox.apache.org/repos/asf/sling-maven-launchpad-plugin.git

commit 1a827c3d125bd43e408f82558131b6e1a116367e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Sep 9 09:14:25 2011 +0000

    SLING-2212 : When merging bundle lists, the highest version should win
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/maven/maven-launchpad-plugin@1167055 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                                    |  5 +++++
 .../maven/projectsupport/bundlelist/BaseBundleList.java    | 14 +++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index c138789..2cb1d42 100644
--- a/pom.xml
+++ b/pom.xml
@@ -162,6 +162,11 @@
             <version>1.0</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.maven.shared</groupId>
+            <artifactId>maven-osgi</artifactId>
+            <version>0.2.0</version>
+        </dependency>
+        <dependency>
             <groupId>org.drools</groupId>
             <artifactId>drools-compiler</artifactId>
             <version>5.1.1</version>
diff --git a/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java b/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java
index 85cc7a8..1c7bc56 100644
--- a/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java
+++ b/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java
@@ -18,9 +18,12 @@ package org.apache.sling.maven.projectsupport.bundlelist;
 
 import java.util.List;
 
+import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
+import org.apache.maven.shared.osgi.Maven2OsgiConverter;
 import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle;
 import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList;
 import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel;
+import org.osgi.framework.Version;
 
 public abstract class BaseBundleList {
 
@@ -78,7 +81,14 @@ public abstract class BaseBundleList {
     private void add(StartLevel mergeStartLevel, Bundle newBnd) {
         Bundle current = get(newBnd, false);
         if (current != null) {
-            current.setVersion(newBnd.getVersion());
+            final Maven2OsgiConverter converter = new DefaultMaven2OsgiConverter();
+
+            // compare versions, the highest will be used
+            final Version newVersion = new Version(converter.getVersion(newBnd.getVersion()));
+            final Version oldVersion = new Version(converter.getVersion(current.getVersion()));
+            if ( newVersion.compareTo(oldVersion) > 0 ) {
+                current.setVersion(newBnd.getVersion());
+            }
         } else {
             StartLevel startLevel = null;
             if ( mergeStartLevel == null || newBnd.getStartLevel() != 0) {
@@ -88,7 +98,6 @@ public abstract class BaseBundleList {
             }
             startLevel.getBundles().add(newBnd);
         }
-
     }
 
     private StartLevel getOrCreateStartLevel(int startLevel) {
@@ -103,5 +112,4 @@ public abstract class BaseBundleList {
         sl.setRawLevel(startLevel);
         return sl;
     }
-
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.