-
Notifications
You must be signed in to change notification settings - Fork 165
org.eclipse.core.contenttype: osgi.extender=osgi.component requirement #2162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,8 +19,9 @@ | |
| import java.io.OutputStream; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.util.ArrayList; | ||
| import java.util.Collection; | ||
| import java.util.HashSet; | ||
| import java.util.LinkedHashSet; | ||
| import java.util.Objects; | ||
| import java.util.Optional; | ||
| import java.util.Properties; | ||
|
|
@@ -36,6 +37,8 @@ | |
| import org.osgi.framework.Constants; | ||
| import org.osgi.framework.FrameworkUtil; | ||
| import org.osgi.framework.Version; | ||
| import org.osgi.framework.wiring.BundleWire; | ||
| import org.osgi.framework.wiring.BundleWiring; | ||
|
|
||
| @SuppressWarnings("restriction") | ||
| public class CustomSessionConfigurationImpl implements CustomSessionConfiguration { | ||
|
|
@@ -48,7 +51,7 @@ public class CustomSessionConfigurationImpl implements CustomSessionConfiguratio | |
| private static final String PROP_SHARED_CONFIG_AREA = "osgi.sharedConfiguration.area"; | ||
| private static final String TEMP_DIR_PREFIX = "eclipse_session_configuration"; | ||
|
|
||
| private final Collection<BundleReference> bundleReferences = new ArrayList<>(); | ||
| private final Collection<BundleReference> bundleReferences = new LinkedHashSet<>(); | ||
| private Path configurationDirectory; | ||
| private boolean readOnly = false; | ||
| private boolean cascaded = false; | ||
|
|
@@ -58,6 +61,18 @@ public CustomSessionConfigurationImpl() { | |
| addMinimalBundleSet(); | ||
| } | ||
|
|
||
| private static void collectDependencies(Bundle bundle, Collection<Bundle> dependencyClosure) { | ||
| if (!dependencyClosure.add(bundle)) { | ||
| return; | ||
| } | ||
| BundleWiring wiring = bundle.adapt(BundleWiring.class); | ||
| if (wiring != null) { | ||
| for (BundleWire wire : wiring.getRequiredWires(null)) { | ||
| collectDependencies(wire.getProviderWiring().getBundle(), dependencyClosure); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @SuppressWarnings("deprecation") | ||
| private void addMinimalBundleSet() { | ||
| // Just use any class from the bundles we want to add as minimal bundle set | ||
|
|
@@ -71,6 +86,12 @@ private void addMinimalBundleSet() { | |
| addBundle(org.eclipse.core.runtime.content.IContentType.class); // org.eclipse.core.contenttype | ||
| addBundle(org.eclipse.equinox.app.IApplication.class); // org.eclipse.equinox.app | ||
|
|
||
| // org.apache.felix.scr + dependencies | ||
| Bundle scrBundle = FrameworkUtil.getBundle(org.apache.felix.scr.info.ScrInfo.class); | ||
| Collection<Bundle> scrAndDependencies = new HashSet<>(); | ||
| collectDependencies(scrBundle, scrAndDependencies); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we maybe better list dependencies (are there many?) explicitly to not pull in too much or optional things unintentionally?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's these: I thought about importing a package from each and specifying them each explicitly. But I am not sure how stable that would be and how often dependencies change here and we'd have to adapt.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks safe to me.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These dependencies are in fact optional: but I guess this won't hurt - it's still pretty minimal and they don't depend on anything else we don't already need. And it's easier to maintain like this.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your gut feeling was right, this was indeed pulling in too much. |
||
| scrAndDependencies.forEach(this::addBundle); | ||
|
|
||
| addBundle(org.eclipse.core.tests.harness.TestHarnessPlugin.class); // org.eclipse.core.tests.harness | ||
| addBundle(org.eclipse.test.performance.Performance.class); // org.eclipse.test.performance | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Project settings say we use 1.4 (but currently only 1.1 features are used) so maybe we should just increase to 1.4 now to be safe in the future. On the other hand one likely will not find any compatible SCR impl for 1.2 anymore anyways :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this from the neighboring
org.eclipse.e4.core.servicesfor consistency.