Search in sources :

Example 6 with P2TargetPlatform

use of org.eclipse.tycho.p2.target.P2TargetPlatform in project tycho by eclipse.

the class TargetPlatformFactoryImpl method createTargetPlatformWithUpdatedReactorUnits.

P2TargetPlatform createTargetPlatformWithUpdatedReactorUnits(PreliminaryTargetPlatformImpl preliminaryTP, Map<IInstallableUnit, ReactorProjectIdentities> reactorUnitsMap, List<IRawArtifactFileProvider> reactorArtifacts) {
    LinkedHashSet<IInstallableUnit> allUnits = preliminaryTP.getExternalUnits();
    // external units are already filtered, only reactor units need to be filtered again
    if (reactorUnitsMap != null) {
        Collection<IInstallableUnit> reactorUnits = new LinkedList<>(reactorUnitsMap.keySet());
        TargetPlatformFilterEvaluator configuredFilters = preliminaryTP.getFilter();
        if (configuredFilters != null) {
            configuredFilters.filterUnits(reactorUnits);
        }
        allUnits.addAll(reactorUnits);
    }
    IRawArtifactFileProvider jointArtifacts = createJointArtifactProvider(reactorArtifacts, preliminaryTP.getExternalArtifacts());
    return new FinalTargetPlatformImpl(allUnits, preliminaryTP.getEEResolutionHints(), jointArtifacts, localArtifactRepository, preliminaryTP.getOriginalMavenArtifactMap(), reactorUnitsMap);
}
Also used : IRawArtifactFileProvider(org.eclipse.tycho.repository.p2base.artifact.provider.IRawArtifactFileProvider) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) TargetPlatformFilterEvaluator(org.eclipse.tycho.p2.target.filters.TargetPlatformFilterEvaluator) LinkedList(java.util.LinkedList)

Example 7 with P2TargetPlatform

use of org.eclipse.tycho.p2.target.P2TargetPlatform 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 8 with P2TargetPlatform

use of org.eclipse.tycho.p2.target.P2TargetPlatform 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 9 with P2TargetPlatform

use of org.eclipse.tycho.p2.target.P2TargetPlatform in project tycho by eclipse.

the class TargetPlatformFactoryTest method testFinalTargetPlatformContainsPomDependencyIU.

@Test
public void testFinalTargetPlatformContainsPomDependencyIU() throws Exception {
    PomDependencyCollector pomDependencies = subject.newPomDependencyCollector();
    pomDependencies.addArtifactWithExistingMetadata(PomDependencyCollectorTest.artifactWithClassifier(null), PomDependencyCollectorTest.existingMetadata());
    P2TargetPlatform preliminaryTP = subject.createTargetPlatform(tpConfig, NOOP_EE_RESOLUTION_HANDLER, null, pomDependencies);
    P2TargetPlatform finalTP = subject.createTargetPlatformWithUpdatedReactorUnits(preliminaryTP, null, REACTOR_ARTIFACTS);
    assertThat(finalTP.getInstallableUnits(), hasItem(unitWithId("test.unit")));
}
Also used : PomDependencyCollector(org.eclipse.tycho.p2.target.facade.PomDependencyCollector) Test(org.junit.Test)

Example 10 with P2TargetPlatform

use of org.eclipse.tycho.p2.target.P2TargetPlatform in project tycho by eclipse.

the class TargetPlatformFactoryTest method testConfiguredFiltersOnPomDependencies.

@Test
public void testConfiguredFiltersOnPomDependencies() throws Exception {
    PomDependencyCollector pomDependencies = subject.newPomDependencyCollector();
    pomDependencies.addArtifactWithExistingMetadata(PomDependencyCollectorTest.artifactWithClassifier(null), PomDependencyCollectorTest.existingMetadata());
    TargetPlatformFilter filter = TargetPlatformFilter.removeAllFilter(CapabilityPattern.patternWithoutVersion(CapabilityType.P2_INSTALLABLE_UNIT, "test.unit"));
    tpConfig.addFilters(Arrays.asList(filter));
    P2TargetPlatform preliminaryTP = subject.createTargetPlatform(tpConfig, NOOP_EE_RESOLUTION_HANDLER, null, pomDependencies);
    assertThat(preliminaryTP.getInstallableUnits(), not(hasItem(unitWithId("test.unit"))));
    P2TargetPlatform finalTP = subject.createTargetPlatformWithUpdatedReactorUnits(preliminaryTP, null, REACTOR_ARTIFACTS);
    assertThat(finalTP.getInstallableUnits(), not(hasItem(unitWithId("test.unit"))));
}
Also used : PomDependencyCollector(org.eclipse.tycho.p2.target.facade.PomDependencyCollector) TargetPlatformFilter(org.eclipse.tycho.artifacts.TargetPlatformFilter) Test(org.junit.Test)

Aggregations

P2TargetPlatform (org.eclipse.tycho.p2.target.P2TargetPlatform)7 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)6 ExecutionEnvironmentConfigurationStub (org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfigurationStub)3 PublishingRepository (org.eclipse.tycho.repository.publishing.PublishingRepository)3 Test (org.junit.Test)3 ReactorProjectIdentities (org.eclipse.tycho.ReactorProjectIdentities)2 TargetPlatformFilter (org.eclipse.tycho.artifacts.TargetPlatformFilter)2 MavenRepositoryLocation (org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation)2 PomDependencyCollector (org.eclipse.tycho.p2.target.facade.PomDependencyCollector)2 TargetPlatformConfigurationStub (org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub)2 TargetPlatformFilterEvaluator (org.eclipse.tycho.p2.target.filters.TargetPlatformFilterEvaluator)2 IRawArtifactFileProvider (org.eclipse.tycho.repository.p2base.artifact.provider.IRawArtifactFileProvider)2 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 ReactorProject (org.eclipse.tycho.ReactorProject)1 MultiLineLogger (org.eclipse.tycho.core.shared.MultiLineLogger)1 ReactorProjectStub (org.eclipse.tycho.p2.impl.test.ReactorProjectStub)1 FinalTargetPlatformImpl (org.eclipse.tycho.p2.target.FinalTargetPlatformImpl)1 PreliminaryTargetPlatformImpl (org.eclipse.tycho.p2.target.PreliminaryTargetPlatformImpl)1 TargetPlatformFactoryImpl (org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl)1