}
return merged;
}
private Feature mergeFeatureOneVersion(Set<Feature> featuresSet) {
Feature merged = new Feature("merged");
Map<String, BundleRef> bundleVersions = new HashMap<String, BundleRef>();
for (Feature feature : featuresSet) {
for (BundleRef bundle : feature.getBundles()) {
bundle.readManifest();
BundleRef existingBundle = bundleVersions.get(bundle.getBundleSymbolicName());
if (existingBundle != null) {
Version existingVersion = new Version(existingBundle.getBundleVersion());
Version newVersion = new Version(bundle.getBundleVersion());
if (newVersion.compareTo(existingVersion) > 0) {
bundleVersions.put(bundle.getBundleSymbolicName(), bundle);
}
} else {
bundleVersions.put(bundle.getBundleSymbolicName(), bundle);
}
}
}
for (BundleRef bundle : bundleVersions.values()) {
merged.getBundles().add(bundle);
}
return merged;
}