MultiMap<String,String> usedBy = new MultiMap<String,String>();
Map<String,Set<Version>> bundleVersions = new HashMap<String,Set<Version>>();
for (File inputFile : files) {
if (inputFile.exists()) {
try {
Builder builder;
if (inputFile.getName().endsWith(".bnd")) {
builder = setupBuilderForBndFile(inputFile);
} else {
builder = setupBuilderForJarFile(inputFile);
}
if (builder == null)
continue;
builderMap.put(inputFile, builder);
mergeCapabilities(exports, usedBy, bundleVersions, builder);
} catch (CoreException e) {
logger.logError("Error in bnd resolution analysis.", e);
} catch (Exception e) {
logger.logError("Error in bnd resolution analysis.", e);
}
}
}
// Merge together all the requirements, with access to the available
// capabilities
Map<String,List<ImportPackage>> imports = new HashMap<String,List<ImportPackage>>();
Map<String,List<RequiredBundle>> requiredBundles = new HashMap<String,List<RequiredBundle>>();
for (Entry<File,Builder> entry : builderMap.entrySet()) {
Builder builder = entry.getValue();
try {
mergeRequirements(imports, exports, usedBy, requiredBundles, bundleVersions, builder);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// Generate the final results
Set<File> resultFiles = builderMap.keySet();
resultFileArray = resultFiles.toArray(new File[resultFiles.size()]);
importResults = new ArrayList<ImportPackage>();
for (List<ImportPackage> list : imports.values()) {
importResults.addAll(list);
}
exportResults = new ArrayList<ExportPackage>();
for (List<ExportPackage> list : exports.values()) {
exportResults.addAll(list);
}
requiredBundleResults = new ArrayList<RequiredBundle>();
for (List<RequiredBundle> list : requiredBundles.values()) {
requiredBundleResults.addAll(list);
}
// Cleanup
for (Builder builder : builderMap.values()) {
builder.close();
}
// showResults(resultFileArray, importResults, exportResults);
return Status.OK_STATUS;
}