use of org.apache.karaf.packages.core.PackageVersion in project karaf by apache.
the class Exports method getDuplicatePackages.
private SortedMap<String, PackageVersion> getDuplicatePackages(Bundle[] bundles) {
SortedMap<String, PackageVersion> packageVersionMap = new TreeMap<>();
for (Bundle bundle : bundles) {
BundleRevision rev = bundle.adapt(BundleRevision.class);
if (rev != null) {
List<BundleCapability> caps = rev.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE);
for (BundleCapability cap : caps) {
Map<String, Object> attr = cap.getAttributes();
String packageName = (String) attr.get(BundleRevision.PACKAGE_NAMESPACE);
Version version = (Version) attr.get("version");
String key = packageName + ":" + version.toString();
PackageVersion pVer = packageVersionMap.computeIfAbsent(key, k -> new PackageVersion(packageName, version));
pVer.addBundle(bundle);
}
}
}
return packageVersionMap;
}
Aggregations