Search in sources :

Example 1 with PomDependencyCollector

use of org.eclipse.tycho.p2.target.facade.PomDependencyCollector in project tycho by eclipse.

the class TargetPlatformFactoryImpl method createTargetPlatform.

/**
 * Computes the target platform from the given configuration and content.
 *
 * <p>
 * Used as entry point for tests, which can provide the execution environment configuration via
 * the more low-level type {@link ExecutionEnvironmentResolutionHandler}.
 * </p>
 *
 * @param tpConfiguration
 * @param eeResolutionHandler
 *            Representation of the target execution environment profile. In case of a custom EE
 *            profile, the handler also reads the full specification from the target platform.
 * @param reactorProjects
 *            may be <code>null</code>
 * @param pomDependencies
 *            may be <code>null</code>
 *
 * @see #createTargetPlatform(TargetPlatformConfigurationStub,
 *      ExecutionEnvironmentConfiguration, List, PomDependencyCollector)
 */
public P2TargetPlatform createTargetPlatform(TargetPlatformConfigurationStub tpConfiguration, ExecutionEnvironmentResolutionHandler eeResolutionHandler, List<ReactorProject> reactorProjects, PomDependencyCollector pomDependencies) {
    List<TargetDefinitionContent> targetFileContent = resolveTargetDefinitions(tpConfiguration, eeResolutionHandler.getResolutionHints());
    PomDependencyCollectorImpl pomDependenciesContent = (PomDependencyCollectorImpl) pomDependencies;
    // TODO 412416 remove when the RepositoryBlackboardKey registration is gone
    if (pomDependenciesContent == null)
        pomDependenciesContent = new PomDependencyCollectorImpl(mavenContext);
    // TODO 372780 get rid of this special handling of pomDependency artifacts: there should be one p2 artifact repo view on the target platform
    IRawArtifactFileProvider pomDependencyArtifactRepo = pomDependenciesContent.getArtifactRepoOfPublishedBundles();
    RepositoryBlackboardKey blackboardKey = RepositoryBlackboardKey.forResolutionContextArtifacts(pomDependenciesContent.getProjectLocation());
    ArtifactRepositoryBlackboard.putRepository(blackboardKey, new ProviderOnlyArtifactRepository(pomDependencyArtifactRepo, Activator.getProvisioningAgent(), blackboardKey.toURI()));
    logger.debug("Registered artifact repository " + blackboardKey);
    Set<MavenRepositoryLocation> completeRepositories = tpConfiguration.getP2Repositories();
    registerRepositoryIDs(completeRepositories);
    // collect & process metadata
    boolean includeLocalMavenRepo = shouldIncludeLocallyInstalledUnits(tpConfiguration);
    LinkedHashSet<IInstallableUnit> externalUIs = gatherExternalInstallableUnits(completeRepositories, targetFileContent, pomDependenciesContent, includeLocalMavenRepo);
    Map<IInstallableUnit, ReactorProjectIdentities> reactorProjectUIs = getPreliminaryReactorProjectUIs(reactorProjects);
    List<TargetPlatformFilter> iuFilters = tpConfiguration.getFilters();
    TargetPlatformFilterEvaluator filter = !iuFilters.isEmpty() ? new TargetPlatformFilterEvaluator(iuFilters, logger) : null;
    applyConfiguredFilter(filter, reactorProjectUIs.keySet());
    applyFilters(filter, externalUIs, reactorProjectUIs.keySet(), eeResolutionHandler.getResolutionHints());
    PreliminaryTargetPlatformImpl targetPlatform = new // 
    PreliminaryTargetPlatformImpl(// 
    reactorProjectUIs, // 
    externalUIs, // 
    pomDependenciesContent.getMavenInstallableUnits(), // 
    eeResolutionHandler.getResolutionHints(), // 
    filter, // 
    localMetadataRepository, createExternalArtifactProvider(completeRepositories, targetFileContent, pomDependencyArtifactRepo, // 
    tpConfiguration.getIncludePackedArtifacts()), // 
    localArtifactRepository, // 
    includeLocalMavenRepo, logger);
    eeResolutionHandler.readFullSpecification(targetPlatform.getInstallableUnits());
    return targetPlatform;
}
Also used : IRawArtifactFileProvider(org.eclipse.tycho.repository.p2base.artifact.provider.IRawArtifactFileProvider) ReactorProjectIdentities(org.eclipse.tycho.ReactorProjectIdentities) RepositoryBlackboardKey(org.eclipse.tycho.repository.registry.facade.RepositoryBlackboardKey) TargetPlatformFilterEvaluator(org.eclipse.tycho.p2.target.filters.TargetPlatformFilterEvaluator) MavenRepositoryLocation(org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation) ProviderOnlyArtifactRepository(org.eclipse.tycho.repository.p2base.artifact.repository.ProviderOnlyArtifactRepository) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) TargetPlatformFilter(org.eclipse.tycho.artifacts.TargetPlatformFilter)

Example 2 with PomDependencyCollector

use of org.eclipse.tycho.p2.target.facade.PomDependencyCollector 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 3 with PomDependencyCollector

use of org.eclipse.tycho.p2.target.facade.PomDependencyCollector in project tycho by eclipse.

the class ReactorRepositoryManagerImpl method computePreliminaryTargetPlatform.

@Override
public TargetPlatform computePreliminaryTargetPlatform(ReactorProject project, TargetPlatformConfigurationStub tpConfiguration, ExecutionEnvironmentConfiguration eeConfiguration, List<ReactorProject> reactorProjects, PomDependencyCollector pomDependencies) {
    // at this point, there is only incomplete ("dependency-only") metadata for the reactor projects
    TargetPlatform result = tpFactory.createTargetPlatform(tpConfiguration, eeConfiguration, reactorProjects, pomDependencies);
    project.setContextValue(PRELIMINARY_TARGET_PLATFORM_KEY, result);
    return result;
}
Also used : P2TargetPlatform(org.eclipse.tycho.p2.target.P2TargetPlatform) TargetPlatform(org.eclipse.tycho.artifacts.TargetPlatform)

Example 4 with PomDependencyCollector

use of org.eclipse.tycho.p2.target.facade.PomDependencyCollector in project tycho by eclipse.

the class P2DependencyResolver method computePreliminaryTargetPlatform.

@Override
public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, MavenProject project, List<ReactorProject> reactorProjects) {
    TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
    ExecutionEnvironmentConfiguration ee = TychoProjectUtils.getExecutionEnvironmentConfiguration(project);
    TargetPlatformConfigurationStub tpConfiguration = new TargetPlatformConfigurationStub();
    tpConfiguration.setIncludePackedArtifacts(configuration.isIncludePackedArtifacts());
    PomDependencyCollector pomDependencies = null;
    if (TargetPlatformConfiguration.POM_DEPENDENCIES_CONSIDER.equals(configuration.getPomDependencies())) {
        pomDependencies = collectPomDependencies(project, reactorProjects, session);
    } else {
        // TODO 412416 remove this when the setProjectLocation is no longer needed
        pomDependencies = resolverFactory.newPomDependencyCollector();
        pomDependencies.setProjectLocation(project.getBasedir());
    }
    for (ArtifactRepository repository : project.getRemoteArtifactRepositories()) {
        addEntireP2RepositoryToTargetPlatform(repository, tpConfiguration);
    }
    tpConfiguration.setEnvironments(configuration.getEnvironments());
    for (File file : configuration.getTargets()) {
        addTargetFileContentToTargetPlatform(file, configuration.getTargetDefinitionIncludeSourceMode(), tpConfiguration);
    }
    tpConfiguration.addFilters(configuration.getFilters());
    return reactorRepositoryManager.computePreliminaryTargetPlatform(DefaultReactorProject.adapt(project), tpConfiguration, ee, reactorProjects, pomDependencies);
}
Also used : TargetPlatformConfigurationStub(org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub) ExecutionEnvironmentConfiguration(org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration) PomDependencyCollector(org.eclipse.tycho.p2.target.facade.PomDependencyCollector) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) File(java.io.File)

Example 5 with PomDependencyCollector

use of org.eclipse.tycho.p2.target.facade.PomDependencyCollector 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

PomDependencyCollector (org.eclipse.tycho.p2.target.facade.PomDependencyCollector)4 Artifact (org.apache.maven.artifact.Artifact)2 TargetPlatformFilter (org.eclipse.tycho.artifacts.TargetPlatformFilter)2 Test (org.junit.Test)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashSet (java.util.LinkedHashSet)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 AbstractArtifactResolutionException (org.apache.maven.artifact.resolver.AbstractArtifactResolutionException)1 MultipleArtifactsNotFoundException (org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException)1 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)1 ReactorProject (org.eclipse.tycho.ReactorProject)1 ReactorProjectIdentities (org.eclipse.tycho.ReactorProjectIdentities)1 TargetPlatform (org.eclipse.tycho.artifacts.TargetPlatform)1 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)1 ExecutionEnvironmentConfiguration (org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration)1 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)1