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);
}
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;
}
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;
}
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;
}
Aggregations