Search in sources :

Example 61 with IInstallableUnit

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

the class TargetPlatformBundlePublisherTest method testPomDependencyOnOtherType.

@Test
public void testPomDependencyOnOtherType() throws Exception {
    File otherFile = resourceFile("platformbuilder/pom-dependencies/other-type.xml");
    IArtifactFacade otherArtifact = new ArtifactMock(otherFile, GROUP_ID, ARTIFACT_ID, VERSION, "pom");
    IInstallableUnit unit = subject.attemptToPublishBundle(otherArtifact);
    assertNull(unit);
}
Also used : IArtifactFacade(org.eclipse.tycho.p2.metadata.IArtifactFacade) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ResourceUtil.resourceFile(org.eclipse.tycho.p2.impl.test.ResourceUtil.resourceFile) File(java.io.File) Test(org.junit.Test)

Example 62 with IInstallableUnit

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

the class TargetPlatformFactoryTest method testOtherVersionsOfReactorIUsAreFilteredFromExternalContent.

@Test
public void testOtherVersionsOfReactorIUsAreFilteredFromExternalContent() throws Exception {
    // contains trt.bundle/1.0.0.201108051343
    tpConfig.addP2Repository(ResourceUtil.resourceFile("targetresolver/v1_content").toURI());
    // reactor artifact produces a unit with same ID
    ReactorProject reactorProject = createReactorProject("artifactId", "trt.bundle/1.5.5.qualifier", null);
    P2TargetPlatform preliminaryTP = subject.createTargetPlatform(tpConfig, NOOP_EE_RESOLUTION_HANDLER, Collections.singletonList(reactorProject), null);
    assertThat(preliminaryTP.getInstallableUnits(), hasItem(unit("trt.bundle", "1.5.5.qualifier")));
    assertThat(preliminaryTP.getInstallableUnits(), not(hasItem(unit("trt.bundle", "1.0.0.201108051343"))));
    Map<IInstallableUnit, ReactorProjectIdentities> finalUnits = Collections.singletonMap(InstallableUnitUtil.createIU("trt.bundle", "1.5.5.20140216"), reactorProject.getIdentities());
    P2TargetPlatform finalTP = subject.createTargetPlatformWithUpdatedReactorUnits(preliminaryTP, finalUnits, REACTOR_ARTIFACTS);
    assertThat(finalTP.getInstallableUnits(), hasItem(unit("trt.bundle", "1.5.5.20140216")));
    assertThat(finalTP.getInstallableUnits(), not(hasItem(unit("trt.bundle", "1.0.0.201108051343"))));
}
Also used : ReactorProject(org.eclipse.tycho.ReactorProject) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ReactorProjectIdentities(org.eclipse.tycho.ReactorProjectIdentities) Test(org.junit.Test)

Example 63 with IInstallableUnit

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

the class TargetPlatformFilterEvaluator method getPackageCapabilities.

private List<IProvidedCapability> getPackageCapabilities(IInstallableUnit unit) {
    Collection<IProvidedCapability> allCapabilities = unit.getProvidedCapabilities();
    List<IProvidedCapability> packageCapabilities = new ArrayList<>(allCapabilities.size());
    for (IProvidedCapability capability : allCapabilities) {
        if (PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE.equals(capability.getNamespace())) {
            packageCapabilities.add(capability);
        }
    }
    return packageCapabilities;
}
Also used : IProvidedCapability(org.eclipse.equinox.p2.metadata.IProvidedCapability) ArrayList(java.util.ArrayList)

Example 64 with IInstallableUnit

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

the class AbstractSlicerResolutionStrategy method createStrictRequirementTo.

private static IRequirement createStrictRequirementTo(IInstallableUnit unit) {
    VersionRange strictRange = new VersionRange(unit.getVersion(), true, unit.getVersion(), true);
    int min = 1;
    int max = Integer.MAX_VALUE;
    boolean greedy = true;
    IRequirement requirement = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, unit.getId(), strictRange, unit.getFilter(), min, max, greedy);
    return requirement;
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) VersionRange(org.eclipse.equinox.p2.metadata.VersionRange)

Example 65 with IInstallableUnit

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

the class DependencyCollector method resolve.

@Override
public Collection<IInstallableUnit> resolve(Map<String, String> properties, IProgressMonitor monitor) {
    Set<IInstallableUnit> result = new LinkedHashSet<>();
    LinkedHashSet<IStatus> errors = new LinkedHashSet<>();
    if (logger.isExtendedDebugEnabled()) {
        logger.debug("Available IUs:\n" + ResolverDebugUtils.toDebugString(data.getAvailableIUs(), false));
        logger.debug("Root IUs:\n" + ResolverDebugUtils.toDebugString(data.getRootIUs(), true));
    }
    result.addAll(data.getRootIUs());
    QueryableCollection availableUIsQueryable = new QueryableCollection(data.getAvailableIUs());
    for (IInstallableUnit iu : data.getRootIUs()) {
        collectIncludedIUs(availableUIsQueryable, result, errors, iu, true, monitor);
    }
    if (logger.isExtendedDebugEnabled()) {
        logger.debug("Collected IUs:\n" + ResolverDebugUtils.toDebugString(result, false));
    }
    if (!errors.isEmpty()) {
        MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, 0, errors.toArray(new IStatus[errors.size()]), "Missing dependencies", null);
        throw new RuntimeException(status.toString(), new ProvisionException(status));
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IStatus(org.eclipse.core.runtime.IStatus) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) QueryableCollection(org.eclipse.tycho.repository.p2base.metadata.QueryableCollection) MultiStatus(org.eclipse.core.runtime.MultiStatus) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Aggregations

IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)153 Test (org.junit.Test)58 ArrayList (java.util.ArrayList)44 File (java.io.File)38 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)25 HashSet (java.util.HashSet)18 IStatus (org.eclipse.core.runtime.IStatus)18 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)16 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)15 HashMap (java.util.HashMap)13 LinkedHashSet (java.util.LinkedHashSet)11 CoreException (org.eclipse.core.runtime.CoreException)11 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)11 ResourceUtil.resourceFile (org.eclipse.tycho.p2.tools.test.util.ResourceUtil.resourceFile)11 URI (java.net.URI)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 SubMonitor (org.eclipse.core.runtime.SubMonitor)9 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)9 Status (org.eclipse.core.runtime.Status)8 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)8