Search in sources :

Example 6 with P2ResolutionResult

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

Example 7 with P2ResolutionResult

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

the class P2DependencyResolver method newDefaultTargetPlatform.

protected DefaultDependencyArtifacts newDefaultTargetPlatform(ReactorProject project, Map<File, ReactorProject> projects, P2ResolutionResult result) {
    DefaultDependencyArtifacts platform = new DefaultDependencyArtifacts(project);
    platform.addNonReactorUnits(result.getNonReactorUnits());
    for (P2ResolutionResult.Entry entry : result.getArtifacts()) {
        ArtifactKey key = new DefaultArtifactKey(entry.getType(), entry.getId(), entry.getVersion());
        ReactorProject otherProject = projects.get(entry.getLocation());
        if (otherProject != null) {
            platform.addReactorArtifact(key, otherProject, entry.getClassifier(), entry.getInstallableUnits());
        } else {
            platform.addArtifactFile(key, entry.getLocation(), entry.getInstallableUnits());
        }
    }
    return platform;
}
Also used : DefaultDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts) DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) ArtifactKey(org.eclipse.tycho.ArtifactKey) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) P2ResolutionResult(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult) DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey)

Example 8 with P2ResolutionResult

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

the class P2ResolverTest method getClassifiedArtifact.

private static P2ResolutionResult.Entry getClassifiedArtifact(P2ResolutionResult resolutionResult, String classifier) {
    Set<String> availableClassifiers = new HashSet<>();
    P2ResolutionResult.Entry selectedEntry = null;
    for (Entry entry : resolutionResult.getArtifacts()) {
        availableClassifiers.add(entry.getClassifier());
        if (eq(classifier, entry.getClassifier())) {
            selectedEntry = entry;
        }
    }
    assertThat(availableClassifiers, hasItem(classifier));
    return selectedEntry;
}
Also used : Entry(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry) P2ResolutionResult(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Entry(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry) HashSet(java.util.HashSet)

Example 9 with P2ResolutionResult

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

the class P2ResolverImpl method resolveDependencies.

@Override
public List<P2ResolutionResult> resolveDependencies(TargetPlatform targetPlatform, ReactorProject project) {
    setContext(targetPlatform, project);
    if (project != null && PackagingType.TYPE_ECLIPSE_TEST_PLUGIN.equals(project.getPackaging())) {
        addDependenciesForTests();
    }
    ArrayList<P2ResolutionResult> results = new ArrayList<>();
    usedTargetPlatformUnits = new LinkedHashSet<>();
    for (TargetEnvironment environment : environments) {
        results.add(resolveDependencies(project, new ProjectorResolutionStrategy(logger), environment));
    }
    context.reportUsedLocalIUs(usedTargetPlatformUnits);
    usedTargetPlatformUnits = null;
    return results;
}
Also used : ArrayList(java.util.ArrayList) P2ResolutionResult(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) ProjectorResolutionStrategy(org.eclipse.tycho.p2.util.resolution.ProjectorResolutionStrategy)

Aggregations

P2ResolutionResult (org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult)6 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)4 ArrayList (java.util.ArrayList)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)3 Entry (org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 ReactorProject (org.eclipse.tycho.ReactorProject)2 ExecutionEnvironmentConfigurationStub (org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfigurationStub)2 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)2 DefaultDependencyArtifacts (org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts)2 MultiLineLogger (org.eclipse.tycho.core.shared.MultiLineLogger)2 P2TargetPlatform (org.eclipse.tycho.p2.target.P2TargetPlatform)2 ProjectorResolutionStrategy (org.eclipse.tycho.p2.util.resolution.ProjectorResolutionStrategy)2 ResolutionDataImpl (org.eclipse.tycho.p2.util.resolution.ResolutionDataImpl)2 ResolverException (org.eclipse.tycho.p2.util.resolution.ResolverException)2 Test (org.junit.Test)2 File (java.io.File)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1