Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2022 IBM Corporation and others.
* Copyright (c) 2007, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -66,6 +66,7 @@
import org.eclipse.pde.internal.build.IPDEBuildConstants;
import org.eclipse.pde.internal.core.DependencyManager;
import org.eclipse.pde.internal.core.FeatureModelManager;
import org.eclipse.pde.internal.core.ICoreConstants;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.PluginModelManager;
import org.eclipse.pde.internal.core.TargetPlatformHelper;
Expand Down Expand Up @@ -352,10 +353,20 @@ private static IFeature getRequiredFeature(String id, String version, int versio
private static final Predicate<IPluginModelBase> ENABLED_VALID_PLUGIN_FILTER = p -> p.getBundleDescription() != null && p.isEnabled();
private static final Function<IPluginModelBase, String> GET_PLUGIN_VERSION = m -> m.getPluginBase().getVersion();
private static final Comparator<IPluginModelBase> COMPARE_PLUGIN_RESOLVED = comparing(p -> p.getBundleDescription().isResolved());
private static final BiPredicate<IPluginModelBase, Version> EXACT_PLUGIN_VERSION = (e, v) -> Version.parseVersion(GET_PLUGIN_VERSION.apply(e)).equals(v);

private static IPluginModelBase getIncludedPlugin(String id, String version, String pluginLocation) {
List<List<IPluginModelBase>> plugins = getPlugins(id, pluginLocation);
return getIncluded(plugins, ENABLED_VALID_PLUGIN_FILTER, GET_PLUGIN_VERSION, COMPARE_PLUGIN_RESOLVED, version);
return getIncluded(plugins, ENABLED_VALID_PLUGIN_FILTER, GET_PLUGIN_VERSION, getIncludedPluginComparator(version), version);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not quite happy with doing the change here. I'll try to have a look later today to move it down into the getIncluded(...) method, so that it's in the same place as the already existing version logic.

}

private static Comparator<IPluginModelBase> getIncludedPluginComparator(String versionString) {
if (ICoreConstants.DEFAULT_VERSION.equals(versionString)) {
return COMPARE_PLUGIN_RESOLVED;
}
Version version = Version.parseVersion(versionString);
return Comparator.<IPluginModelBase, Boolean> comparing(e -> EXACT_PLUGIN_VERSION.test(e, version)) // false < true
.thenComparing(COMPARE_PLUGIN_RESOLVED);
}

private static IPluginModelBase getRequiredPlugin(String id, String version, int versionMatchRule, String pluginLocation) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2022 Julian Honnen and others.
* Copyright (c) 2019, 2026 Julian Honnen and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -822,6 +822,32 @@ public void testGetMergedBundleMap_requiredPluginWithSpecificVersion2() throws T
}
}

@Test
public void testGetMergedBundleMap_requiredPluginWithSpecificVersion3() throws Throwable {
var targetBundles = ofEntries( //
bundle("plugin.a", "1.0.0", entry(IMPORT_PACKAGE, "test;version=\"1.0.0\""),
entry(EXPORT_PACKAGE, "test;version=\"1.0.0\"")), //
bundle("plugin.a", "2.0.0", entry(IMPORT_PACKAGE, "test;version=\"2.0.0\""),
entry(EXPORT_PACKAGE, "test;version=\"2.0.0\"")), //
bundle("plugin.b", "1.0.0", entry(IMPORT_PACKAGE, "test;version=\"[1.0.0,2.0.0)\"")), //
bundle("plugin.b", "2.0.0", entry(IMPORT_PACKAGE, "test;version=\"[2.0.0,3.0.0)\"")));

var targetFeatures = List.of( //
targetFeature("feature.a", "1.0.0", f -> {
addIncludedPlugin(f, "plugin.a", "1.0.0");
addIncludedPlugin(f, "plugin.b", "1.0.0");
}));

setTargetPlatform(targetBundles, targetFeatures);

ILaunchConfigurationWorkingCopy lc = createFeatureLaunchConfig();
lc.setAttribute(IPDELauncherConstants.FEATURE_DEFAULT_LOCATION, IPDELauncherConstants.LOCATION_WORKSPACE);
lc.setAttribute(IPDELauncherConstants.SELECTED_FEATURES, Set.of("feature.a:default"));

assertGetMergedBundleMap("featureResolution workspace", lc,
Set.of(targetBundle("plugin.a", "1.0.0"), targetBundle("plugin.b", "1.0.0")));
}

// --- required/imported feature dependencies ---

@Test
Expand Down
Loading