Search in sources :

Example 1 with TargetPlatformConfigurationStub

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

the class P2ResolverTestBase method prepare.

@Before
public final void prepare() throws Exception {
    fullGenerator = new P2GeneratorImpl(true);
    BuildPropertiesParserForTesting buildPropertiesReader = new BuildPropertiesParserForTesting();
    fullGenerator.setBuildPropertiesParser(buildPropertiesReader);
    dependencyGenerator = new DefaultDependencyMetadataGenerator();
    dependencyGenerator.setBuildPropertiesParser(buildPropertiesReader);
    tpConfig = new TargetPlatformConfigurationStub();
    tpFactory = resolverFactory.getTargetPlatformFactoryImpl();
}
Also used : TargetPlatformConfigurationStub(org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub) P2GeneratorImpl(org.eclipse.tycho.p2.impl.publisher.P2GeneratorImpl) BuildPropertiesParserForTesting(org.eclipse.tycho.test.util.BuildPropertiesParserForTesting) DefaultDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator) Before(org.junit.Before)

Example 2 with TargetPlatformConfigurationStub

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

the class ReactorRepositoryManagerTest method testTargetPlatformComputationInIntegration.

@Test
public void testTargetPlatformComputationInIntegration() throws Exception {
    subject = getService(ReactorRepositoryManagerFacade.class);
    ReactorProject currentProject = new ReactorProjectStub("reactor-artifact");
    TargetPlatformConfigurationStub tpConfig = new TargetPlatformConfigurationStub();
    tpConfig.addP2Repository(new MavenRepositoryLocation(null, ResourceUtil.resourceFile("repositories/launchers").toURI()));
    subject.computePreliminaryTargetPlatform(currentProject, tpConfig, new ExecutionEnvironmentConfigurationStub("JavaSE-1.7"), null, null);
    ReactorProjectIdentities upstreamProject = new ReactorProjectIdentitiesStub(ResourceUtil.resourceFile("projectresult"));
    subject.computeFinalTargetPlatform(currentProject, Arrays.asList(upstreamProject));
    P2TargetPlatform finalTP = (P2TargetPlatform) currentProject.getContextValue("org.eclipse.tycho.core.TychoConstants/targetPlatform");
    Collection<IInstallableUnit> units = finalTP.getInstallableUnits();
    // units from the p2 repository
    assertThat(units, hasItem(unitWithId("org.eclipse.equinox.launcher")));
    // units from the upstream project
    assertThat(units, hasItem(unitWithId("bundle")));
    assertThat(units, hasItem(unitWithId("bundle.source")));
// TODO get artifact
}
Also used : ReactorRepositoryManagerFacade(org.eclipse.tycho.repository.registry.facade.ReactorRepositoryManagerFacade) TargetPlatformConfigurationStub(org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub) ExecutionEnvironmentConfigurationStub(org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfigurationStub) MavenRepositoryLocation(org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation) ReactorProjectIdentitiesStub(org.eclipse.tycho.test.util.ReactorProjectIdentitiesStub) ReactorProject(org.eclipse.tycho.ReactorProject) ReactorProjectStub(org.eclipse.tycho.p2.impl.test.ReactorProjectStub) P2TargetPlatform(org.eclipse.tycho.p2.target.P2TargetPlatform) ReactorProjectIdentities(org.eclipse.tycho.ReactorProjectIdentities) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 3 with TargetPlatformConfigurationStub

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

the class TargetPlatformFactoryImpl method resolveTargetDefinitions.

private List<TargetDefinitionContent> resolveTargetDefinitions(TargetPlatformConfigurationStub tpConfiguration, ExecutionEnvironmentResolutionHints eeResolutionHints) {
    List<TargetDefinitionContent> result = new ArrayList<>();
    for (TargetDefinition definition : tpConfiguration.getTargetDefinitions()) {
        if (logger.isDebugEnabled()) {
            logger.debug("Adding target definition file \"" + definition.getOrigin() + "\"");
        }
        TargetDefinitionContent targetFileContent = targetDefinitionResolverService.getTargetDefinitionContent(definition, tpConfiguration.getEnvironments(), eeResolutionHints, remoteAgent);
        result.add(targetFileContent);
        if (logger.isDebugEnabled()) {
            logger.debug("Added " + targetFileContent.getUnits().size() + " units, the content of the target definition file, to the target platform");
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) TargetDefinition(org.eclipse.tycho.p2.target.facade.TargetDefinition)

Example 4 with TargetPlatformConfigurationStub

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

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

Aggregations

TargetPlatformConfigurationStub (org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub)6 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)4 P2TargetPlatform (org.eclipse.tycho.p2.target.P2TargetPlatform)4 ExecutionEnvironmentConfigurationStub (org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfigurationStub)3 Before (org.junit.Before)3 ReactorProjectIdentities (org.eclipse.tycho.ReactorProjectIdentities)2 MavenRepositoryLocation (org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 ReactorProject (org.eclipse.tycho.ReactorProject)1 TargetPlatform (org.eclipse.tycho.artifacts.TargetPlatform)1 TargetPlatformFilter (org.eclipse.tycho.artifacts.TargetPlatformFilter)1 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)1 ExecutionEnvironmentConfiguration (org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration)1 MultiLineLogger (org.eclipse.tycho.core.shared.MultiLineLogger)1 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)1 DefaultDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator)1 P2GeneratorImpl (org.eclipse.tycho.p2.impl.publisher.P2GeneratorImpl)1 ReactorProjectStub (org.eclipse.tycho.p2.impl.test.ReactorProjectStub)1