// add fragment host bundle
if (descriptor.getFragmentHost() != null) {
BundleDescriptor[] hosts = repository.resolveBundle(descriptor.getFragmentHost(), descriptor.getFragmentHostVersionRange(), true);
if (hosts.length > 0) {
BundleDescriptor fragmentHost = hosts[0];
importedBundles.add(fragmentHost);
// resolve the fragment host
resolveBundle(0, fragmentHost, repository);
} else {
if (failOnUnresolved || failOnUnresolvedMandatory) {
throw new BuildException("Cannot resolve fragment host bundle for " + descriptor.getFragmentHost());
}
}
}
resolveBundle(0, descriptor, repository);
if (unresolved.size() > 0) {
StringBuilder sb = new StringBuilder();
sb.append("Could not resolve imports:\n");
boolean mandatoryUnresolved = false;
for (ImportPackage importPackage : unresolved) {
if (importPackage.isMandatory()) {
mandatoryUnresolved = true;
sb.append('\t').append(importPackage.getName()).append(' ').append(importPackage.getVersionRange()).append('\n');
} else {
sb.append('\t').append(importPackage.getName()).append(' ').append(importPackage.getVersionRange()).append(" [optional]\n");
}
}
if (failOnUnresolved || (mandatoryUnresolved && failOnUnresolvedMandatory)) {
throw new BuildException(sb.toString());
} else {
log(sb.toString(), Project.MSG_ERR);
}
}
if (verbose) {
log("Classpath elements:");
}
if (resolveToBundle) {
for (ExportPackage exportPackage : resolved) {
BundleDescriptor exportDescriptor = exportPackage.getBundleDescriptor();
if (exportDescriptor != null) {
importedBundles.add(exportDescriptor);
}
}
} else {
for (ExportPackage exportPackage : resolved) {
BundleDescriptor exportDescriptor = exportPackage.getBundleDescriptor();
// bundle descriptor is null for system packages
if (exportDescriptor != null) {
File path = new File(repositoryDirectory, "packages" + File.separator +
exportDescriptor.getBundleSymbolicName() + File.separator + exportDescriptor.getBundleVersion() +
File.separator + exportPackage.getName() + File.separator + exportPackage.getVersion());
if (verbose) {
log("\t" + path.toString());
}
createPathElement().setPath(path.toString());