Skip to content

Commit

Permalink
Add required o.e.osgi bundle for subclasses of EquinoxLaunchConfig too (
Browse files Browse the repository at this point in the history
#33)

Fixes #32

Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
  • Loading branch information
HannesWell authored Apr 27, 2022
1 parent 8c108d0 commit 96d307b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public static Map<IPluginModelBase, String> getAllSelectedPluginBundles(ILaunchC

private static void addRequiredBundles(Map<IPluginModelBase, String> bundle2startLevel, ILaunchConfiguration configuration) throws CoreException {

RequirementHelper.addApplicationLaunchRequirements(bundle2startLevel, configuration);
List<String> appRequirements = RequirementHelper.getApplicationLaunchRequirements(configuration);
RequirementHelper.addApplicationLaunchRequirements(appRequirements, configuration, bundle2startLevel);

boolean includeOptional = configuration.getAttribute(IPDELauncherConstants.INCLUDE_OPTIONAL, true);
Set<BundleDescription> requiredDependencies = includeOptional //
Expand Down Expand Up @@ -167,7 +168,8 @@ private static Map<IPluginModelBase, String> getMergedBundleMapFeatureBased(ILau

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

// Get all required plugins
Set<BundleDescription> additionalBundles = DependencyManager.getDependencies(launchPlugins);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,15 @@ public static List<String> getApplicationLaunchRequirements(ILaunchConfiguration
return requirementsFunction != null ? Objects.requireNonNull(requirementsFunction.getRequiredBundleIds(config)) : Collections.emptyList();
}

public static boolean addApplicationLaunchRequirements(Map<IPluginModelBase, String> bundle2startLevel, ILaunchConfiguration configuration) throws CoreException {
public static boolean addApplicationLaunchRequirements(List<String> appRequirements, ILaunchConfiguration configuration, Map<IPluginModelBase, String> bundle2startLevel) throws CoreException {
Consumer<IPluginModelBase> addPlugin = b -> BundleLauncherHelper.addDefaultStartingBundle(bundle2startLevel, b);
return addApplicationLaunchRequirements(configuration, bundle2startLevel.keySet(), addPlugin);
return addApplicationLaunchRequirements(appRequirements, configuration, bundle2startLevel.keySet(), addPlugin);
}

public static boolean addApplicationLaunchRequirements(ILaunchConfiguration configuration, Set<IPluginModelBase> containedPlugins, Consumer<IPluginModelBase> addPlugin) throws CoreException {
public static boolean addApplicationLaunchRequirements(List<String> appRequirements, ILaunchConfiguration configuration, Set<IPluginModelBase> containedPlugins, Consumer<IPluginModelBase> addPlugin) throws CoreException {
boolean isFeatureBasedLaunch = configuration.getAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, false);
String pluginResolution = isFeatureBasedLaunch ? configuration.getAttribute(IPDELauncherConstants.FEATURE_PLUGIN_RESOLUTION, IPDELauncherConstants.LOCATION_WORKSPACE) : IPDELauncherConstants.LOCATION_WORKSPACE;

List<String> appRequirements = getApplicationLaunchRequirements(configuration);
boolean allRequirementsSatisfied = true;
for (String requiredBundleId : appRequirements) {
ModelEntry entry = PluginRegistry.findEntry(requiredBundleId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private void appendStartData(StringBuilder buffer, String startData, boolean def
protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
fModels = BundleLauncherHelper.getMergedBundleMap(configuration, true);

if (!RequirementHelper.addApplicationLaunchRequirements(fModels, configuration)) {
if (!RequirementHelper.addApplicationLaunchRequirements(List.of(IPDEBuildConstants.BUNDLE_OSGI), configuration, fModels)) {
throw new CoreException(Status.error(PDEMessages.EquinoxLaunchConfiguration_oldTarget));
}
fAllBundles = fModels.keySet().stream().collect(Collectors.groupingBy(m -> m.getPluginBase().getId(), HashMap::new, Collectors.toCollection(ArrayList::new)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.eclipse.pde.internal.launching.IPDEConstants;
import org.eclipse.pde.internal.launching.PDEMessages;
import org.eclipse.pde.internal.launching.launcher.*;
import org.eclipse.pde.launching.IPDELauncherConstants;

/**
* A launch delegate for launching the Equinox framework
Expand Down Expand Up @@ -162,7 +161,7 @@ private void appendStartData(StringBuilder buffer, String startData, boolean def
protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
fModels = BundleLauncherHelper.getMergedBundleMap(configuration, true);

if (!RequirementHelper.addApplicationLaunchRequirements(fModels, configuration)) {
if (!RequirementHelper.addApplicationLaunchRequirements(List.of(IPDEBuildConstants.BUNDLE_OSGI), configuration, fModels)) {
throw new CoreException(Status.error(PDEMessages.EquinoxLaunchConfiguration_oldTarget));
}
fAllBundles = fModels.keySet().stream().collect(Collectors.groupingBy(m -> m.getPluginBase().getId(),
Expand Down

0 comments on commit 96d307b

Please sign in to comment.