Search in sources :

Example 1 with Entry

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

the class P2ResolverTest method testReactorVsExternal.

@Test
public void testReactorVsExternal() throws Exception {
    tpConfig.addP2Repository(resourceFile("reactor-vs-external/extrepo").toURI());
    reactorProjects.add(createReactorProject(resourceFile("reactor-vs-external/bundle01"), TYPE_ECLIPSE_PLUGIN, "org.sonatype.tycho.p2.impl.resolver.test.bundle01"));
    projectToResolve = createReactorProject(resourceFile("reactor-vs-external/feature01"), TYPE_ECLIPSE_FEATURE, "org.sonatype.tycho.p2.impl.resolver.test.feature01");
    result = singleEnv(impl.resolveDependencies(getTargetPlatform(), projectToResolve));
    assertEquals(2, result.getArtifacts().size());
    assertEquals(0, result.getNonReactorUnits().size());
    for (Entry entry : result.getArtifacts()) {
        assertEquals("1.0.0.qualifier", entry.getVersion());
    }
}
Also used : Entry(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry) Test(org.junit.Test)

Example 2 with Entry

use of org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry 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 3 with Entry

use of org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry 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 4 with Entry

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

the class P2ResolverTest method testSourceBundle.

@Test
public void testSourceBundle() throws Exception {
    String featureId = "org.eclipse.tycho.p2.impl.resolver.test.feature01";
    projectToResolve = createReactorProject(resourceFile("sourcebundles/feature01"), TYPE_ECLIPSE_FEATURE, featureId);
    File bundle = resourceFile("sourcebundles/bundle01");
    String bundleId = "org.eclipse.tycho.p2.impl.resolver.test.bundle01";
    String bundleVersion = "1.0.0-SNAPSHOT";
    reactorProjects.add(createReactorProject(bundle, TYPE_ECLIPSE_PLUGIN, bundleId));
    ReactorProjectStub sb = new ReactorProjectStub(bundle, bundleId, bundleId, bundleVersion, TYPE_ECLIPSE_PLUGIN);
    DependencyMetadata metadata = new SourcesBundleDependencyMetadataGenerator().generateMetadata(new ArtifactMock(sb, "source"), getEnvironments(), null);
    sb.setDependencyMetadata(metadata);
    reactorProjects.add(sb);
    result = singleEnv(impl.resolveDependencies(getTargetPlatform(), projectToResolve));
    assertEquals(3, result.getArtifacts().size());
    List<P2ResolutionResult.Entry> entries = new ArrayList<>(result.getArtifacts());
    Collections.sort(entries, new Comparator<Entry>() {

        @Override
        public int compare(Entry entry1, Entry entry2) {
            return entry1.getId().compareTo(entry2.getId());
        }
    });
    assertEquals("org.eclipse.tycho.p2.impl.resolver.test.bundle01", entries.get(0).getId());
    assertEquals("org.eclipse.tycho.p2.impl.resolver.test.bundle01.source", entries.get(1).getId());
    assertEquals("org.eclipse.tycho.p2.impl.resolver.test.feature01", entries.get(2).getId());
    assertEquals(bundle, entries.get(0).getLocation());
    assertEquals(bundle, entries.get(1).getLocation());
    assertEquals("sources", entries.get(1).getClassifier());
}
Also used : Entry(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry) ReactorProjectStub(org.eclipse.tycho.p2.impl.test.ReactorProjectStub) ArrayList(java.util.ArrayList) DependencyMetadata(org.eclipse.tycho.p2.impl.publisher.DependencyMetadata) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ResourceUtil.resourceFile(org.eclipse.tycho.p2.impl.test.ResourceUtil.resourceFile) File(java.io.File) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) Test(org.junit.Test)

Example 5 with Entry

use of org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry 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)

Aggregations

ArrayList (java.util.ArrayList)5 Entry (org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry)5 File (java.io.File)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)4 IP2Artifact (org.eclipse.tycho.p2.metadata.IP2Artifact)4 P2ResolutionResult (org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 LinkedHashSet (java.util.LinkedHashSet)3 ReactorProject (org.eclipse.tycho.ReactorProject)3 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)3 IOException (java.io.IOException)2 Artifact (org.apache.maven.artifact.Artifact)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 ArtifactDelta (org.eclipse.tycho.artifactcomparator.ArtifactDelta)2 MavenRepositoryLocation (org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation)2