Search in sources :

Example 1 with BundleRequirement

use of org.apache.ivy.osgi.core.BundleRequirement 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;
}
Also used : Require(org.apache.ivy.osgi.updatesite.xml.Require) BundleInfo(org.apache.ivy.osgi.core.BundleInfo) BundleArtifact(org.apache.ivy.osgi.core.BundleArtifact) VersionRange(org.apache.ivy.osgi.util.VersionRange) URI(java.net.URI) EclipsePlugin(org.apache.ivy.osgi.updatesite.xml.EclipsePlugin) BundleRequirement(org.apache.ivy.osgi.core.BundleRequirement)

Example 2 with BundleRequirement

use of org.apache.ivy.osgi.core.BundleRequirement in project ant-ivy by apache.

the class OBRXMLWriter method saxBundleInfo.

private static void saxBundleInfo(BundleInfo bundleInfo, ContentHandler handler) throws SAXException {
    AttributesImpl atts = new AttributesImpl();
    addAttr(atts, ResourceHandler.SYMBOLIC_NAME, bundleInfo.getSymbolicName());
    addAttr(atts, ResourceHandler.VERSION, bundleInfo.getRawVersion());
    for (BundleArtifact artifact : bundleInfo.getArtifacts()) {
        if (!artifact.isSource()) {
            addAttr(atts, ResourceHandler.URI, bundleInfo.getArtifacts().get(0).getUri().toString());
            break;
        }
    }
    handler.startElement("", ResourceHandler.RESOURCE, ResourceHandler.RESOURCE, atts);
    for (BundleArtifact artifact : bundleInfo.getArtifacts()) {
        if (artifact.isSource()) {
            startElement(handler, ResourceSourceHandler.SOURCE);
            characters(handler, artifact.getUri().toString());
            endElement(handler, ResourceSourceHandler.SOURCE);
            break;
        }
    }
    for (BundleCapability capability : bundleInfo.getCapabilities()) {
        saxCapability(capability, handler);
    }
    for (BundleRequirement requirement : bundleInfo.getRequirements()) {
        saxRequirement(requirement, handler);
    }
    handler.endElement("", ResourceHandler.RESOURCE, ResourceHandler.RESOURCE);
    handler.characters("\n".toCharArray(), 0, 1);
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) BundleArtifact(org.apache.ivy.osgi.core.BundleArtifact) BundleCapability(org.apache.ivy.osgi.core.BundleCapability) BundleRequirement(org.apache.ivy.osgi.core.BundleRequirement)

Example 3 with BundleRequirement

use of org.apache.ivy.osgi.core.BundleRequirement 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);
    }
}
Also used : VersionRange(org.apache.ivy.osgi.util.VersionRange) ParseException(java.text.ParseException) BundleRequirement(org.apache.ivy.osgi.core.BundleRequirement)

Aggregations

BundleRequirement (org.apache.ivy.osgi.core.BundleRequirement)3 BundleArtifact (org.apache.ivy.osgi.core.BundleArtifact)2 VersionRange (org.apache.ivy.osgi.util.VersionRange)2 URI (java.net.URI)1 ParseException (java.text.ParseException)1 BundleCapability (org.apache.ivy.osgi.core.BundleCapability)1 BundleInfo (org.apache.ivy.osgi.core.BundleInfo)1 EclipsePlugin (org.apache.ivy.osgi.updatesite.xml.EclipsePlugin)1 Require (org.apache.ivy.osgi.updatesite.xml.Require)1 AttributesImpl (org.xml.sax.helpers.AttributesImpl)1