Search in sources :

Example 1 with IRequirement

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

the class ExtensionUpdateSite method getInstallableUnits.

// Get the list of InstallableUnits and all its requirements
protected List<IServerExtension> getInstallableUnits(IMetadataRepository repo, IQuery<IInstallableUnit> query, URI url, IProgressMonitor monitor) {
    List<IServerExtension> list = new ArrayList<IServerExtension>();
    IQueryResult<IInstallableUnit> collector = repo.query(query, monitor);
    for (IInstallableUnit iu : collector.toUnmodifiableSet()) {
        Collection<IRequirement> req = iu.getRequirements();
        if (req != null) {
            for (IRequirement requirement : req) {
                IMatchExpression<IInstallableUnit> matches = requirement.getMatches();
                query = new ExpressionMatchQuery<IInstallableUnit>(IInstallableUnit.class, matches);
                IQueryResult<IInstallableUnit> collector2 = repo.query(query, monitor);
                Iterator<IInstallableUnit> iter2 = collector2.iterator();
                while (iter2.hasNext()) {
                    IInstallableUnit iu2 = iter2.next();
                    if (!list.contains(iu2)) {
                        Extension ext = new Extension(iu2, url);
                        list.add(ext);
                    }
                }
            }
        }
    }
    return list;
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 2 with IRequirement

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

the class P2ResolverAdditionalRequirementsTest method testNullVersionInTargetDefinitionUnit.

@Test
public void testNullVersionInTargetDefinitionUnit() throws Exception {
    String nullVersion = null;
    String arbitraryVersion = "2.5.8";
    impl.addDependency(IU_TYPE, TARGET_UNIT_ID, nullVersion);
    impl.addDependency(BUNDLE_TYPE, TARGET_UNIT_ID, nullVersion);
    List<IRequirement> additionalRequirements = impl.getAdditionalRequirements();
    IInstallableUnit iu = createIU(arbitraryVersion);
    Assert.assertTrue("Given version was null; should be satisfied by any version", additionalRequirements.get(0).isMatch(iu));
    Assert.assertTrue("Given version was null; should be satisfied by any version", additionalRequirements.get(1).isMatch(iu));
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 3 with IRequirement

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

the class P2GeneratorImplTest method testOptionalImportPackage_REQUIRE.

@Test
public void testOptionalImportPackage_REQUIRE() throws Exception {
    DefaultDependencyMetadataGenerator generator = createDependencyMetadataGenerator();
    File location = new File("resources/generator/optional-import-package").getCanonicalFile();
    ArtifactMock artifactMock = new ArtifactMock(location, "optional-import-package", "optional-import-package", "0.0.1", "eclipse-plugin");
    Set<Object> units = generator.generateMetadata(artifactMock, getEnvironments(), OptionalResolutionAction.REQUIRE).getMetadata();
    assertEquals(1, units.size());
    IInstallableUnit iu = getUnit("optional-import-package", 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(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, requirement.getNamespace());
    assertEquals("org.osgi.framework", 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) DefaultDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator) Test(org.junit.Test)

Example 4 with IRequirement

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

the class P2DependencyGeneratorImplTest method rcpBundle.

@Test
public void rcpBundle() throws Exception {
    generateDependencies("rcp-bundle", PackagingType.TYPE_ECLIPSE_APPLICATION);
    assertEquals(1, units.size());
    IInstallableUnit unit = units.iterator().next();
    assertEquals("org.eclipse.tycho.p2.impl.test.rcp-bundle", unit.getId());
    assertEquals("1.0.0.qualifier", unit.getVersion().toString());
    List<IRequirement> requirements = new ArrayList<>(unit.getRequirements());
    assertEquals(2, requirements.size());
    assertNotNull(getRequiredCapability("included.bundle", requirements));
    // implicit dependencies because includeLaunchers="true"
    assertNotNull(getRequiredCapability("org.eclipse.equinox.executable.feature.group", requirements));
    assertEquals(0, artifacts.size());
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) ArrayList(java.util.ArrayList) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 5 with IRequirement

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

the class P2DependencyGeneratorImplTest method rcpNoLaunchers.

@Test
public void rcpNoLaunchers() throws Exception {
    generateDependencies("rcp-no-launchers", PackagingType.TYPE_ECLIPSE_APPLICATION);
    assertEquals(1, units.size());
    IInstallableUnit unit = units.iterator().next();
    assertEquals("org.eclipse.tycho.p2.impl.test.rcp-no-launchers", unit.getId());
    assertEquals("1.0.0.qualifier", unit.getVersion().toString());
    List<IRequirement> requirement = new ArrayList<>(unit.getRequirements());
    assertEquals(0, requirement.size());
    assertEquals(0, artifacts.size());
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) ArrayList(java.util.ArrayList) 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