Skip to content

Commit 0251a18

Browse files
committed
Fix minimal state
1 parent 3d2a06e commit 0251a18

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/MinimalState.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
package org.eclipse.pde.internal.core;
1717

1818
import java.io.File;
19-
import java.util.ArrayList;
2019
import java.util.Arrays;
20+
import java.util.Collection;
2121
import java.util.Collections;
2222
import java.util.Dictionary;
2323
import java.util.LinkedHashSet;
@@ -47,6 +47,7 @@
4747
import org.eclipse.jdt.launching.PropertyChangeEvent;
4848
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
4949
import org.eclipse.osgi.service.resolver.BundleDescription;
50+
import org.eclipse.osgi.service.resolver.HostSpecification;
5051
import org.eclipse.osgi.service.resolver.State;
5152
import org.eclipse.osgi.service.resolver.StateDelta;
5253
import org.eclipse.osgi.util.ManifestElement;
@@ -62,6 +63,9 @@
6263
import org.osgi.framework.Constants;
6364
import org.osgi.framework.FrameworkUtil;
6465
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;
6569

6670
public class MinimalState {
6771

@@ -259,11 +263,33 @@ public StateDelta resolveState(String[] symbolicNames) {
259263
if (initializePlatformProperties()) {
260264
return fState.resolve(false);
261265
}
262-
List<BundleDescription> bundles = new ArrayList<>();
266+
Collection<BundleDescription> bundles = new LinkedHashSet<>();
263267
for (String symbolicName : symbolicNames) {
264268
BundleDescription[] descriptions = fState.getBundles(symbolicName);
265269
Collections.addAll(bundles, descriptions);
266270
}
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+
}
267293
return fState.resolve(bundles.toArray(new BundleDescription[bundles.size()]));
268294
}
269295

0 commit comments

Comments
 (0)