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
Expand Up @@ -224,6 +224,17 @@ public static boolean hasExtensibleAPI(IPluginModelBase model) {
return false;
}

public static String getPlatformFilter(IPluginModelBase model) {
IPluginBase pluginBase = model.getPluginBase();
if (pluginBase instanceof BundlePlugin plugin) {
return plugin.getPlatformFilter();
}
if (pluginBase instanceof BundleFragment fragment) {
return fragment.getPlatformFilter();
}
return null;
}

public static boolean isPatchFragment(Resource desc) {
IPluginModelBase model = PluginRegistry.findModel(desc);
return model instanceof IFragmentModel i ? isPatchFragment(i.getFragment()) : false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,19 @@ public enum Options {
* Specifies to include all non-test fragments into the closure (must
* not be combined with {@link #INCLUDE_ALL_FRAGMENTS}).
*/
INCLUDE_NON_TEST_FRAGMENTS;
INCLUDE_NON_TEST_FRAGMENTS,
/**
* Option that can be set to include native fragments, that are ones
* that define an {@link ICoreConstants#PLATFORM_FILTER} in their
* manifest.
*/
INCLUDE_PLATFORM_FRAGMENTS,
/**
* Option that can be set to include native fragments, that are ones
* that define an {@link ICoreConstants#PLATFORM_FILTER} in their
* manifest.
*/
INCLUDE_EXTENSIBLE_FRAGMENTS;
}

/**
Expand Down Expand Up @@ -168,6 +180,8 @@ public static Set<BundleDescription> findRequirementsClosure(Collection<BundleDe
boolean includeOptional = optionSet.contains(Options.INCLUDE_OPTIONAL_DEPENDENCIES);
boolean includeAllFragments = optionSet.contains(Options.INCLUDE_ALL_FRAGMENTS);
boolean includeNonTestFragments = optionSet.contains(Options.INCLUDE_NON_TEST_FRAGMENTS);
boolean includeNativeFragments = optionSet.contains(Options.INCLUDE_PLATFORM_FRAGMENTS);
boolean includeExtensibleFragments = optionSet.contains(Options.INCLUDE_EXTENSIBLE_FRAGMENTS);
if (includeAllFragments && includeNonTestFragments) {
throw new AssertionError("Cannot combine INCLUDE_ALL_FRAGMENTS and INCLUDE_NON_TEST_FRAGMENTS"); //$NON-NLS-1$
}
Expand All @@ -188,14 +202,22 @@ public static Set<BundleDescription> findRequirementsClosure(Collection<BundleDe
if (wiring == null || !wiring.isInUse()) {
continue;
}
if (includeAllFragments || includeNonTestFragments || isExtensibleApi(bundle)) {
if (includeAllFragments || includeNonTestFragments
|| (includeExtensibleFragments && isExtensibleApi(bundle))) {
// A fragment's host is already required by a wire
for (BundleDescription fragment : bundle.getFragments()) {
if (includeAllFragments || !isTestWorkspaceProject(fragment)) {
addNewRequiredBundle(fragment, closure, pending);
}
}
}
if (includeNativeFragments) {
for (BundleDescription fragment : bundle.getFragments()) {
if (isNativeFragment(fragment) && !isTestWorkspaceProject(fragment)) {
addNewRequiredBundle(fragment, closure, pending);
}
}
}

if (isFragment(wiring.getRevision())) {
// Requirements of a fragment are hosted at the host, which
Expand Down Expand Up @@ -231,6 +253,14 @@ public static Set<BundleDescription> findRequirementsClosure(Collection<BundleDe
return closure;
}

private static boolean isNativeFragment(BundleDescription fragment) {
Object userObject = fragment.getUserObject();
if (userObject instanceof IPluginModelBase model) {
return ClasspathUtilCore.getPlatformFilter(model) != null;
}
return false;
}

private static boolean isExtensibleApi(BundleDescription bundleDescription) {
if (bundleDescription.getFragments().length == 0) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ static class PluginInfo {
String localization;
String bundleSourceEntry;
boolean exportsExternalAnnotations;
String platformFilter;
}

/**
Expand Down Expand Up @@ -379,6 +380,7 @@ protected void addAuxiliaryData(BundleDescription desc, Map<String, String> mani
info.libraries = getClasspath(manifest);
info.hasExtensibleAPI = "true".equals(manifest.get(ICoreConstants.EXTENSIBLE_API)); //$NON-NLS-1$
info.isPatchFragment = "true".equals(manifest.get(ICoreConstants.PATCH_FRAGMENT)); //$NON-NLS-1$
info.platformFilter = manifest.get(ICoreConstants.PLATFORM_FILTER);
info.localization = manifest.get(Constants.BUNDLE_LOCALIZATION);
info.hasBundleStructure = hasBundleStructure;
info.bundleSourceEntry = manifest.get(ICoreConstants.ECLIPSE_SOURCE_BUNDLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,8 @@ public boolean isPatch() {
return "true".equals(getValue(ICoreConstants.PATCH_FRAGMENT, false)); //$NON-NLS-1$
}

public String getPlatformFilter() {
return getValue(ICoreConstants.PLATFORM_FILTER, false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@ public boolean exportsExternalAnnotations() {
return "true".equals(getValue(ICoreConstants.ECLIPSE_EXPORT_EXTERNAL_ANNOTATIONS, false)); //$NON-NLS-1$
}

public String getPlatformFilter() {
return getValue(ICoreConstants.PLATFORM_FILTER, false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public interface ILaunchingPreferenceConstants {

// Main preference page
public static final String PROP_AUTO_MANAGE = "Preferences.Launching.automanageDependencies"; //$NON-NLS-1$
public static final String PROP_AUTO_MANAGE_EXTENSIBLE_FRAGMENTS = "Preferences.Launching.automanageDependencies.includeExtensibleFragments"; //$NON-NLS-1$
public static final String PROP_AUTO_MANAGE_PLATFORM_FRAGMENTS = "Preferences.Launching.automanageDependencies.includePlatformFragments"; //$NON-NLS-1$
public static final String PROP_RUNTIME_WORKSPACE_LOCATION = "Preferences.Launching.runtimeWorkspaceLocation"; //$NON-NLS-1$
public static final String PROP_RUNTIME_WORKSPACE_LOCATION_IS_CONTAINER = "Preferences.Launching.runtimeWorkspaceLocationIsContainer"; //$NON-NLS-1$
public static final String PROP_JUNIT_WORKSPACE_LOCATION = "Preferences.Launching.junitWorkspaceLocation"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public void initializeDefaultPreferences() {
prefs.putBoolean(ILaunchingPreferenceConstants.PROP_JUNIT_ADD_NEW_WORKSPACE_PLUGINS, false);
prefs.putBoolean(ILaunchingPreferenceConstants.PROP_JUNIT_VALIDATE_LAUNCH, true);
prefs.putBoolean(ILaunchingPreferenceConstants.ADD_SWT_NON_DISPOSAL_REPORTING, true);
prefs.putBoolean(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE_EXTENSIBLE_FRAGMENTS, true);
prefs.putBoolean(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE_PLATFORM_FRAGMENTS, true);

// copy over instance scope prefs from UI plugin
IEclipsePreferences oldInstancePrefs = InstanceScope.INSTANCE.getNode(IPDEConstants.UI_PLUGIN_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.eclipse.pde.internal.core.DependencyManager;
import org.eclipse.pde.internal.core.FeatureModelManager;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.PDEPreferencesManager;
import org.eclipse.pde.internal.core.PluginModelManager;
import org.eclipse.pde.internal.core.TargetPlatformHelper;
import org.eclipse.pde.internal.core.ifeature.IFeature;
Expand All @@ -74,6 +75,7 @@
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
import org.eclipse.pde.internal.core.ifeature.IFeaturePlugin;
import org.eclipse.pde.internal.core.util.VersionUtil;
import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants;
import org.eclipse.pde.internal.launching.IPDEConstants;
import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
import org.eclipse.pde.internal.launching.PDEMessages;
Expand Down Expand Up @@ -168,11 +170,29 @@ private static void addRequiredBundles(Map<IPluginModelBase, String> bundle2star
List<String> appRequirements = RequirementHelper.getApplicationLaunchRequirements(configuration);
RequirementHelper.addApplicationLaunchRequirements(appRequirements, configuration, bundle2startLevel);

boolean includeOptional = configuration.getAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL, true);
computeDependencies(bundle2startLevel.keySet(), includeOptional, true) //
Set<DependencyManager.Options> options = configurationToOptions(configuration);
computeDependencies(bundle2startLevel.keySet(), options, true) //
.forEach(p -> addDefaultStartingBundle(bundle2startLevel, p));
}

protected static Set<DependencyManager.Options> configurationToOptions(ILaunchConfiguration configuration) throws CoreException {
boolean includeOptional = configuration.getAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL, true);
//TODO read everything from launch config
PDEPreferencesManager launchingStore = PDELaunchingPlugin.getDefault().getPreferenceManager();

Set<DependencyManager.Options> options = new HashSet<>();
if (includeOptional) {
options.add(DependencyManager.Options.INCLUDE_OPTIONAL_DEPENDENCIES);
}
if (launchingStore.getBoolean(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE_EXTENSIBLE_FRAGMENTS)) {
options.add(DependencyManager.Options.INCLUDE_EXTENSIBLE_FRAGMENTS);
}
if (launchingStore.getBoolean(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE_PLATFORM_FRAGMENTS)) {
options.add(DependencyManager.Options.INCLUDE_PLATFORM_FRAGMENTS);
}
return options;
}

// --- feature based launches ---

private static Map<IPluginModelBase, String> getMergedBundleMapFeatureBased(ILaunchConfiguration configuration, Map<IFeature, Boolean> features) throws CoreException {
Expand Down Expand Up @@ -221,12 +241,13 @@ private static Map<IPluginModelBase, String> getMergedBundleMapFeatureBased(ILau
launchPlugins.addAll(additionalPlugins.keySet());

if (addRequirements) {
Set<DependencyManager.Options> options = configurationToOptions(configuration);
// Add all missing plug-ins required by the application/product set in the config
List<String> appRequirements = RequirementHelper.getApplicationLaunchRequirements(configuration);
RequirementHelper.addApplicationLaunchRequirements(appRequirements, configuration, launchPlugins, launchPlugins::add);

// Get all required plugins
computeDependencies(launchPlugins, false, isWorkspace(defaultPluginResolution)).forEach(launchPlugins::add);
computeDependencies(launchPlugins, options, isWorkspace(defaultPluginResolution)).forEach(launchPlugins::add);
}

// Create the start levels for the selected plugins and add them to the map
Expand Down Expand Up @@ -542,7 +563,7 @@ private static void addBundleToMap(Map<IPluginModelBase, String> map, IPluginMod

// --- dependency resolution ---

private static Stream<IPluginModelBase> computeDependencies(Set<IPluginModelBase> includedPlugins, boolean includeOptional, boolean preferWorkspaceBundles) {
private static Stream<IPluginModelBase> computeDependencies(Set<IPluginModelBase> includedPlugins, Set<DependencyManager.Options> options, boolean preferWorkspaceBundles) {
if (includedPlugins.isEmpty()) {
return Stream.empty();
}
Expand All @@ -556,11 +577,7 @@ private static Stream<IPluginModelBase> computeDependencies(Set<IPluginModelBase
Version version = versionStr != null ? Version.parseVersion(versionStr) : null;
return launchState.getBundle(descriptor.getId(), version);
}).forEach(launchBundles::add);

DependencyManager.Options[] options = includeOptional //
? new DependencyManager.Options[] {DependencyManager.Options.INCLUDE_OPTIONAL_DEPENDENCIES}
: new DependencyManager.Options[] {};
Set<BundleDescription> closure = DependencyManager.findRequirementsClosure(launchBundles, options);
Set<BundleDescription> closure = DependencyManager.findRequirementsClosure(launchBundles, options.toArray(DependencyManager.Options[]::new));
return closure.stream().map(launchBundlePlugins::get).map(Objects::requireNonNull) //
.filter(p -> !includedPlugins.contains(p));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,14 @@ public class PDEUIMessages extends NLS {
public static String ConfigurationPageMock_sectionDesc;
public static String PluginConfigurationSection_tablePluginTitle;

public static String AbstractPluginBlock_addRequiredDialogIncludeAllFragments;

public static String AbstractPluginBlock_addRequiredDialogIncludeFragmentsWithoutTests;

public static String AbstractPluginBlock_addRequiredDialogIncludeOptional;

public static String AbstractPluginBlock_addRequiredDialogTitle;

public static String AbstractPluginBlock_counter;

public static String AbstractRepository_ErrorLoadingImageFromJar;
Expand Down Expand Up @@ -2711,6 +2719,12 @@ public class PDEUIMessages extends NLS {

public static String LaunchingPreferencePage_description;

public static String LaunchingPreferencePage_GroupComputingOptions;

public static String LaunchingPreferencePage_IncludeExtensibleFragments;

public static String LaunchingPreferencePage_IncludePlatformFragments;

public static String RemoveLazyLoadingDirectiveResolution_remove;

public static String RemoveAutomaticModuleResolution_remove;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.util.Util;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
Expand Down Expand Up @@ -415,11 +416,14 @@ public void createControl(Composite parent, int span, int indent) {
SelectionListener.widgetSelectedAdapter(e -> this.fAutoIncludeRequirementsButtonChanged = true));

if (fTab instanceof PluginsTab) {
fIncludeOptionalButton = createButton(parent, span, indent,PDEUIMessages.AdvancedLauncherTab_includeOptional_plugins);
fIncludeOptionalButton = createButton(parent, span, indent + 15,
PDEUIMessages.AdvancedLauncherTab_includeOptional_plugins);
}else if (fTab instanceof BundlesTab) {
fIncludeOptionalButton = createButton(parent, span, indent, PDEUIMessages.AdvancedLauncherTab_includeOptional_bundles);
fIncludeOptionalButton = createButton(parent, span, indent + 15,
PDEUIMessages.AdvancedLauncherTab_includeOptional_bundles);
}else{
fIncludeOptionalButton = createButton(parent, span, indent, NLS.bind(PDEUIMessages.AdvancedLauncherTab_includeOptional, fTab.getName().toLowerCase(Locale.ENGLISH)));
fIncludeOptionalButton = createButton(parent, span, indent + 15, NLS.bind(
PDEUIMessages.AdvancedLauncherTab_includeOptional, fTab.getName().toLowerCase(Locale.ENGLISH)));
}
if (fTab instanceof PluginsTab) {
fAddWorkspaceButton = createButton(parent, span, indent, PDEUIMessages.AdvancedLauncherTab_addNew_plugins);
Expand Down Expand Up @@ -868,22 +872,79 @@ protected void initializeButtonsFrom(ILaunchConfiguration config) throws CoreExc
* then also checked in the tree
*/
protected void addRequiredPlugins() {
Object[] checked = fPluginTreeViewer.getCheckedLeafElements();
List<IPluginModelBase> toCheck = Arrays.stream(checked).filter(IPluginModelBase.class::isInstance)
.map(IPluginModelBase.class::cast).collect(Collectors.toList());
Set<DependencyManager.Options> options = new HashSet<>();
options.add(Options.INCLUDE_NON_TEST_FRAGMENTS);
options.add(Options.INCLUDE_OPTIONAL_DEPENDENCIES);
Dialog dialog = new Dialog(fPluginTreeViewer.getControl().getShell()) {

DependencyManager.Options[] options = fIncludeOptionalButton.getSelection()
? new Options[] { Options.INCLUDE_NON_TEST_FRAGMENTS, Options.INCLUDE_OPTIONAL_DEPENDENCIES }
: new Options[] { Options.INCLUDE_NON_TEST_FRAGMENTS };
Set<BundleDescription> additionalBundles = DependencyManager.getDependencies(toCheck, options);
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
Button buttonFragmentsAll = new Button(composite, SWT.RADIO);
Button buttonFragmentNonTest = new Button(composite, SWT.RADIO);
Button buttonOptional = new Button(composite, SWT.CHECK);
buttonFragmentNonTest.setText(PDEUIMessages.AbstractPluginBlock_addRequiredDialogIncludeFragmentsWithoutTests);
buttonFragmentNonTest.setSelection(true);
SelectionListener radioListener = new SelectionListener() {

@Override
public void widgetSelected(SelectionEvent e) {
if (buttonFragmentNonTest.getSelection()) {
options.add(Options.INCLUDE_NON_TEST_FRAGMENTS);
options.remove(Options.INCLUDE_ALL_FRAGMENTS);
} else {
options.remove(Options.INCLUDE_NON_TEST_FRAGMENTS);
options.add(Options.INCLUDE_ALL_FRAGMENTS);
}
}

@Override
public void widgetDefaultSelected(SelectionEvent e) {

additionalBundles.stream().map(Resource.class::cast).map(PluginRegistry::findModel).filter(Objects::nonNull)
.forEach(toCheck::add);
}
};
buttonFragmentNonTest.addSelectionListener(radioListener);
buttonFragmentsAll.setText(PDEUIMessages.AbstractPluginBlock_addRequiredDialogIncludeAllFragments);
buttonFragmentsAll.addSelectionListener(radioListener);
buttonOptional.setSelection(true);
buttonOptional.setText(PDEUIMessages.AbstractPluginBlock_addRequiredDialogIncludeOptional);
buttonOptional.addSelectionListener(new SelectionListener() {

@Override
public void widgetSelected(SelectionEvent e) {
if (buttonOptional.getSelection()) {
options.add(Options.INCLUDE_OPTIONAL_DEPENDENCIES);
} else {
options.remove(Options.INCLUDE_OPTIONAL_DEPENDENCIES);
}
}

checked = toCheck.toArray();
setCheckedElements(checked);
@Override
public void widgetDefaultSelected(SelectionEvent e) {

countSelectedModels();
}
});
return composite;
}

@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(PDEUIMessages.AbstractPluginBlock_addRequiredDialogTitle);
}
};
if (dialog.open() == Window.OK) {
Object[] checked = fPluginTreeViewer.getCheckedLeafElements();
List<IPluginModelBase> toCheck = Arrays.stream(checked).filter(IPluginModelBase.class::isInstance)
.map(IPluginModelBase.class::cast).collect(Collectors.toList());
Set<BundleDescription> additionalBundles = DependencyManager.getDependencies(toCheck,
options.toArray(DependencyManager.Options[]::new));
additionalBundles.stream().map(Resource.class::cast).map(PluginRegistry::findModel).filter(Objects::nonNull)
.forEach(toCheck::add);
checked = toCheck.toArray();
setCheckedElements(checked);
countSelectedModels();
}
}

protected IPluginModelBase findPlugin(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,10 @@ SchemaElementDetails_title=Element Details
SchemaElementDetails_rootTitle=Extension Element Details
SchemaAttributeDetails_use=Use:

AbstractPluginBlock_addRequiredDialogIncludeAllFragments=Include all fragments
AbstractPluginBlock_addRequiredDialogIncludeFragmentsWithoutTests=Include fragments, except those containing tests
AbstractPluginBlock_addRequiredDialogIncludeOptional=Include optional dependencies
AbstractPluginBlock_addRequiredDialogTitle=Choose Options
AbstractPluginBlock_counter={0} out of {1} selected
AbstractTargetPage_setTarget=Set as Active Target Platform
AbstractTargetPage_reloadTarget=Reload Target Platform
Expand Down Expand Up @@ -2193,6 +2197,9 @@ LauncherSection_launcherName=Launcher Name:
LauncherSection_dialogTitle=Image Selection
LauncherSection_dialogMessage=Select an image:
LaunchingPreferencePage_description=Settings for Plug-in launches
LaunchingPreferencePage_GroupComputingOptions=When computing required Plug-ins
LaunchingPreferencePage_IncludeExtensibleFragments=Include Fragment of Extensible-API Plug-ins
LaunchingPreferencePage_IncludePlatformFragments=Include Platform Specific Fragment
RemoveLazyLoadingDirectiveResolution_remove=Remove lazy activation header
RemoveAutomaticModuleResolution_remove=Remove automatic module name header
ProductDefinitonWizardPage_applicationDefinition=<form><p>An Eclipse product must be associated with an <a href="applications">application</a>, the default entry point for the product when it is running.</p></form>
Expand Down
Loading
Loading