diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/DynamicPluginProjectReferences.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/DynamicPluginProjectReferences.java index 62cc5c170b..ea3a9c2aee 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/DynamicPluginProjectReferences.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/DynamicPluginProjectReferences.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Andrey Loskutov and others. + * Copyright (c) 2018, 2026 Andrey Loskutov and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,21 +13,21 @@ *******************************************************************************/ package org.eclipse.pde.internal.core; -import static java.util.Collections.singleton; -import static java.util.stream.Collectors.toList; - import java.util.Collections; import java.util.List; +import java.util.Objects; +import java.util.Set; import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IDynamicReferenceProvider; import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.osgi.service.resolver.BundleDescription; import org.eclipse.pde.core.plugin.IPluginModelBase; +import org.eclipse.pde.core.plugin.PluginRegistry; /** * Project references provider for JDT build to compute right build order with @@ -35,10 +35,6 @@ */ public class DynamicPluginProjectReferences implements IDynamicReferenceProvider { - public DynamicPluginProjectReferences() { - super(); - } - @Override public List getDependentProjects(IBuildConfiguration buildConfiguration) throws CoreException { IProject input = buildConfiguration.getProject(); @@ -46,13 +42,13 @@ public List getDependentProjects(IBuildConfiguration buildConfiguratio if (javaProject != null) { IPluginModelBase model = PDECore.getDefault().getModelManager().findModel(javaProject.getProject()); if (model != null) { - BundleDescription currentBundle = model.getBundleDescription(); - if (currentBundle != null) { - IWorkspaceRoot root = PDECore.getWorkspace().getRoot(); - return BuildDependencyCollector.collectBuildRelevantDependencies(singleton(currentBundle)).stream() - .filter(dependency -> dependency != currentBundle) - .map(dependency -> root.getProject(dependency.getName())).filter(IProject::exists) - .distinct().collect(toList()); + BundleDescription bundle = model.getBundleDescription(); + if (bundle != null) { + return BuildDependencyCollector.collectBuildRelevantDependencies(Set.of(bundle)).stream() + .map(b -> (org.osgi.resource.Resource) b) // + .filter(dependency -> dependency != bundle).map(PluginRegistry::findModel) + .map(IPluginModelBase::getUnderlyingResource).filter(Objects::nonNull) + .map(IResource::getProject).distinct().toList(); } } }