Search in sources :

Example 46 with Version

use of org.eclipse.equinox.p2.metadata.Version 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 47 with Version

use of org.eclipse.equinox.p2.metadata.Version 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 48 with Version

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

the class InstallableUnitUtil method createIUArtifact.

public static IInstallableUnit createIUArtifact(String id, String version, String artifactId, String artifactVersion) {
    InstallableUnitDescription description = createIuDescription(id, version);
    description.setArtifacts(new IArtifactKey[] { new ArtifactKey("type", artifactId, Version.create(artifactVersion)) });
    return MetadataFactory.createInstallableUnit(description);
}
Also used : InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription) ArtifactKey(org.eclipse.equinox.internal.p2.metadata.ArtifactKey) IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey)

Example 49 with Version

use of org.eclipse.equinox.p2.metadata.Version 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)

Example 50 with Version

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

the class InstallableUnitUtil method createIuDescription.

private static InstallableUnitDescription createIuDescription(String id, String version) {
    InstallableUnitDescription description = new InstallableUnitDescription();
    description.setId(id);
    description.setVersion(Version.create(version));
    description.addProvidedCapabilities(createProvidedCapability(IU_CAPABILITY_NS, id, version));
    return description;
}
Also used : InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)

Aggregations

IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)25 Version (org.eclipse.equinox.p2.metadata.Version)15 Test (org.junit.Test)15 File (java.io.File)12 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)12 ArrayList (java.util.ArrayList)8 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)7 VersionRange (org.eclipse.equinox.p2.metadata.VersionRange)7 IStatus (org.eclipse.core.runtime.IStatus)5 IProvidedCapability (org.eclipse.equinox.p2.metadata.IProvidedCapability)5 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)5 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)4 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 CoreException (org.eclipse.core.runtime.CoreException)3 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)3 IOException (java.io.IOException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2