XEnvironment env = depUnit.getAttachment(OSGiConstants.ENVIRONMENT_KEY);
XResolver resolver = depUnit.getAttachment(OSGiConstants.RESOLVER_KEY);
BundleManager bundleManager = depUnit.getAttachment(OSGiConstants.BUNDLE_MANAGER_KEY);
Set<XBundleRevision> mandatoryResources = Collections.singleton(brev);
Set<XBundleRevision> optionalResources = getOptionalResources(bundleManager, brev);
XResolveContext context = resolver.createResolveContext(env, mandatoryResources, optionalResources);
try {
LOGGER.debugf("Resolve: %s", depUnit.getName());
resolver.resolveAndApply(context);
depUnit.putAttachment(Attachments.BUNDLE_STATE_KEY, BundleState.RESOLVED);
} catch (ResolutionException ex) {