Search in sources :

Example 1 with Feature

use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project tycho by eclipse.

the class P2DependencyGeneratorImplTest method rcpFeature.

@Test
public void rcpFeature() throws Exception {
    generateDependencies("rcp-feature", PackagingType.TYPE_ECLIPSE_APPLICATION);
    assertEquals(1, units.size());
    IInstallableUnit unit = units.iterator().next();
    assertEquals("org.eclipse.tycho.p2.impl.test.rcp-feature", unit.getId());
    assertEquals("1.0.0.qualifier", unit.getVersion().toString());
    assertEquals(2, unit.getRequirements().size());
    assertEquals(0, artifacts.size());
}
Also used : IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 2 with Feature

use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project tycho by eclipse.

the class ProductDependenciesAction method getRequiredCapabilities.

@Override
protected Set<IRequirement> getRequiredCapabilities() {
    Set<IRequirement> required = new LinkedHashSet<>();
    if (product.useFeatures()) {
        for (IVersionedId feature : product.getFeatures()) {
            // $NON-NLS-1$
            String id = feature.getId() + FEATURE_GROUP_IU_SUFFIX;
            Version version = feature.getVersion();
            addRequiredCapability(required, id, version, null, false);
        }
    } else {
        for (FeatureEntry plugin : ((ProductFile) product).getProductEntries()) {
            addRequiredCapability(required, plugin.getId(), Version.parseVersion(plugin.getVersion()), null, true);
        }
    }
    if (product.includeLaunchers()) {
        addRequiredCapability(required, "org.eclipse.equinox.executable.feature.group", null, null, false);
    }
    return required;
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) LinkedHashSet(java.util.LinkedHashSet) FeatureEntry(org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry) ProductFile(org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile) IVersionedId(org.eclipse.equinox.p2.metadata.IVersionedId) Version(org.eclipse.equinox.p2.metadata.Version)

Example 3 with Feature

use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project epp.mpc by eclipse.

the class MarketplaceWizard method computeNewInstallCatalogItems.

private Set<CatalogItem> computeNewInstallCatalogItems() {
    Set<CatalogItem> items = new HashSet<CatalogItem>();
    Map<CatalogItem, Collection<String>> iusByCatalogItem = new HashMap<CatalogItem, Collection<String>>();
    for (CatalogItemEntry entry : getSelectionModel().getCatalogItemEntries()) {
        List<FeatureEntry> features = entry.getChildren();
        Collection<String> featureIds = new ArrayList<String>(features.size());
        for (FeatureEntry feature : features) {
            if (feature.computeChangeOperation() == Operation.INSTALL) {
                featureIds.add(feature.getFeatureDescriptor().getId());
            }
        }
        if (!featureIds.isEmpty()) {
            iusByCatalogItem.put(entry.getItem(), featureIds);
        }
    }
    for (IInstallableUnit unit : operationIUs) {
        for (Entry<CatalogItem, Collection<String>> entry : iusByCatalogItem.entrySet()) {
            if (entry.getValue().contains(unit.getId())) {
                items.add(entry.getKey());
            }
        }
    }
    return items;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) FeatureEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry) CatalogItemEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.CatalogItemEntry) Collection(java.util.Collection) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) HashSet(java.util.HashSet)

Example 4 with Feature

use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project webtools.servertools by eclipse.

the class ExtensionUtility method addExtension.

private static void addExtension(List<IServerExtension> list, List<Extension> existing, IServerExtension newFeature, ExtensionListener listener) {
    if (alreadyExists(existing, newFeature))
        return;
    synchronized (list) {
        Version newV = newFeature.getVersion();
        IServerExtension remove = null;
        Iterator<IServerExtension> iterator = list.iterator();
        while (iterator.hasNext()) {
            IServerExtension feature = iterator.next();
            if (feature.getId().equals(newFeature.getId())) {
                if (newV == null)
                    // don't add if already exists
                    return;
                if (feature.getVersion().compareTo(newV) < 0) {
                    remove = feature;
                } else
                    // new feature is older
                    return;
            }
        }
        if (remove != null) {
            list.remove(remove);
            if (listener != null)
                listener.extensionRemoved((Extension) remove);
        }
        list.add(newFeature);
    }
    if (listener != null) {
        listener.extensionFound((Extension) newFeature);
    }
    if (listener == null && newFeature instanceof ExtensionProxy)
        serverExtension.add(createServerProxy((ExtensionProxy) newFeature));
}
Also used : Version(org.eclipse.equinox.p2.metadata.Version)

Example 5 with Feature

use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project knime-core by knime.

the class OSGIHelperTest method testGetFeature.

/**
 * Checks whether the feature for a bundle is resolved correctly.
 */
@Test
public void testGetFeature() {
    assumeThat("Gettings feature when running from SDK not possible", EclipseUtil.isRunFromSDK(), is(false));
    Bundle bundle = OSGIHelper.getBundle(NodeModel.class);
    Optional<IInstallableUnit> iUnit = OSGIHelper.getFeature(bundle);
    assertThat("Feature for NodeModel not found", iUnit.isPresent(), is(true));
    assertThat("Unexpected feature for NodeModel returned", iUnit.get().getId(), is("org.knime.features.base.feature.group"));
    bundle = OSGIHelper.getBundle("org.knime.ext.jfreechart");
    iUnit = OSGIHelper.getFeature(bundle);
    assertThat("Feature for JFreeChart not found", iUnit.isPresent(), is(true));
    assertThat("Unexpected feature for JFreeChart returned", iUnit.get().getId(), is("org.knime.features.ext.jfreechart.feature.group"));
}
Also used : Bundle(org.osgi.framework.Bundle) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Aggregations

IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)8 ArrayList (java.util.ArrayList)6 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)4 Version (org.eclipse.equinox.p2.metadata.Version)4 Test (org.junit.Test)4 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)2 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 Path (org.eclipse.core.runtime.Path)1