Search in sources :

Example 6 with IProvidedCapability

use of org.eclipse.equinox.p2.metadata.IProvidedCapability in project tycho by eclipse.

the class AbstractDependenciesAction method perform.

@Override
public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
    InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
    iud.setId(getId());
    iud.setVersion(getVersion());
    Set<IProvidedCapability> provided = new LinkedHashSet<>();
    addProvidedCapabilities(provided);
    provided.add(MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, iud.getId(), iud.getVersion()));
    iud.addProvidedCapabilities(provided);
    iud.addRequirements(getRequiredCapabilities());
    addProperties(iud);
    addPublisherAdvice(publisherInfo);
    processCapabilityAdvice(iud, publisherInfo);
    processInstallableUnitPropertiesAdvice(iud, publisherInfo);
    IInstallableUnit iu = MetadataFactory.createInstallableUnit(iud);
    results.addIU(iu, PublisherResult.ROOT);
    InstallableUnitDescription[] others = processAdditionalInstallableUnitsAdvice(iu, publisherInfo);
    if (others != null) {
        for (InstallableUnitDescription other : others) {
            // using PublisherResult.NON_ROOT results in these IUs appear after the primary
            // see org.eclipse.equinox.p2.publisher.PublisherResult.getIUs(String, String)
            // see org.eclipse.tycho.p2.metadata.IReactorArtifactFacade.getDependencyMetadata()
            results.addIU(MetadataFactory.createInstallableUnit(other), PublisherResult.NON_ROOT);
        }
    }
    return Status.OK_STATUS;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription) IProvidedCapability(org.eclipse.equinox.p2.metadata.IProvidedCapability) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 7 with IProvidedCapability

use of org.eclipse.equinox.p2.metadata.IProvidedCapability in project tycho by eclipse.

the class P2ResolverAdditionalRequirementsTest method createIU.

private static IInstallableUnit createIU(String version) {
    InstallableUnitDescription iud = new InstallableUnitDescription();
    iud.setId(TARGET_UNIT_ID);
    Version osgiVersion = Version.create(version);
    iud.setVersion(osgiVersion);
    List<IProvidedCapability> list = new ArrayList<>();
    list.add(MetadataFactory.createProvidedCapability(IU_NAMESPACE, TARGET_UNIT_ID, osgiVersion));
    list.add(MetadataFactory.createProvidedCapability(BUNDLE_NAMESPACE, TARGET_UNIT_ID, osgiVersion));
    iud.addProvidedCapabilities(list);
    IInstallableUnit iu = MetadataFactory.createInstallableUnit(iud);
    return iu;
}
Also used : InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription) Version(org.eclipse.equinox.p2.metadata.Version) IProvidedCapability(org.eclipse.equinox.p2.metadata.IProvidedCapability) ArrayList(java.util.ArrayList) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 8 with IProvidedCapability

use of org.eclipse.equinox.p2.metadata.IProvidedCapability in project tycho by eclipse.

the class PublisherServiceTest method testProfilePublishing.

@Test
public void testProfilePublishing() throws Exception {
    File customProfile = resourceFile("publishers/virgo-1.6.profile");
    Collection<DependencySeed> seeds = subject.publishEEProfile(customProfile);
    assertThat(seeds.size(), is(2));
    IInstallableUnit virgoProfileIU = unitsById(seeds).get("a.jre.virgo");
    assertThat(virgoProfileIU, not(nullValue()));
    Collection<IProvidedCapability> provided = virgoProfileIU.getProvidedCapabilities();
    boolean customJavaxActivationVersionFound = false;
    Version version_1_1_1 = Version.create("1.1.1");
    for (IProvidedCapability capability : provided) {
        if (PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE.equals(capability.getNamespace())) {
            if ("javax.activation".equals(capability.getName())) {
                if (version_1_1_1.equals(capability.getVersion())) {
                    customJavaxActivationVersionFound = true;
                    break;
                }
            }
        }
    }
    assertTrue("did not find capability for package javax.activation with custom version " + version_1_1_1, customJavaxActivationVersionFound);
    assertThat(unitsById(seeds).keySet(), hasItem("config.a.jre.virgo"));
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) IProvidedCapability(org.eclipse.equinox.p2.metadata.IProvidedCapability) Version(org.eclipse.equinox.p2.metadata.Version) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ResourceUtil.resourceFile(org.eclipse.tycho.p2.tools.test.util.ResourceUtil.resourceFile) File(java.io.File) Test(org.junit.Test)

Example 9 with IProvidedCapability

use of org.eclipse.equinox.p2.metadata.IProvidedCapability in project tycho by eclipse.

the class InstallableUnitMatchers method hasSelfCapability.

public static Matcher<IInstallableUnit> hasSelfCapability() {
    return new TypeSafeMatcher<IInstallableUnit>() {

        @Override
        public void describeTo(Description description) {
            description.appendText("an installable unit providing the self-capability");
        }

        @Override
        protected boolean matchesSafely(IInstallableUnit unit) {
            String name = unit.getId();
            Version version = unit.getVersion();
            for (IProvidedCapability capability : unit.getProvidedCapabilities()) {
                if (IU_CAPABILITY_NS.equals(capability.getNamespace()) && name.equals(capability.getName()) && version.equals(capability.getVersion())) {
                    return true;
                }
            }
            return false;
        }

        @Override
        protected void describeMismatchSafely(IInstallableUnit item, Description mismatchDescription) {
            mismatchDescription.appendValue(item).appendText(" has the provided capabilities ").appendValue(item.getProvidedCapabilities());
        }
    };
}
Also used : TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) Description(org.hamcrest.Description) Version(org.eclipse.equinox.p2.metadata.Version) IProvidedCapability(org.eclipse.equinox.p2.metadata.IProvidedCapability) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 10 with IProvidedCapability

use of org.eclipse.equinox.p2.metadata.IProvidedCapability in project tycho by eclipse.

the class InstallableUnitUtil method createIUWithCapabilitiesAndFilter.

public static IInstallableUnit createIUWithCapabilitiesAndFilter(String id, String version, Collection<IProvidedCapability> capabilities, String filter) {
    InstallableUnitDescription description = createIuDescription(id, version);
    description.addProvidedCapabilities(capabilities);
    description.setFilter(filter);
    return MetadataFactory.createInstallableUnit(description);
}
Also used : InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)

Aggregations

IProvidedCapability (org.eclipse.equinox.p2.metadata.IProvidedCapability)9 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)5 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)4 Version (org.eclipse.equinox.p2.metadata.Version)4 ArrayList (java.util.ArrayList)3 File (java.io.File)2 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Properties (java.util.Properties)1 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)1 VersionRange (org.eclipse.equinox.p2.metadata.VersionRange)1 AdviceFileParser (org.eclipse.equinox.p2.publisher.AdviceFileParser)1 ICapabilityAdvice (org.eclipse.equinox.p2.publisher.actions.ICapabilityAdvice)1 SystemCapability (org.eclipse.tycho.core.ee.shared.SystemCapability)1