Search in sources :

Example 1 with ReactorProjectIdentities

use of org.eclipse.tycho.ReactorProjectIdentities 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 2 with ReactorProjectIdentities

use of org.eclipse.tycho.ReactorProjectIdentities in project tycho by eclipse.

the class TargetPlatformMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    ReactorRepositoryManagerFacade repositoryManager = osgiServices.getService(ReactorRepositoryManagerFacade.class);
    List<ReactorProjectIdentities> upstreamProjects = getReferencedTychoProjects();
    repositoryManager.computeFinalTargetPlatform(DefaultReactorProject.adapt(project), upstreamProjects);
}
Also used : ReactorRepositoryManagerFacade(org.eclipse.tycho.repository.registry.facade.ReactorRepositoryManagerFacade) ReactorProjectIdentities(org.eclipse.tycho.ReactorProjectIdentities)

Example 3 with ReactorProjectIdentities

use of org.eclipse.tycho.ReactorProjectIdentities in project tycho by eclipse.

the class TargetPlatformFactoryImpl method getPreliminaryReactorProjectUIs.

private Map<IInstallableUnit, ReactorProjectIdentities> getPreliminaryReactorProjectUIs(List<ReactorProject> reactorProjects) throws DuplicateReactorIUsException {
    if (reactorProjects == null) {
        return Collections.emptyMap();
    }
    Map<IInstallableUnit, ReactorProjectIdentities> reactorUIs = new HashMap<>();
    Map<IInstallableUnit, Set<File>> duplicateReactorUIs = new HashMap<>();
    for (ReactorProject project : reactorProjects) {
        @SuppressWarnings("unchecked") Set<IInstallableUnit> projectIUs = (Set<IInstallableUnit>) project.getDependencyMetadata();
        if (projectIUs == null)
            continue;
        for (IInstallableUnit iu : projectIUs) {
            ReactorProjectIdentities otherOrigin = reactorUIs.put(iu, project.getIdentities());
            if (otherOrigin != null && !otherOrigin.equals(project.getIdentities())) {
                Set<File> duplicateLocations = duplicateReactorUIs.get(iu);
                if (duplicateLocations == null) {
                    duplicateLocations = new LinkedHashSet<>();
                    duplicateReactorUIs.put(iu, duplicateLocations);
                }
                duplicateLocations.add(otherOrigin.getBasedir());
                duplicateLocations.add(project.getBasedir());
            }
        }
    }
    if (!duplicateReactorUIs.isEmpty()) {
        // TODO 392320 we should only fail if IUs with same id and version but different content are found
        throw new DuplicateReactorIUsException(duplicateReactorUIs);
    }
    return reactorUIs;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ReactorProject(org.eclipse.tycho.ReactorProject) ReactorProjectIdentities(org.eclipse.tycho.ReactorProjectIdentities) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File)

Example 4 with ReactorProjectIdentities

use of org.eclipse.tycho.ReactorProjectIdentities 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 ReactorProjectIdentities

use of org.eclipse.tycho.ReactorProjectIdentities in project tycho by eclipse.

the class TargetPlatformFactoryTest method testOtherVersionsOfReactorIUsAreFilteredFromExternalContent.

@Test
public void testOtherVersionsOfReactorIUsAreFilteredFromExternalContent() throws Exception {
    // contains trt.bundle/1.0.0.201108051343
    tpConfig.addP2Repository(ResourceUtil.resourceFile("targetresolver/v1_content").toURI());
    // reactor artifact produces a unit with same ID
    ReactorProject reactorProject = createReactorProject("artifactId", "trt.bundle/1.5.5.qualifier", null);
    P2TargetPlatform preliminaryTP = subject.createTargetPlatform(tpConfig, NOOP_EE_RESOLUTION_HANDLER, Collections.singletonList(reactorProject), null);
    assertThat(preliminaryTP.getInstallableUnits(), hasItem(unit("trt.bundle", "1.5.5.qualifier")));
    assertThat(preliminaryTP.getInstallableUnits(), not(hasItem(unit("trt.bundle", "1.0.0.201108051343"))));
    Map<IInstallableUnit, ReactorProjectIdentities> finalUnits = Collections.singletonMap(InstallableUnitUtil.createIU("trt.bundle", "1.5.5.20140216"), reactorProject.getIdentities());
    P2TargetPlatform finalTP = subject.createTargetPlatformWithUpdatedReactorUnits(preliminaryTP, finalUnits, REACTOR_ARTIFACTS);
    assertThat(finalTP.getInstallableUnits(), hasItem(unit("trt.bundle", "1.5.5.20140216")));
    assertThat(finalTP.getInstallableUnits(), not(hasItem(unit("trt.bundle", "1.0.0.201108051343"))));
}
Also used : ReactorProject(org.eclipse.tycho.ReactorProject) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ReactorProjectIdentities(org.eclipse.tycho.ReactorProjectIdentities) Test(org.junit.Test)

Aggregations

ReactorProjectIdentities (org.eclipse.tycho.ReactorProjectIdentities)9 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)6 File (java.io.File)3 ReactorProject (org.eclipse.tycho.ReactorProject)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 TargetPlatformFilter (org.eclipse.tycho.artifacts.TargetPlatformFilter)2 MavenRepositoryLocation (org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation)2 ReactorRepositoryManagerFacade (org.eclipse.tycho.repository.registry.facade.ReactorRepositoryManagerFacade)2 ReactorProjectIdentitiesStub (org.eclipse.tycho.test.util.ReactorProjectIdentitiesStub)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)1 ExecutionEnvironmentConfigurationStub (org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfigurationStub)1 MavenContext (org.eclipse.tycho.core.shared.MavenContext)1 MavenContextImpl (org.eclipse.tycho.core.shared.MavenContextImpl)1 ReactorProjectStub (org.eclipse.tycho.p2.impl.test.ReactorProjectStub)1 IArtifactFacade (org.eclipse.tycho.p2.metadata.IArtifactFacade)1