Search in sources :

Example 1 with PluginFilter

use of org.eclipse.tycho.core.maven.utils.PluginRealmHelper.PluginFilter 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)

Aggregations

HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 MavenExecutionException (org.apache.maven.MavenExecutionException)1 PluginDescriptor (org.apache.maven.plugin.descriptor.PluginDescriptor)1 ComponentLookupException (org.codehaus.plexus.component.repository.exception.ComponentLookupException)1 PluginFilter (org.eclipse.tycho.core.maven.utils.PluginRealmHelper.PluginFilter)1 AttachedArtifact (org.eclipse.tycho.p2.facade.internal.AttachedArtifact)1 IDependencyMetadata (org.eclipse.tycho.p2.metadata.IDependencyMetadata)1