* Add requirements for an artifact to a feature
*/
private void addRequirements(Artifact artifact, Feature feature) throws ArtifactResolutionException, ArtifactNotFoundException, ZipException, IOException {
Manifest manifest = getManifest(artifact);
Collection<Clause> remaining = getRemainingImports(manifest);
Artifact previous = null;
for (Clause clause : remaining) {
Artifact add = null;
Map<VersionRange, Artifact> versions = bundleExports.get(clause.getName());
if (versions != null) {
for (VersionRange range : versions.keySet()) {
add = versions.get(range);
if (range.intersect(ManifestUtils.getVersionRange(clause)) != null) {
add = versions.get(range);
}
}
}
if (add == null) {
if (ManifestUtils.isOptional(clause)) {
// debug logging for optional dependency...
getLog().debug(String.format(" Unable to find suitable bundle for optional dependency %s (%s)",
clause.getName(), ManifestUtils.getVersionRange(clause)));
} else {
// ...but a warning for a mandatory dependency
getLog().warn(
String.format(" Unable to find suitable bundle for dependency %s (%s) (required by %s)",
clause.getName(), ManifestUtils.getVersionRange(clause), artifact.getArtifactId()));
}
} else {
if (!add.equals(previous) && feature.push(add) && !isFeature(add)) {
//and get requirements for the bundle we just added
getLog().debug(" Getting requirements for " + add);
addRequirements(add, feature);
}
}