|
16 | 16 | package org.eclipse.pde.internal.core; |
17 | 17 |
|
18 | 18 | import java.io.File; |
19 | | -import java.util.ArrayList; |
20 | 19 | import java.util.Arrays; |
| 20 | +import java.util.Collection; |
21 | 21 | import java.util.Collections; |
22 | 22 | import java.util.Dictionary; |
23 | 23 | import java.util.LinkedHashSet; |
|
47 | 47 | import org.eclipse.jdt.launching.PropertyChangeEvent; |
48 | 48 | import org.eclipse.jdt.launching.environments.IExecutionEnvironment; |
49 | 49 | import org.eclipse.osgi.service.resolver.BundleDescription; |
| 50 | +import org.eclipse.osgi.service.resolver.HostSpecification; |
50 | 51 | import org.eclipse.osgi.service.resolver.State; |
51 | 52 | import org.eclipse.osgi.service.resolver.StateDelta; |
52 | 53 | import org.eclipse.osgi.util.ManifestElement; |
|
62 | 63 | import org.osgi.framework.Constants; |
63 | 64 | import org.osgi.framework.FrameworkUtil; |
64 | 65 | import org.osgi.framework.namespace.ExecutionEnvironmentNamespace; |
| 66 | +import org.osgi.framework.namespace.HostNamespace; |
| 67 | +import org.osgi.framework.wiring.BundleCapability; |
| 68 | +import org.osgi.framework.wiring.BundleRequirement; |
65 | 69 |
|
66 | 70 | public class MinimalState { |
67 | 71 |
|
@@ -259,11 +263,33 @@ public StateDelta resolveState(String[] symbolicNames) { |
259 | 263 | if (initializePlatformProperties()) { |
260 | 264 | return fState.resolve(false); |
261 | 265 | } |
262 | | - List<BundleDescription> bundles = new ArrayList<>(); |
| 266 | + Collection<BundleDescription> bundles = new LinkedHashSet<>(); |
263 | 267 | for (String symbolicName : symbolicNames) { |
264 | 268 | BundleDescription[] descriptions = fState.getBundles(symbolicName); |
265 | 269 | Collections.addAll(bundles, descriptions); |
266 | 270 | } |
| 271 | + // now we need to check all bundles if there is any fragment. If a |
| 272 | + // fragment should be resolved its host and all already attached |
| 273 | + // fragments must be re-resolved again |
| 274 | + for (BundleDescription bundleDescription : bundles) { |
| 275 | + HostSpecification host = bundleDescription.getHost(); |
| 276 | + if (host != null) { |
| 277 | + BundleRequirement requirement = host.getRequirement(); |
| 278 | + BundleDescription[] others = fState.getBundles(); |
| 279 | + for (BundleDescription other : others) { |
| 280 | + List<BundleCapability> capabilities = other.getDeclaredCapabilities(HostNamespace.HOST_NAMESPACE); |
| 281 | + for (BundleCapability cap : capabilities) { |
| 282 | + if (requirement.matches(cap)) { |
| 283 | + bundles.add(other); |
| 284 | + BundleDescription[] fragments = other.getFragments(); |
| 285 | + for (BundleDescription f : fragments) { |
| 286 | + bundles.add(f); |
| 287 | + } |
| 288 | + } |
| 289 | + } |
| 290 | + } |
| 291 | + } |
| 292 | + } |
267 | 293 | return fState.resolve(bundles.toArray(new BundleDescription[bundles.size()])); |
268 | 294 | } |
269 | 295 |
|
|
0 commit comments