Search in sources :

Example 1 with IDependencyMetadata

use of org.eclipse.tycho.p2.metadata.IDependencyMetadata in project tycho by eclipse.

the class P2DependencyResolver method setupProjects.

@Override
public void setupProjects(final MavenSession session, final MavenProject project, final ReactorProject reactorProject) {
    TargetPlatformConfiguration configuration = (TargetPlatformConfiguration) project.getContextValue(TychoConstants.CTX_TARGET_PLATFORM_CONFIGURATION);
    List<TargetEnvironment> environments = configuration.getEnvironments();
    Map<String, IDependencyMetadata> metadata = getDependencyMetadata(session, project, environments, OptionalResolutionAction.OPTIONAL);
    Set<Object> primaryMetadata = new LinkedHashSet<>();
    Set<Object> secondaryMetadata = new LinkedHashSet<>();
    for (Map.Entry<String, IDependencyMetadata> entry : metadata.entrySet()) {
        primaryMetadata.addAll(entry.getValue().getMetadata(true));
        secondaryMetadata.addAll(entry.getValue().getMetadata(false));
    }
    reactorProject.setDependencyMetadata(true, primaryMetadata);
    reactorProject.setDependencyMetadata(false, secondaryMetadata);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IDependencyMetadata(org.eclipse.tycho.p2.metadata.IDependencyMetadata) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with IDependencyMetadata

use of org.eclipse.tycho.p2.metadata.IDependencyMetadata in project tycho by eclipse.

the class P2DependencyResolver method getDependencyMetadata.

protected Map<String, IDependencyMetadata> getDependencyMetadata(final MavenSession session, final MavenProject project, final List<TargetEnvironment> environments, final OptionalResolutionAction optionalAction) {
    final Map<String, IDependencyMetadata> metadata = new LinkedHashMap<>();
    metadata.put(null, generator.generateMetadata(new AttachedArtifact(project, project.getBasedir(), null), environments, optionalAction));
    // let external providers contribute additional metadata
    try {
        pluginRealmHelper.execute(session, project, new Runnable() {

            @Override
            public void run() {
                try {
                    for (P2MetadataProvider provider : plexus.lookupList(P2MetadataProvider.class)) {
                        Map<String, IDependencyMetadata> providedMetadata = provider.getDependencyMetadata(session, project, null, optionalAction);
                        if (providedMetadata != null) {
                            metadata.putAll(providedMetadata);
                        }
                    }
                } catch (ComponentLookupException e) {
                // have not found anything
                }
            }
        }, new PluginFilter() {

            @Override
            public boolean accept(PluginDescriptor descriptor) {
                return isTychoP2Plugin(descriptor);
            }
        });
    } catch (MavenExecutionException e) {
        throw new RuntimeException(e);
    }
    return metadata;
}
Also used : PluginFilter(org.eclipse.tycho.core.maven.utils.PluginRealmHelper.PluginFilter) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) LinkedHashMap(java.util.LinkedHashMap) AttachedArtifact(org.eclipse.tycho.p2.facade.internal.AttachedArtifact) PluginDescriptor(org.apache.maven.plugin.descriptor.PluginDescriptor) MavenExecutionException(org.apache.maven.MavenExecutionException) IDependencyMetadata(org.eclipse.tycho.p2.metadata.IDependencyMetadata) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with IDependencyMetadata

use of org.eclipse.tycho.p2.metadata.IDependencyMetadata in project tycho by eclipse.

the class P2ResolverTestBase method createReactorProject.

protected ReactorProject createReactorProject(File projectRoot, String packagingType, String artifactId, OptionalResolutionAction optionalDependencies) {
    ReactorProjectStub project = new ReactorProjectStub(projectRoot, DEFAULT_GROUP_ID, artifactId, DEFAULT_VERSION, packagingType);
    IDependencyMetadata metadata = dependencyGenerator.generateMetadata(new ArtifactMock(project, null), getEnvironments(), optionalDependencies);
    project.setDependencyMetadata(metadata);
    return project;
}
Also used : ReactorProjectStub(org.eclipse.tycho.p2.impl.test.ReactorProjectStub) IDependencyMetadata(org.eclipse.tycho.p2.metadata.IDependencyMetadata) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock)

Example 4 with IDependencyMetadata

use of org.eclipse.tycho.p2.metadata.IDependencyMetadata in project tycho by eclipse.

the class P2DependencyResolver method getThisReactorProject.

private ReactorProject getThisReactorProject(MavenSession session, MavenProject project, TargetPlatformConfiguration configuration) {
    // 'this' project should obey optionalDependencies configuration
    final List<TargetEnvironment> environments = configuration.getEnvironments();
    final OptionalResolutionAction optionalAction = configuration.getDependencyResolverConfiguration().getOptionalResolutionAction();
    Map<String, IDependencyMetadata> dependencyMetadata = getDependencyMetadata(session, project, environments, optionalAction);
    final Set<Object> metadata = new LinkedHashSet<>();
    final Set<Object> secondaryMetadata = new LinkedHashSet<>();
    for (Map.Entry<String, IDependencyMetadata> entry : dependencyMetadata.entrySet()) {
        metadata.addAll(entry.getValue().getMetadata(true));
        secondaryMetadata.addAll(entry.getValue().getMetadata(false));
    }
    ReactorProject reactorProjet = new DefaultReactorProject(project) {

        @Override
        public Set<?> getDependencyMetadata(boolean primary) {
            return primary ? metadata : secondaryMetadata;
        }
    };
    return reactorProjet;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) OptionalResolutionAction(org.eclipse.tycho.core.resolver.shared.OptionalResolutionAction) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) IDependencyMetadata(org.eclipse.tycho.p2.metadata.IDependencyMetadata) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

IDependencyMetadata (org.eclipse.tycho.p2.metadata.IDependencyMetadata)4 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 LinkedHashSet (java.util.LinkedHashSet)2 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)2 MavenExecutionException (org.apache.maven.MavenExecutionException)1 PluginDescriptor (org.apache.maven.plugin.descriptor.PluginDescriptor)1 ComponentLookupException (org.codehaus.plexus.component.repository.exception.ComponentLookupException)1 ReactorProject (org.eclipse.tycho.ReactorProject)1 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)1 PluginFilter (org.eclipse.tycho.core.maven.utils.PluginRealmHelper.PluginFilter)1 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)1 OptionalResolutionAction (org.eclipse.tycho.core.resolver.shared.OptionalResolutionAction)1 AttachedArtifact (org.eclipse.tycho.p2.facade.internal.AttachedArtifact)1 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)1 ReactorProjectStub (org.eclipse.tycho.p2.impl.test.ReactorProjectStub)1