use of org.eclipse.tycho.core.TargetPlatformConfiguration in project tycho by eclipse.
the class LocalDependencyResolver method addDependencies.
private void addDependencies(MavenSession session, MavenProject project, DefaultDependencyArtifacts platform) {
TargetPlatformConfiguration configuration = (TargetPlatformConfiguration) project.getContextValue(TychoConstants.CTX_TARGET_PLATFORM_CONFIGURATION);
if (configuration != null && TargetPlatformConfiguration.POM_DEPENDENCIES_CONSIDER.equals(configuration.getPomDependencies())) {
Map<String, MavenProject> projectIds = new HashMap<>(session.getProjects().size() * 2);
// make a list of reactor projects
for (MavenProject p : session.getProjects()) {
String key = ArtifactUtils.key(p.getGroupId(), p.getArtifactId(), p.getVersion());
projectIds.put(key, p);
}
// handle dependencies that are in reactor
for (Dependency dependency : project.getDependencies()) {
if (Artifact.SCOPE_COMPILE.equals(dependency.getScope())) {
String key = ArtifactUtils.key(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion());
if (projectIds.containsKey(key)) {
MavenProject dependent = projectIds.get(key);
ArtifactKey artifactKey = getArtifactKey(session, dependent);
if (artifactKey != null) {
platform.removeAll(artifactKey.getType(), artifactKey.getId());
ReactorProject projectProxy = DefaultReactorProject.adapt(dependent);
platform.addReactorArtifact(artifactKey, projectProxy, null, null);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Add Maven project " + artifactKey);
}
}
}
}
}
// handle rest of dependencies
ArrayList<String> scopes = new ArrayList<>();
scopes.add(Artifact.SCOPE_COMPILE);
Collection<Artifact> artifacts;
try {
artifacts = projectDependenciesResolver.resolve(project, scopes, session);
} catch (MultipleArtifactsNotFoundException e) {
Collection<Artifact> missing = new HashSet<>(e.getMissingArtifacts());
for (Iterator<Artifact> it = missing.iterator(); it.hasNext(); ) {
Artifact a = it.next();
String key = ArtifactUtils.key(a.getGroupId(), a.getArtifactId(), a.getBaseVersion());
if (projectIds.containsKey(key)) {
it.remove();
}
}
if (!missing.isEmpty()) {
throw new RuntimeException("Could not resolve project dependencies", e);
}
artifacts = e.getResolvedArtifacts();
artifacts.removeAll(e.getMissingArtifacts());
} catch (AbstractArtifactResolutionException e) {
throw new RuntimeException("Could not resolve project dependencies", e);
}
for (Artifact artifact : artifacts) {
String key = ArtifactUtils.key(artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion());
if (!projectIds.containsKey(key)) {
File plugin = artifact.getFile();
ArtifactKey artifactKey = getArtifactKey(session, plugin);
if (artifactKey != null) {
platform.addArtifactFile(artifactKey, plugin, null);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Add Maven artifact " + artifactKey);
}
}
}
}
}
}
use of org.eclipse.tycho.core.TargetPlatformConfiguration in project tycho by eclipse.
the class AbstractArtifactBasedProject method checkForMissingDependencies.
@Override
public void checkForMissingDependencies(MavenProject project) {
TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
// this throws exceptions when dependencies are missing
getDependencyWalker(project).walk(new ArtifactDependencyVisitor() {
});
}
use of org.eclipse.tycho.core.TargetPlatformConfiguration in project tycho by eclipse.
the class EquinoxResolver method getPlatformProperties.
protected Properties getPlatformProperties(MavenProject project, ExecutionEnvironment ee) {
TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
TargetEnvironment environment = configuration.getEnvironments().get(0);
Properties properties = new Properties();
properties.putAll((Properties) project.getContextValue(TychoConstants.CTX_MERGED_PROPERTIES));
return getPlatformProperties(properties, environment, ee);
}
use of org.eclipse.tycho.core.TargetPlatformConfiguration in project tycho by eclipse.
the class OsgiBundleProject method readExecutionEnvironmentConfiguration.
@Override
public void readExecutionEnvironmentConfiguration(MavenProject project, ExecutionEnvironmentConfiguration sink) {
// read packaging-type independent configuration
super.readExecutionEnvironmentConfiguration(project, sink);
// only in plugin projects, the profile may also be ...
// ... specified in build.properties (for PDE compatibility)
String pdeProfile = getEclipsePluginProject(DefaultReactorProject.adapt(project)).getBuildProperties().getJreCompilationProfile();
if (pdeProfile != null) {
sink.setProfileConfiguration(pdeProfile.trim(), "build.properties");
} else {
// ... derived from BREE in bundle manifest
StandardExecutionEnvironment[] manifestBREEs = getManifest(project).getExecutionEnvironments();
if (manifestBREEs.length > 0) {
TargetPlatformConfiguration tpConfiguration = TychoProjectUtils.getTargetPlatformConfiguration(project);
switch(tpConfiguration.getBREEHeaderSelectionPolicy()) {
case first:
sink.setProfileConfiguration(manifestBREEs[0].getProfileName(), "Bundle-RequiredExecutionEnvironment (first entry)");
break;
case minimal:
ExecutionEnvironment manifestMinimalEE = Collections.min(Arrays.asList(manifestBREEs));
sink.setProfileConfiguration(manifestMinimalEE.getProfileName(), "Bundle-RequiredExecutionEnvironment (minimal entry)");
}
}
}
}
use of org.eclipse.tycho.core.TargetPlatformConfiguration 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);
}
Aggregations