Search in sources :

Example 26 with IRequirement

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

the class P2GeneratorImplTest method testOptionalRequireBundle_OPTIONAL.

@Test
public void testOptionalRequireBundle_OPTIONAL() throws Exception {
    DependencyMetadataGenerator generator = createDependencyMetadataGenerator();
    File location = new File("resources/generator/optional-require-bundle").getCanonicalFile();
    ArtifactMock artifactMock = new ArtifactMock(location, "optional-require-bundle", "optional-require-bundle", "0.0.1", "eclipse-plugin");
    Set<Object> units = generator.generateMetadata(artifactMock, getEnvironments(), OptionalResolutionAction.OPTIONAL).getMetadata();
    assertEquals(1, units.size());
    IInstallableUnit iu = getUnit("optional-require-bundle", units);
    assertNotNull(iu);
    List<IRequirement> requirements = new ArrayList<>(iu.getRequirements());
    assertEquals(1, requirements.size());
    IRequiredCapability requirement = (IRequiredCapability) requirements.get(0);
    assertFalse(requirement.isGreedy());
    assertEquals(0, requirement.getMin());
    assertEquals(1, requirement.getMax());
    assertEquals(BundlesAction.CAPABILITY_NS_OSGI_BUNDLE, requirement.getNamespace());
    assertEquals("org.eclipse.osgi", requirement.getName());
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) ArrayList(java.util.ArrayList) IRequiredCapability(org.eclipse.equinox.internal.p2.metadata.IRequiredCapability) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) DefaultDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator) DependencyMetadataGenerator(org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator) Test(org.junit.Test)

Example 27 with IRequirement

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

the class P2GeneratorImplTest method testOptionalRequireBundleP2inf_REQUIRE.

@Test
public void testOptionalRequireBundleP2inf_REQUIRE() throws Exception {
    DependencyMetadataGenerator generator = createDependencyMetadataGenerator();
    File location = new File("resources/generator/optional-reqiure-bundle-p2inf").getCanonicalFile();
    ArtifactMock artifactMock = new ArtifactMock(location, "optional-reqiure-bundle-p2inf", "optional-reqiure-bundle-p2inf", "0.0.1", "eclipse-plugin");
    Set<Object> units = generator.generateMetadata(artifactMock, getEnvironments(), OptionalResolutionAction.REQUIRE).getMetadata();
    assertEquals(1, units.size());
    IInstallableUnit iu = getUnit("optional-reqiure-bundle-p2inf", units);
    assertNotNull(iu);
    List<IRequirement> requirements = new ArrayList<>(iu.getRequirements());
    assertEquals(1, requirements.size());
    IRequiredCapability requirement = (IRequiredCapability) requirements.get(0);
    assertTrue(requirement.isGreedy());
    assertEquals(1, requirement.getMin());
    assertEquals(1, requirement.getMax());
    assertEquals(BundlesAction.CAPABILITY_NS_OSGI_BUNDLE, requirement.getNamespace());
    assertEquals("org.eclipse.osgi", requirement.getName());
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) ArrayList(java.util.ArrayList) IRequiredCapability(org.eclipse.equinox.internal.p2.metadata.IRequiredCapability) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) DefaultDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator) DependencyMetadataGenerator(org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator) Test(org.junit.Test)

Example 28 with IRequirement

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

the class FeatureDependenciesAction method getRequiredCapabilities.

@Override
protected Set<IRequirement> getRequiredCapabilities() {
    Set<IRequirement> required = new LinkedHashSet<>();
    if (feature.getLicenseFeature() != null) {
        String id = feature.getLicenseFeature() + FEATURE_GROUP_IU_SUFFIX;
        VersionRange range = getVersionRange(createVersion(feature.getLicenseFeatureVersion()));
        required.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, range, null, false, /* optional */
        false));
    }
    for (FeatureEntry entry : feature.getEntries()) {
        if (entry.isPatch()) {
            // target platform
            continue;
        }
        VersionRange range;
        if (entry.isRequires()) {
            range = getVersionRange(entry);
        } else {
            range = getVersionRange(createVersion(entry.getVersion()));
        }
        String id = getInstallableUnitId(entry);
        // TODO 391283 without enhancement 391283, additional filters will always evaluate to false -> ignore for now
        boolean optional = entry.isOptional();
        required.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, range, createFilter(entry), optional, false));
    }
    return required;
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) LinkedHashSet(java.util.LinkedHashSet) FeatureEntry(org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry) VersionRange(org.eclipse.equinox.p2.metadata.VersionRange)

Example 29 with IRequirement

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

the class P2DependencyGeneratorImplTest method feature_with_p2_inf.

@Test
public void feature_with_p2_inf() throws Exception {
    generateDependencies("feature-p2-inf", PackagingType.TYPE_ECLIPSE_FEATURE);
    List<IInstallableUnit> units = new ArrayList<>(this.units);
    // no feature.jar IU because dependencyOnly=true
    assertEquals(2, units.size());
    // TODO
    IInstallableUnit unit = units.get(0);
    assertEquals("org.eclipse.tycho.p2.impl.test.feature-p2-inf.feature.group", unit.getId());
    assertEquals("1.0.0.qualifier", unit.getVersion().toString());
    List<IRequirement> requirements = new ArrayList<>(unit.getRequirements());
    assertEquals(1, requirements.size());
    IRequiredCapability requirement = (IRequiredCapability) requirements.get(0);
    assertEquals(IInstallableUnit.NAMESPACE_IU_ID, requirement.getNamespace());
    assertEquals("required.p2.inf", requirement.getName());
    assertEquals(0, artifacts.size());
    assertEquals("iu.p2.inf", units.get(1).getId());
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) ArrayList(java.util.ArrayList) IRequiredCapability(org.eclipse.equinox.internal.p2.metadata.IRequiredCapability) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 30 with IRequirement

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

the class P2DependencyGeneratorImplTest method feature.

@Test
public void feature() throws Exception {
    generateDependencies("feature", PackagingType.TYPE_ECLIPSE_FEATURE);
    // no feature.jar IU because dependencyOnly=true
    assertEquals(1, units.size());
    IInstallableUnit unit = units.iterator().next();
    assertEquals("org.eclipse.tycho.p2.impl.test.feature.feature.group", unit.getId());
    assertEquals("1.0.0.qualifier", unit.getVersion().toString());
    assertEquals(DEFAULT_CLASSIFIER, unit.getProperty(RepositoryLayoutHelper.PROP_CLASSIFIER));
    List<IRequirement> requirements = new ArrayList<>(unit.getRequirements());
    assertEquals(6, requirements.size());
    IRequiredCapability capability = getRequiredCapability("another.required.feature.feature.group", requirements);
    IMatchExpression<IInstallableUnit> matches = capability.getMatches();
    assertEquals("providedCapabilities.exists(x | x.name == $0 && x.namespace == $1 && x.version >= $2 && x.version < $3)", matches.toString());
    assertEquals(Version.parseVersion("1.0.0"), matches.getParameters()[2]);
    assertEquals(Version.parseVersion("2.0.0"), matches.getParameters()[3]);
    assertEquals(0, artifacts.size());
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) ArrayList(java.util.ArrayList) IRequiredCapability(org.eclipse.equinox.internal.p2.metadata.IRequiredCapability) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Aggregations

IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)31 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)23 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)17 VersionRange (org.eclipse.equinox.p2.metadata.VersionRange)11 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)8 File (java.io.File)7 DefaultDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator)6 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)6 LinkedHashSet (java.util.LinkedHashSet)5 SourcesBundleDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator)5 DependencyMetadataGenerator (org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator)5 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)4 List (java.util.List)2 Map (java.util.Map)2 IStatus (org.eclipse.core.runtime.IStatus)2 MultiStatus (org.eclipse.core.runtime.MultiStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Version (org.eclipse.equinox.p2.metadata.Version)2 FeatureEntry (org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry)2