use of org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts 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);
}
}
use of org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts 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;
}
use of org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts in project tycho by eclipse.
the class BuildQualifierTest method testAggregateAttachedFeatureQualifier.
public void testAggregateAttachedFeatureQualifier() throws Exception {
File basedir = getBasedir("projects/stablebuildqualifier/attachedfeature");
List<MavenProject> projects = getSortedProjects(basedir, new File(basedir, "targetplatform"));
MavenProject project = getProject(projects, "attachedfeature");
ReactorProject reactorProject = DefaultReactorProject.adapt(project);
DefaultDependencyArtifacts dependencyArtifacts = (DefaultDependencyArtifacts) TychoProjectUtils.getDependencyArtifacts(project);
// replace target platform dependencies with fake attached feature and bundle atrifacts
ArtifactDescriptor attachedFeature = dependencyArtifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_FEATURE, "attachedfeature.attached.feature", null);
dependencyArtifacts.removeAll(attachedFeature.getKey().getType(), attachedFeature.getKey().getId());
dependencyArtifacts.addReactorArtifact(attachedFeature.getKey(), reactorProject, "attached-feature", attachedFeature.getInstallableUnits());
ArtifactDescriptor attachedBundle = dependencyArtifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_PLUGIN, "attachedfeature.attached.bundle", null);
dependencyArtifacts.removeAll(attachedBundle.getKey().getType(), attachedBundle.getKey().getId());
dependencyArtifacts.addReactorArtifact(attachedBundle.getKey(), reactorProject, "attached-bundle", attachedBundle.getInstallableUnits());
MavenSession session = newMavenSession(projects.get(0), projects);
executeMojo(session, project, "build-qualifier-aggregator");
assertQualifier("201206180600", projects, "attachedfeature");
}
use of org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts in project tycho by eclipse.
the class DefaultDependencyArtifactsTest method testRelativePath.
@Test
public void testRelativePath() throws IOException {
DefaultDependencyArtifacts tp = new DefaultDependencyArtifacts();
File relative = new File("relative.xml");
File canonical = new File("canonical.xml");
tp.addArtifactFile(new DefaultArtifactKey("foo", "relative", "1"), relative, null);
tp.addArtifactFile(new DefaultArtifactKey("foo", "canonical", "1"), canonical.getAbsoluteFile(), null);
Assert.assertNotNull(tp.getArtifact(relative.getAbsoluteFile()));
Assert.assertNotNull(tp.getArtifact(canonical));
}
use of org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts in project tycho by eclipse.
the class DefaultDependencyArtifactsTest method testEqualArtifacts.
@Test
public void testEqualArtifacts() {
DefaultDependencyArtifacts tp = new DefaultDependencyArtifacts();
ArtifactKey key = new DefaultArtifactKey("type", "id", "version");
File location = new File("location");
tp.addArtifactFile(key, location, asSet("a"));
tp.addArtifactFile(key, location, asSet("a"));
Assert.assertEquals(1, tp.getArtifacts().size());
}
Aggregations