Search in sources :

Example 1 with MultiEnvironmentDependencyArtifacts

use of org.eclipse.tycho.core.osgitools.targetplatform.MultiEnvironmentDependencyArtifacts in project tycho by eclipse.

the class DefaultDependencyArtifactsTest method testMultiEnvironmentMetadataMerge.

@Test
public void testMultiEnvironmentMetadataMerge() {
    ArtifactKey key = new DefaultArtifactKey("type", "id", "version");
    File location = new File("location");
    DefaultDependencyArtifacts tpA = new DefaultDependencyArtifacts();
    tpA.addArtifactFile(key, location, asSet("a"));
    DefaultDependencyArtifacts tpB = new DefaultDependencyArtifacts();
    tpB.addArtifactFile(key, location, asSet("a", "b"));
    MultiEnvironmentDependencyArtifacts tp = new MultiEnvironmentDependencyArtifacts();
    tp.addPlatform(new TargetEnvironment("a", "a", "a"), tpA);
    tp.addPlatform(new TargetEnvironment("b", "b", "b"), tpB);
    List<ArtifactDescriptor> artifacts = tp.getArtifacts();
    Assert.assertEquals(1, artifacts.size());
    Set<Object> units = artifacts.get(0).getInstallableUnits();
    Assert.assertEquals(2, units.size());
    Assert.assertTrue(units.contains("a"));
    Assert.assertTrue(units.contains("b"));
}
Also used : DefaultDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts) DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) ArtifactKey(org.eclipse.tycho.ArtifactKey) DefaultArtifactDescriptor(org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) File(java.io.File) MultiEnvironmentDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.MultiEnvironmentDependencyArtifacts) Test(org.junit.Test)

Example 2 with MultiEnvironmentDependencyArtifacts

use of org.eclipse.tycho.core.osgitools.targetplatform.MultiEnvironmentDependencyArtifacts in project tycho by eclipse.

the class P2DependencyResolver method doResolveDependencies.

private DependencyArtifacts doResolveDependencies(MavenSession session, MavenProject project, List<ReactorProject> reactorProjects, DependencyResolverConfiguration resolverConfiguration, TargetPlatform targetPlatform, P2Resolver resolver, TargetPlatformConfiguration configuration) {
    Map<File, ReactorProject> projects = new HashMap<>();
    resolver.setEnvironments(configuration.getEnvironments());
    resolver.setAdditionalFilterProperties(configuration.getProfileProperties());
    for (ReactorProject otherProject : reactorProjects) {
        projects.put(otherProject.getBasedir(), otherProject);
    }
    if (resolverConfiguration != null) {
        for (Dependency dependency : resolverConfiguration.getExtraRequirements()) {
            try {
                resolver.addDependency(dependency.getType(), dependency.getArtifactId(), dependency.getVersion());
            } catch (IllegalArtifactReferenceException e) {
                throw new BuildFailureException("Invalid extraRequirement " + dependency.getType() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion() + ": " + e.getMessage(), e);
            }
        }
    }
    // get reactor project with prepared optional dependencies // TODO use original IU and have the resolver create the modified IUs
    ReactorProject optionalDependencyPreparedProject = getThisReactorProject(session, project, configuration);
    if (!isAllowConflictingDependencies(project, configuration)) {
        List<P2ResolutionResult> results = resolver.resolveDependencies(targetPlatform, optionalDependencyPreparedProject);
        MultiEnvironmentDependencyArtifacts multiPlatform = new MultiEnvironmentDependencyArtifacts(DefaultReactorProject.adapt(project));
        // FIXME this is just wrong
        for (int i = 0; i < configuration.getEnvironments().size(); i++) {
            TargetEnvironment environment = configuration.getEnvironments().get(i);
            P2ResolutionResult result = results.get(i);
            DefaultDependencyArtifacts platform = newDefaultTargetPlatform(DefaultReactorProject.adapt(project), projects, result);
            multiPlatform.addPlatform(environment, platform);
        }
        return multiPlatform;
    } else {
        P2ResolutionResult result = resolver.collectProjectDependencies(targetPlatform, optionalDependencyPreparedProject);
        return newDefaultTargetPlatform(DefaultReactorProject.adapt(project), projects, result);
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IllegalArtifactReferenceException(org.eclipse.tycho.artifacts.IllegalArtifactReferenceException) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) ComponentDependency(org.codehaus.plexus.component.repository.ComponentDependency) Dependency(org.apache.maven.model.Dependency) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) MultiEnvironmentDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.MultiEnvironmentDependencyArtifacts) DefaultDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts) P2ResolutionResult(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult) File(java.io.File)

Aggregations

File (java.io.File)2 DefaultDependencyArtifacts (org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts)2 MultiEnvironmentDependencyArtifacts (org.eclipse.tycho.core.osgitools.targetplatform.MultiEnvironmentDependencyArtifacts)2 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Dependency (org.apache.maven.model.Dependency)1 ComponentDependency (org.codehaus.plexus.component.repository.ComponentDependency)1 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)1 ArtifactKey (org.eclipse.tycho.ArtifactKey)1 DefaultArtifactKey (org.eclipse.tycho.DefaultArtifactKey)1 ReactorProject (org.eclipse.tycho.ReactorProject)1 IllegalArtifactReferenceException (org.eclipse.tycho.artifacts.IllegalArtifactReferenceException)1 DefaultArtifactDescriptor (org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor)1 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)1 BuildFailureException (org.eclipse.tycho.core.shared.BuildFailureException)1 P2ResolutionResult (org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult)1 Test (org.junit.Test)1