01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.exports;
11:
12: import java.io.File;
13: import java.util.Dictionary;
14:
15: import org.eclipse.osgi.service.resolver.BundleDescription;
16: import org.eclipse.osgi.service.resolver.State;
17: import org.eclipse.pde.core.plugin.TargetPlatform;
18: import org.eclipse.pde.internal.core.TargetPlatformHelper;
19:
20: public class PluginExportOperation extends FeatureBasedExportOperation {
21:
22: public PluginExportOperation(FeatureExportInfo info) {
23: super (info);
24: }
25:
26: protected void createPostProcessingFiles() {
27: createPostProcessingFile(new File(fFeatureLocation,
28: PLUGIN_POST_PROCESSING));
29: }
30:
31: protected State getState(String os, String ws, String arch) {
32: // the way plug-in export works, the os, ws and arch should ALWAYS equal the target settings.
33: if (os.equals(TargetPlatform.getOS())
34: && ws.equals(TargetPlatform.getWS())
35: && arch.equals(TargetPlatform.getOSArch())
36: && fStateCopy != null) {
37: fStateCopy.resolve(true);
38: return fStateCopy;
39: }
40: return super .getState(os, ws, arch);
41: }
42:
43: protected boolean shouldAddPlugin(BundleDescription bundle,
44: Dictionary environment) {
45: // if there is an environment conflict
46: boolean conflict = !super .shouldAddPlugin(bundle, environment);
47: if (conflict) {
48: // make a copy of the state if we haven't already
49: if (fStateCopy == null)
50: copyState(TargetPlatformHelper.getState());
51: // replace the current BundleDescription with a copy who does not have the platform filter. This will allow the plug-in to be resolved
52: BundleDescription desc = fStateCopy.removeBundle(bundle
53: .getBundleId());
54: BundleDescription newDesc = fStateCopy.getFactory()
55: .createBundleDescription(desc.getBundleId(),
56: desc.getSymbolicName(), desc.getVersion(),
57: desc.getLocation(),
58: desc.getRequiredBundles(), desc.getHost(),
59: desc.getImportPackages(),
60: desc.getExportPackages(),
61: desc.isSingleton(), desc.attachFragments(),
62: desc.dynamicFragments(), null,
63: desc.getExecutionEnvironments(),
64: desc.getGenericRequires(),
65: desc.getGenericCapabilities());
66: fStateCopy.addBundle(newDesc);
67: }
68: // always include plug-ins, even ones with environment conflicts
69: return true;
70: }
71:
72: }
|