Fix a bug in determination of the highest version of all bundles contained in a group.
authorBruno Sinou <bsinou@argeo.org>
Tue, 4 Feb 2014 21:39:07 +0000 (21:39 +0000)
committerBruno Sinou <bsinou@argeo.org>
Tue, 4 Feb 2014 21:39:07 +0000 (21:39 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6807 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/NormalizeGroup.java

index 58f832c0aa69920354660b2ca736458bea28703b..0d1eded0847b9b7131cd4bd7db42e3c5f6e28efa 100644 (file)
@@ -127,6 +127,17 @@ public class NormalizeGroup implements Runnable, SlcNames {
                                                        if (allArtifactsHighestVersion == null)
                                                                allArtifactsHighestVersion = aVersion;
 
+                                                       // BS will fail if artifacts arrive in this order
+                                                       // Name1 - V1, name2 - V3, V1 will remain the
+                                                       // allArtifactsHighestVersion
+                                                       // Fixed below
+                                                       else {
+                                                               Version currVersion = extractOsgiVersion(aVersion);
+                                                               Version highestVersion = extractOsgiVersion(allArtifactsHighestVersion);
+                                                               if (currVersion.compareTo(highestVersion) > 0)
+                                                                       allArtifactsHighestVersion = aVersion;
+                                                       }
+
                                                } else {
                                                        Version currVersion = extractOsgiVersion(aVersion);
                                                        Version currentHighestVersion = extractOsgiVersion(highestAVersion);
@@ -158,7 +169,7 @@ public class NormalizeGroup implements Runnable, SlcNames {
                        }
                }
 
-               // if version not set or empty, use the highets version
+               // if version not set or empty, use the highest version
                // useful when indexing a product maven repository where
                // all artifacts have the same version for a given release
                // => the version can then be left empty
@@ -187,10 +198,11 @@ public class NormalizeGroup implements Runnable, SlcNames {
                // indexes
                Set<Artifact> indexes = new TreeSet<Artifact>(
                                new ArtifactIdComparator());
-               Artifact indexArtifact = writeIndex(session, RepoConstants.BINARIES_ARTIFACT_ID,
-                               binaries);
+               Artifact indexArtifact = writeIndex(session,
+                               RepoConstants.BINARIES_ARTIFACT_ID, binaries);
                indexes.add(indexArtifact);
-               indexArtifact = writeIndex(session, RepoConstants.SOURCES_ARTIFACT_ID, sources);
+               indexArtifact = writeIndex(session, RepoConstants.SOURCES_ARTIFACT_ID,
+                               sources);
                indexes.add(indexArtifact);
                // sdk
                writeIndex(session, RepoConstants.SDK_ARTIFACT_ID, indexes);
@@ -403,7 +415,8 @@ public class NormalizeGroup implements Runnable, SlcNames {
                p.append("\t<groupId>").append(groupId).append("</groupId>\n");
                p.append("\t<artifactId>")
                                .append(ownSymbolicName.endsWith(".source") ? RepoConstants.SOURCES_ARTIFACT_ID
-                                               : RepoConstants.BINARIES_ARTIFACT_ID).append("</artifactId>\n");
+                                               : RepoConstants.BINARIES_ARTIFACT_ID)
+                               .append("</artifactId>\n");
                p.append("\t<version>").append(version).append("</version>\n");
                p.append("\t<type>pom</type>\n");
                p.append("\t<scope>import</scope>\n");