use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.
the class TargetPlatformFactoryImpl method getPreliminaryReactorProjectUIs.
private Map<IInstallableUnit, ReactorProjectIdentities> getPreliminaryReactorProjectUIs(List<ReactorProject> reactorProjects) throws DuplicateReactorIUsException {
if (reactorProjects == null) {
return Collections.emptyMap();
}
Map<IInstallableUnit, ReactorProjectIdentities> reactorUIs = new HashMap<>();
Map<IInstallableUnit, Set<File>> duplicateReactorUIs = new HashMap<>();
for (ReactorProject project : reactorProjects) {
@SuppressWarnings("unchecked") Set<IInstallableUnit> projectIUs = (Set<IInstallableUnit>) project.getDependencyMetadata();
if (projectIUs == null)
continue;
for (IInstallableUnit iu : projectIUs) {
ReactorProjectIdentities otherOrigin = reactorUIs.put(iu, project.getIdentities());
if (otherOrigin != null && !otherOrigin.equals(project.getIdentities())) {
Set<File> duplicateLocations = duplicateReactorUIs.get(iu);
if (duplicateLocations == null) {
duplicateLocations = new LinkedHashSet<>();
duplicateReactorUIs.put(iu, duplicateLocations);
}
duplicateLocations.add(otherOrigin.getBasedir());
duplicateLocations.add(project.getBasedir());
}
}
}
if (!duplicateReactorUIs.isEmpty()) {
// TODO 392320 we should only fail if IUs with same id and version but different content are found
throw new DuplicateReactorIUsException(duplicateReactorUIs);
}
return reactorUIs;
}
use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.
the class TargetPlatformFactoryTest method testConfiguredFiltersOnReactorIUsInPreliminaryTP.
// TODO 372035 test logging for potential bugs in the explicit filters configuration
@Test
public void testConfiguredFiltersOnReactorIUsInPreliminaryTP() throws Exception {
TargetPlatformFilter filter = TargetPlatformFilter.removeAllFilter(CapabilityPattern.patternWithoutVersion(CapabilityType.P2_INSTALLABLE_UNIT, "iu.p2.inf"));
tpConfig.addFilters(Arrays.asList(filter));
ReactorProject reactorProject = createReactorProject("artifactId", "test.feature.feature.group", "iu.p2.inf");
P2TargetPlatform preliminaryTP = subject.createTargetPlatform(tpConfig, NOOP_EE_RESOLUTION_HANDLER, Collections.singletonList(reactorProject), null);
assertThat(preliminaryTP.getInstallableUnits(), hasItem(unitWithId("test.feature.feature.group")));
assertThat(preliminaryTP.getInstallableUnits(), not(hasItem(unitWithId("iu.p2.inf"))));
}
use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.
the class TargetPlatformFactoryTest method testOtherVersionsOfReactorIUsAreFilteredFromExternalContent.
@Test
public void testOtherVersionsOfReactorIUsAreFilteredFromExternalContent() throws Exception {
// contains trt.bundle/1.0.0.201108051343
tpConfig.addP2Repository(ResourceUtil.resourceFile("targetresolver/v1_content").toURI());
// reactor artifact produces a unit with same ID
ReactorProject reactorProject = createReactorProject("artifactId", "trt.bundle/1.5.5.qualifier", null);
P2TargetPlatform preliminaryTP = subject.createTargetPlatform(tpConfig, NOOP_EE_RESOLUTION_HANDLER, Collections.singletonList(reactorProject), null);
assertThat(preliminaryTP.getInstallableUnits(), hasItem(unit("trt.bundle", "1.5.5.qualifier")));
assertThat(preliminaryTP.getInstallableUnits(), not(hasItem(unit("trt.bundle", "1.0.0.201108051343"))));
Map<IInstallableUnit, ReactorProjectIdentities> finalUnits = Collections.singletonMap(InstallableUnitUtil.createIU("trt.bundle", "1.5.5.20140216"), reactorProject.getIdentities());
P2TargetPlatform finalTP = subject.createTargetPlatformWithUpdatedReactorUnits(preliminaryTP, finalUnits, REACTOR_ARTIFACTS);
assertThat(finalTP.getInstallableUnits(), hasItem(unit("trt.bundle", "1.5.5.20140216")));
assertThat(finalTP.getInstallableUnits(), not(hasItem(unit("trt.bundle", "1.0.0.201108051343"))));
}
use of org.eclipse.tycho.ReactorProject 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.ReactorProject in project tycho by eclipse.
the class AbstractArtifactDependencyWalker method traverseFeature.
protected void traverseFeature(File location, Feature feature, FeatureRef featureRef, ArtifactDependencyVisitor visitor, WalkbackPath visited) {
ArtifactDescriptor artifact = getArtifact(location, feature.getId());
if (artifact == null) {
// ah?
throw new IllegalStateException("Feature " + location + " with id " + feature.getId() + " is not part of the project build target platform");
}
ArtifactKey key = artifact.getKey();
ReactorProject project = artifact.getMavenProject();
String classifier = artifact.getClassifier();
Set<Object> installableUnits = artifact.getInstallableUnits();
DefaultFeatureDescription description = new DefaultFeatureDescription(key, location, project, classifier, feature, featureRef, installableUnits);
if (visitor.visitFeature(description)) {
for (PluginRef ref : feature.getPlugins()) {
traversePlugin(ref, visitor, visited);
}
for (FeatureRef ref : feature.getIncludedFeatures()) {
traverseFeature(ref, visitor, visited);
}
}
}
Aggregations