Search in sources :

Example 6 with IInstallableUnit

use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project gemoc-studio by eclipse.

the class PrepareInstallProfileJob method resolve.

private InstallOperation resolve(IProgressMonitor monitor, final Collection<IInstallableUnit> ius, URI[] repositories) throws CoreException {
    final InstallOperation installOperation = provisioningUI.getInstallOperation(ius, repositories);
    IStatus operationStatus = installOperation.resolveModal(new SubProgressMonitor(monitor, installableConnectors.size()));
    if (operationStatus.getSeverity() > IStatus.WARNING) {
        Activator.getDefault().getLog().log(operationStatus);
        throw new RuntimeException(getFullMessage(operationStatus));
    }
    return installOperation;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) InstallOperation(org.eclipse.equinox.p2.operations.InstallOperation) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 7 with IInstallableUnit

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

the class MetadataSerializableImplTest method testSerializeAndLoad.

@Test
public void testSerializeAndLoad() throws IOException, ProvisionException, OperationCanceledException {
    File tmpDir = createTempDir("repo");
    try {
        Set<IInstallableUnit> units = new HashSet<>(Arrays.asList(InstallableUnitUtil.createIU("org.example.test", "1.0.0")));
        MetadataSerializableImpl subject = new MetadataSerializableImpl();
        serialize(subject, units, tmpDir);
        Assert.assertEquals(units, deserialize(tmpDir));
    } finally {
        deleteRecursive(tmpDir);
    }
}
Also used : MetadataSerializableImpl(org.eclipse.tycho.p2.impl.repo.MetadataSerializableImpl) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with IInstallableUnit

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

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

the class P2ResolverTest method testSiteConflictingDependenciesResolver.

@SuppressWarnings({ "unchecked", "deprecation" })
@Test
public void testSiteConflictingDependenciesResolver() throws IOException {
    tpConfig.addP2Repository(resourceFile("repositories/e342").toURI());
    File[] projects = new File[] { // 
    resourceFile("siteresolver/bundle342"), // 
    resourceFile("siteresolver/bundle352"), // 
    resourceFile("siteresolver/feature342"), resourceFile("siteresolver/feature352") };
    addContextProject(projects[0], TYPE_ECLIPSE_PLUGIN);
    addContextProject(projects[1], TYPE_ECLIPSE_PLUGIN);
    addContextProject(projects[2], TYPE_ECLIPSE_FEATURE);
    addContextProject(projects[3], TYPE_ECLIPSE_FEATURE);
    projectToResolve = createReactorProject(resourceFile("siteresolver/site"), TYPE_ECLIPSE_UPDATE_SITE, "site");
    result = impl.collectProjectDependencies(getTargetPlatform(), projectToResolve);
    assertEquals(projects.length, result.getArtifacts().size());
    for (File project : projects) {
        assertContainLocation(result, project);
    }
    // TODO the eclipse-update-site module itself is not in the resolution result; is this needed?
    // conflicting dependency mode only collects included artifacts - the referenced non-reactor unit
    // org.eclipse.osgi is not included
    assertThat((Set<IInstallableUnit>) result.getNonReactorUnits(), not(hasItem(unitWithId("org.eclipse.osgi"))));
}
Also used : 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 10 with IInstallableUnit

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

the class TargetDefinitionResolverExecutionEnvironmentTest method testAutoGeneratedExecutionEnvironment.

@Test
public void testAutoGeneratedExecutionEnvironment() throws Exception {
    subject = targetResolverForEE("JavaSE-1.7");
    TargetDefinition definition = definitionWith(new AlternatePackageProviderLocationStub());
    Collection<IInstallableUnit> units = subject.resolveContent(definition).getUnits();
    // expect that resolver did not included a bundle providing org.w3c.dom...
    assertThat(units, not(hasItem(unit("javax.xml", "0.0.1.SNAPSHOT"))));
    // ... but instead included the configured 'a.jre' IU (which is not contained in the repository)
    assertThat(units, hasItem(unit("a.jre.javase", "1.7.0")));
    // other "a.jre" IUs from the repository shall be filtered out
    assertThat(units, not(hasItem(unitWithId("a.jre"))));
}
Also used : TargetDefinition(org.eclipse.tycho.p2.target.facade.TargetDefinition) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

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