use of org.apache.ivy.plugins.resolver.util.MDResolvedResource in project ant-ivy by apache.
the class AbstractOSGiResolver method findResource.
@Override
public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser, ModuleRevisionId mrid, Date date) {
ResolvedResource found = super.findResource(rress, rmdparser, mrid, date);
if (found == null) {
return null;
}
String osgiType = mrid.getOrganisation();
// for non bundle requirement : log the selected bundle
if (!BundleInfo.BUNDLE_TYPE.equals(osgiType)) {
// several candidates with different symbolic name : make an warning about the ambiguity
if (rress.length != 1) {
// several candidates with different symbolic name ?
Map<String, List<MDResolvedResource>> matching = new HashMap<>();
for (ResolvedResource rres : rress) {
String name = ((MDResolvedResource) rres).getResolvedModuleRevision().getDescriptor().getExtraAttribute(CAPABILITY_EXTRA_ATTR);
List<MDResolvedResource> list = matching.get(name);
if (list == null) {
list = new ArrayList<>();
matching.put(name, list);
}
list.add((MDResolvedResource) rres);
}
if (matching.keySet().size() != 1) {
if (requirementStrategy == RequirementStrategy.first) {
Message.warn("Ambiguity for the '" + osgiType + "' requirement " + mrid.getName() + ";version=" + mrid.getRevision());
for (Map.Entry<String, List<MDResolvedResource>> entry : matching.entrySet()) {
Message.warn("\t" + entry.getKey());
for (MDResolvedResource c : entry.getValue()) {
Message.warn("\t\t" + c.getRevision() + (found == c ? " (selected)" : ""));
}
}
} else if (requirementStrategy == RequirementStrategy.noambiguity) {
Message.error("Ambiguity for the '" + osgiType + "' requirement " + mrid.getName() + ";version=" + mrid.getRevision());
for (Map.Entry<String, List<MDResolvedResource>> entry : matching.entrySet()) {
Message.error("\t" + entry.getKey());
for (MDResolvedResource c : entry.getValue()) {
Message.error("\t\t" + c.getRevision() + (found == c ? " (best match)" : ""));
}
}
return null;
}
}
}
Message.info("'" + osgiType + "' requirement " + mrid.getName() + ";version=" + mrid.getRevision() + " satisfied by " + ((MDResolvedResource) found).getResolvedModuleRevision().getId().getName() + ";" + found.getRevision());
}
return found;
}
Aggregations