Search in sources :

Example 1 with P2ResolutionResult

use of org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult in project tycho by eclipse.

the class P2ResolverTest method testProductMultienvP2Inf.

@Test
public void testProductMultienvP2Inf() throws Exception {
    List<TargetEnvironment> environments = new ArrayList<>();
    environments.add(new TargetEnvironment("linux", "gtk", "x86_64"));
    environments.add(new TargetEnvironment("macosx", "cocoa", "x86_64"));
    impl.setEnvironments(environments);
    String artifactId = "product.multienv.p2-inf";
    projectToResolve = createReactorProject(resourceFile("resolver/product.multienv.p2-inf"), TYPE_ECLIPSE_REPOSITORY, artifactId);
    List<P2ResolutionResult> results = impl.resolveDependencies(getTargetPlatform(), projectToResolve);
    assertEquals(2, results.size());
    P2ResolutionResult linux = results.get(0);
    List<Entry> linuxEntries = new ArrayList<>(linux.getArtifacts());
    assertEquals(1, linuxEntries.size());
    assertEquals(1, linuxEntries.get(0).getInstallableUnits().size());
    assertEquals(0, linux.getNonReactorUnits().size());
    P2ResolutionResult macosx = results.get(1);
    List<Entry> macosxEntries = new ArrayList<>(macosx.getArtifacts());
    assertEquals(1, macosxEntries.size());
    assertEquals(2, macosxEntries.get(0).getInstallableUnits().size());
    assertEquals(0, macosx.getNonReactorUnits().size());
}
Also used : Entry(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry) ArrayList(java.util.ArrayList) P2ResolutionResult(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) Test(org.junit.Test)

Example 2 with P2ResolutionResult

use of org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult in project tycho by eclipse.

the class P2ResolverTest method testFeatureMultienvP2Inf.

@Test
public void testFeatureMultienvP2Inf() throws Exception {
    List<TargetEnvironment> environments = new ArrayList<>();
    environments.add(new TargetEnvironment("linux", "gtk", "x86_64"));
    environments.add(new TargetEnvironment("macosx", "cocoa", "x86_64"));
    impl.setEnvironments(environments);
    String artifactId = "feature.multienv.p2-inf";
    projectToResolve = createReactorProject(resourceFile("resolver/feature.multienv.p2-inf"), TYPE_ECLIPSE_FEATURE, artifactId);
    List<P2ResolutionResult> results = impl.resolveDependencies(getTargetPlatform(), projectToResolve);
    assertEquals(2, results.size());
    P2ResolutionResult linux = results.get(0);
    List<Entry> linuxEntries = new ArrayList<>(linux.getArtifacts());
    assertEquals(1, linuxEntries.size());
    assertEquals(1, linuxEntries.get(0).getInstallableUnits().size());
    assertEquals(0, linux.getNonReactorUnits().size());
    P2ResolutionResult macosx = results.get(1);
    List<Entry> macosxEntries = new ArrayList<>(macosx.getArtifacts());
    assertEquals(1, macosxEntries.size());
    assertEquals(2, macosxEntries.get(0).getInstallableUnits().size());
    assertEquals(0, macosx.getNonReactorUnits().size());
}
Also used : Entry(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry) ArrayList(java.util.ArrayList) P2ResolutionResult(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) Test(org.junit.Test)

Example 3 with P2ResolutionResult

use of org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult in project tycho by eclipse.

the class P2ResolverImpl method resolveMetadata.

@Override
public P2ResolutionResult resolveMetadata(TargetPlatformConfigurationStub tpConfiguration, String eeName) {
    P2TargetPlatform contextImpl = targetPlatformFactory.createTargetPlatform(tpConfiguration, new ExecutionEnvironmentConfigurationStub(eeName), null, null);
    ResolutionDataImpl data = new ResolutionDataImpl(contextImpl.getEEResolutionHints());
    data.setAvailableIUs(contextImpl.getInstallableUnits());
    data.setRootIUs(new HashSet<IInstallableUnit>());
    data.setAdditionalRequirements(additionalRequirements);
    ProjectorResolutionStrategy strategy = new ProjectorResolutionStrategy(logger);
    strategy.setData(data);
    MetadataOnlyP2ResolutionResult result = new MetadataOnlyP2ResolutionResult();
    try {
        for (IInstallableUnit iu : strategy.multiPlatformResolve(environments, monitor)) {
            result.addArtifact(ArtifactType.TYPE_INSTALLABLE_UNIT, iu.getId(), iu.getVersion().toString(), iu);
        }
    } catch (ResolverException e) {
        logger.error("Resolution failed:");
        new MultiLineLogger(logger).error(e.getDetails(), "  ");
        throw new RuntimeException(e);
    }
    return result;
}
Also used : ExecutionEnvironmentConfigurationStub(org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfigurationStub) ResolverException(org.eclipse.tycho.p2.util.resolution.ResolverException) ResolutionDataImpl(org.eclipse.tycho.p2.util.resolution.ResolutionDataImpl) P2TargetPlatform(org.eclipse.tycho.p2.target.P2TargetPlatform) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ProjectorResolutionStrategy(org.eclipse.tycho.p2.util.resolution.ProjectorResolutionStrategy) MultiLineLogger(org.eclipse.tycho.core.shared.MultiLineLogger)

Example 4 with P2ResolutionResult

use of org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult in project tycho by eclipse.

the class P2ResolverImpl method getTargetPlatformAsResolutionResult.

// TODO 412416 make this obsolete by adding appropriate getters in TargetPlatform interface
@Override
public P2ResolutionResult getTargetPlatformAsResolutionResult(TargetPlatformConfigurationStub tpConfiguration, String eeName) {
    P2TargetPlatform targetPlatform = targetPlatformFactory.createTargetPlatform(tpConfiguration, new ExecutionEnvironmentConfigurationStub(eeName), null, null);
    MetadataOnlyP2ResolutionResult result = new MetadataOnlyP2ResolutionResult();
    for (IInstallableUnit iu : targetPlatform.getInstallableUnits()) {
        result.addArtifact(ArtifactType.TYPE_INSTALLABLE_UNIT, iu.getId(), iu.getVersion().toString(), iu);
    }
    return result;
}
Also used : ExecutionEnvironmentConfigurationStub(org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfigurationStub) P2TargetPlatform(org.eclipse.tycho.p2.target.P2TargetPlatform) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 5 with P2ResolutionResult

use of org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult in project tycho by eclipse.

the class P2ResolverImpl method resolveDependencies.

@SuppressWarnings("unchecked")
protected P2ResolutionResult resolveDependencies(ReactorProject project, AbstractResolutionStrategy strategy, TargetEnvironment environment) {
    ResolutionDataImpl data = new ResolutionDataImpl(context.getEEResolutionHints());
    Set<IInstallableUnit> availableUnits = context.getInstallableUnits();
    if (project != null) {
        data.setRootIUs((Set<IInstallableUnit>) project.getDependencyMetadata(true));
        Collection<IInstallableUnit> projectSecondaryIUs = (Collection<IInstallableUnit>) project.getDependencyMetadata(false);
        if (!projectSecondaryIUs.isEmpty()) {
            availableUnits = new LinkedHashSet<>(availableUnits);
            availableUnits.addAll(projectSecondaryIUs);
        }
    } else {
        data.setRootIUs(Collections.<IInstallableUnit>emptySet());
    }
    data.setAdditionalRequirements(additionalRequirements);
    data.setAvailableIUs(availableUnits);
    data.setAdditionalFilterProperties(additionalFilterProperties);
    strategy.setData(data);
    Collection<IInstallableUnit> newState;
    try {
        newState = strategy.resolve(environment, monitor);
    } catch (ResolverException e) {
        logger.info(e.getSelectionContext());
        logger.error("Cannot resolve project dependencies:");
        new MultiLineLogger(logger).error(e.getDetails(), "  ");
        logger.error("");
        logger.error("See http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting for help.");
        throw new DependencyResolutionException("Cannot resolve dependencies of " + project, e);
    }
    if (usedTargetPlatformUnits != null) {
        usedTargetPlatformUnits.addAll(newState);
    }
    return toResolutionResult(newState, project);
}
Also used : ResolverException(org.eclipse.tycho.p2.util.resolution.ResolverException) ResolutionDataImpl(org.eclipse.tycho.p2.util.resolution.ResolutionDataImpl) Collection(java.util.Collection) QueryableCollection(org.eclipse.tycho.repository.p2base.metadata.QueryableCollection) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) DependencyResolutionException(org.eclipse.tycho.artifacts.DependencyResolutionException) MultiLineLogger(org.eclipse.tycho.core.shared.MultiLineLogger)

Aggregations

P2ResolutionResult (org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult)6 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)4 ArrayList (java.util.ArrayList)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)3 Entry (org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 ReactorProject (org.eclipse.tycho.ReactorProject)2 ExecutionEnvironmentConfigurationStub (org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfigurationStub)2 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)2 DefaultDependencyArtifacts (org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts)2 MultiLineLogger (org.eclipse.tycho.core.shared.MultiLineLogger)2 P2TargetPlatform (org.eclipse.tycho.p2.target.P2TargetPlatform)2 ProjectorResolutionStrategy (org.eclipse.tycho.p2.util.resolution.ProjectorResolutionStrategy)2 ResolutionDataImpl (org.eclipse.tycho.p2.util.resolution.ResolutionDataImpl)2 ResolverException (org.eclipse.tycho.p2.util.resolution.ResolverException)2 Test (org.junit.Test)2 File (java.io.File)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1