From 3980b4996b8468b0377bdcf79a5846764d7cc890 Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Wed, 20 Sep 2023 00:35:53 +0200 Subject: [PATCH] [FIXUP] Update all entries, retained and reloaded ones --- .../pde/internal/core/ClasspathComputer.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathComputer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathComputer.java index 6458e5e4c53..d21a6e834d4 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathComputer.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathComputer.java @@ -55,7 +55,7 @@ public class ClasspathComputer { - private record ClasspathConfiguration(IPluginModelBase model, IJavaProject javaProject, boolean isTestPlugin, + private record ClasspathConfiguration(IPluginModelBase model, IJavaProject javaProject, IClasspathAttribute[] defaultAttrs, Map originalByPath, List reloaded) { } @@ -74,8 +74,8 @@ public static IClasspathEntry[] getClasspath(IProject project, IPluginModelBase IJavaProject javaProject = JavaCore.create(project); List originalClasspath = clear ? List.of() : Arrays.asList(javaProject.getRawClasspath()); ClasspathConfiguration context = new ClasspathConfiguration(model, javaProject, - hasTestPluginName(project), getClasspathAttributes(project, model), - mapFirstSeenByPath(originalClasspath.stream()), new ArrayList<>()); + getClasspathAttributes(project, model), mapFirstSeenByPath(originalClasspath.stream()), + new ArrayList<>()); // add JRE and set compliance options String ee = getExecutionEnvironment(model.getBundleDescription()); @@ -88,7 +88,8 @@ public static IClasspathEntry[] getClasspath(IProject project, IPluginModelBase // add own libraries/source addSourceAndLibraries(sourceLibraryMap != null ? sourceLibraryMap : Collections.emptyMap(), context); - IClasspathEntry[] entries = collectInOriginalOrder(originalClasspath, context.reloaded); + boolean isTestPlugin = hasTestPluginName(project); + IClasspathEntry[] entries = collectInOriginalOrder(originalClasspath, context.reloaded, isTestPlugin); IJavaModelStatus validation = JavaConventions.validateClasspath(javaProject, entries, javaProject.getOutputLocation()); if (!validation.isOK()) { PDECore.logErrorMessage(validation.getMessage()); @@ -98,7 +99,7 @@ public static IClasspathEntry[] getClasspath(IProject project, IPluginModelBase } private static IClasspathEntry[] collectInOriginalOrder(List originalClasspath, - List reloaded) { + List reloaded, boolean isTestPlugin) { // preserve original entries which eventually weren't reloaded Map resultingReloadedByPath = mapFirstSeenByPath(reloaded.stream()); List result = new ArrayList<>(originalClasspath); @@ -108,6 +109,7 @@ private static IClasspathEntry[] collectInOriginalOrder(List or }); // using the order of reloading, append new entries (in the map still) result.addAll(resultingReloadedByPath.values()); + result.replaceAll(e -> updateTestAttribute(isTestPlugin, e)); return result.toArray(IClasspathEntry[]::new); } @@ -236,12 +238,7 @@ private static void addSourceFolders(IBuildEntry buildEntry, ClasspathConfigurat continue; } } - if (context.isTestPlugin) { - context.reloaded.add(JavaCore.newSourceEntry(path, null, null, null, new IClasspathAttribute[] { - JavaCore.newClasspathAttribute(IClasspathAttribute.TEST, "true") })); //$NON-NLS-1$ - } else { - context.reloaded.add(JavaCore.newSourceEntry(path)); - } + context.reloaded.add(JavaCore.newSourceEntry(path)); } }