use of org.apache.ivy.osgi.util.VersionRange in project ant-ivy by apache.
the class PluginAdapter method featureAsBundle.
public static BundleInfo featureAsBundle(URI baseUri, EclipseFeature feature) {
BundleInfo b = new BundleInfo(feature.getId(), feature.getVersion());
URI uri;
if (feature.getUrl() == null) {
uri = baseUri.resolve("features/" + feature.getId() + '_' + feature.getVersion() + ".jar");
} else {
uri = baseUri.resolve(feature.getUrl());
}
b.addArtifact(new BundleArtifact(false, uri, null));
b.setDescription(feature.getDescription());
b.setLicense(feature.getLicense());
for (EclipsePlugin plugin : feature.getPlugins()) {
BundleRequirement r = new BundleRequirement(BundleInfo.BUNDLE_TYPE, plugin.getId(), new VersionRange(plugin.getVersion()), null);
b.addRequirement(r);
}
for (Require require : feature.getRequires()) {
String id;
if (require.getPlugin() != null) {
id = require.getPlugin();
} else {
id = require.getFeature();
}
VersionRange range;
if (require.getMatch().equals("greaterOrEqual")) {
range = new VersionRange(require.getVersion());
} else {
throw new IllegalStateException("unsupported match " + require.getMatch());
}
BundleRequirement r = new BundleRequirement(BundleInfo.BUNDLE_TYPE, id, range, null);
b.addRequirement(r);
}
return b;
}
use of org.apache.ivy.osgi.util.VersionRange in project ant-ivy by apache.
the class OBRXMLWriter method buildFilter.
private static String buildFilter(BundleRequirement requirement) {
StringBuilder filter = new StringBuilder();
VersionRange v = requirement.getVersion();
if (v != null) {
appendVersion(filter, v);
}
filter.append('(');
filter.append(requirement.getType());
filter.append("=");
filter.append(requirement.getName());
filter.append(')');
if (v != null) {
filter.append(')');
}
return filter.toString();
}
use of org.apache.ivy.osgi.util.VersionRange in project ant-ivy by apache.
the class RequirementAdapter method adapt.
private void adapt(BundleInfo info, boolean optional) throws ParseException {
VersionRange range = getVersionRange();
String resolution = optional ? "optional" : null;
if (type == null) {
throw new ParseException("No requirement actually specified", 0);
}
BundleRequirement requirement = new BundleRequirement(type, name, range, resolution);
info.addRequirement(requirement);
if (BundleInfo.EXECUTION_ENVIRONMENT_TYPE.equals(type)) {
info.addExecutionEnvironment(name);
}
}
use of org.apache.ivy.osgi.util.VersionRange in project ant-ivy by apache.
the class ManifestParser method parseRequirement.
private static void parseRequirement(BundleInfo bundleInfo, Attributes mainAttributes, String headerName, String type, String versionAttr) throws ParseException {
ManifestHeaderValue elements = new ManifestHeaderValue(mainAttributes.getValue(headerName));
for (ManifestHeaderElement element : elements.getElements()) {
String resolution = element.getDirectives().get(ATTR_RESOLUTION);
String attVersion = element.getAttributes().get(versionAttr);
VersionRange version = null;
try {
version = versionRangeOf(attVersion);
} catch (ParseException e) {
throw new ParseException("The " + headerName + " has an incorrect version: " + attVersion + " (" + e.getMessage() + ")", 0);
}
for (String name : element.getValues()) {
bundleInfo.addRequirement(new BundleRequirement(type, name, version, resolution));
}
}
}
Aggregations