Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 114779 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/core/exports/FeatureExportOperation.java (-5 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 93-99 Link Here
93
93
94
	protected HashMap fAntBuildProperties;
94
	protected HashMap fAntBuildProperties;
95
95
96
	private State fStateCopy;
96
	protected State fStateCopy;
97
97
98
	protected static String FEATURE_POST_PROCESSING = "features.postProcessingSteps.properties"; //$NON-NLS-1$
98
	protected static String FEATURE_POST_PROCESSING = "features.postProcessingSteps.properties"; //$NON-NLS-1$
99
	protected static String PLUGIN_POST_PROCESSING = "plugins.postProcessingSteps.properties"; //$NON-NLS-1$
99
	protected static String PLUGIN_POST_PROCESSING = "plugins.postProcessingSteps.properties"; //$NON-NLS-1$
Lines 480-488 Link Here
480
			return main;
480
			return main;
481
		} 			
481
		} 			
482
		if (fStateCopy == null) {
482
		if (fStateCopy == null) {
483
			fStateCopy = main.getFactory().createState(main);
483
			copyState(main);
484
			fStateCopy.setResolver(Platform.getPlatformAdmin().getResolver());
485
			fStateCopy.setPlatformProperties(main.getPlatformProperties());
486
		}
484
		}
487
		
485
		
488
		Dictionary[] dictionaries = fStateCopy.getPlatformProperties();
486
		Dictionary[] dictionaries = fStateCopy.getPlatformProperties();
Lines 496-501 Link Here
496
		return fStateCopy;
494
		return fStateCopy;
497
	}
495
	}
498
	
496
	
497
	protected void copyState(State state) {
498
		fStateCopy = state.getFactory().createState(state);
499
		fStateCopy.setResolver(Platform.getPlatformAdmin().getResolver());
500
		fStateCopy.setPlatformProperties(state.getPlatformProperties());
501
	}
502
	
499
	private String getDevProperties() {
503
	private String getDevProperties() {
500
		if (fDevProperties == null) {
504
		if (fDevProperties == null) {
501
			fDevProperties = ClasspathHelper.getDevEntriesProperties(fBuildTempLocation + "/dev.properties", false); //$NON-NLS-1$
505
			fDevProperties = ClasspathHelper.getDevEntriesProperties(fBuildTempLocation + "/dev.properties", false); //$NON-NLS-1$
(-)src/org/eclipse/pde/internal/core/exports/PluginExportOperation.java (-1 / +121 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-17 Link Here
11
package org.eclipse.pde.internal.core.exports;
11
package org.eclipse.pde.internal.core.exports;
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.io.IOException;
15
import java.util.Dictionary;
16
import java.util.Hashtable;
14
17
18
import javax.xml.parsers.DocumentBuilderFactory;
19
import javax.xml.parsers.FactoryConfigurationError;
20
import javax.xml.parsers.ParserConfigurationException;
21
22
import org.eclipse.osgi.service.resolver.BundleDescription;
23
import org.eclipse.osgi.service.resolver.State;
24
import org.eclipse.pde.core.plugin.IPluginModelBase;
25
import org.eclipse.pde.core.plugin.TargetPlatform;
26
import org.eclipse.pde.internal.core.PDECore;
27
import org.eclipse.pde.internal.core.TargetPlatformHelper;
28
import org.eclipse.pde.internal.core.XMLPrintHandler;
29
import org.eclipse.pde.internal.core.ifeature.IFeature;
30
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
31
import org.osgi.framework.BundleContext;
32
import org.osgi.framework.InvalidSyntaxException;
33
import org.w3c.dom.DOMException;
34
import org.w3c.dom.Document;
35
import org.w3c.dom.Element;
15
36
16
public class PluginExportOperation extends FeatureBasedExportOperation {
37
public class PluginExportOperation extends FeatureBasedExportOperation {
17
38
Lines 22-26 Link Here
22
	protected void createPostProcessingFiles() {
43
	protected void createPostProcessingFiles() {
23
		createPostProcessingFile(new File(fFeatureLocation, PLUGIN_POST_PROCESSING));		
44
		createPostProcessingFile(new File(fFeatureLocation, PLUGIN_POST_PROCESSING));		
24
	}
45
	}
46
	
47
	// extend createFeature since the super's implementation does not include plug-ins with conflicting platform filters
48
	protected void createFeature(String featureID, String featureLocation, String[] config, boolean includeLauncher) throws IOException {
49
        File file = new File(featureLocation);
50
        if (!file.exists() || !file.isDirectory())
51
            file.mkdirs();
52
        
53
		try {
54
			 Dictionary environment = new Hashtable(4);
55
	            environment.put("osgi.os", config[0]); //$NON-NLS-1$
56
	            environment.put("osgi.ws", config[1]); //$NON-NLS-1$
57
	            environment.put("osgi.arch", config[2]); //$NON-NLS-1$
58
	            environment.put("osgi.nl", config[3]); //$NON-NLS-1$
25
59
60
			BundleDescription[] plugins = getBundles(environment);
61
			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
62
			Document doc = factory.newDocumentBuilder().newDocument();
63
			Element root = doc.createElement("feature"); //$NON-NLS-1$
64
			root.setAttribute("id", featureID); //$NON-NLS-1$
65
			root.setAttribute("version", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$
66
			doc.appendChild(root);
67
			
68
			if (includeLauncher) {
69
				IFeatureModel model = PDECore.getDefault().getFeatureModelManager().getDeltaPackFeature();
70
				if (model != null) {
71
					IFeature feature = model.getFeature();
72
					Element includes = doc.createElement("includes"); //$NON-NLS-1$
73
					includes.setAttribute("id", feature.getId()); //$NON-NLS-1$
74
					includes.setAttribute("version", feature.getVersion()); //$NON-NLS-1$
75
					root.appendChild(includes);
76
				}
77
			}
78
           
79
            for (int i = 0; i < plugins.length; i++) {
80
	            	BundleDescription bundle = plugins[i];
81
	            	if (bundle == null)
82
	            		continue;
83
	            	Element plugin = doc.createElement("plugin"); //$NON-NLS-1$
84
	            	plugin.setAttribute("id", bundle.getSymbolicName()); //$NON-NLS-1$
85
	            	plugin.setAttribute("version", bundle.getVersion().toString()); //$NON-NLS-1$ 
86
	            	setAdditionalAttributes(plugin, bundle);
87
	            	root.appendChild(plugin);
88
            }
89
            XMLPrintHandler.writeFile(doc, new File(file, "feature.xml")); //$NON-NLS-1$
90
 		} catch (DOMException e1) {
91
		} catch (FactoryConfigurationError e1) {
92
		} catch (ParserConfigurationException e1) {
93
		}      	
94
    }
95
	
96
	// Returns an array of BundleDescriptions which represent bundles to export.
97
	// If a bundle has a conflicting platform filter, we copy the state and remove the filter.  This way it is still included in the export
98
	private BundleDescription[] getBundles(Dictionary environment) {
99
		BundleContext context = PDECore.getDefault().getBundleContext();
100
		BundleDescription[] plugins = new BundleDescription[fInfo.items.length];
101
		for (int i = 0; i < plugins.length; i++) {
102
			if (!(fInfo.items[i] instanceof IFeatureModel)) {
103
				BundleDescription bundle = null;
104
                if (fInfo.items[i] instanceof IPluginModelBase) {
105
                	bundle = ((IPluginModelBase)fInfo.items[i]).getBundleDescription();
106
                }
107
                if (bundle == null) {
108
                	if (fInfo.items[i] instanceof BundleDescription)
109
                		bundle = (BundleDescription)fInfo.items[i];
110
                }
111
                if (bundle == null)
112
                	continue;
113
                try {
114
                	plugins[i] = bundle;
115
                    String filterSpec = bundle.getPlatformFilter();
116
                    // if there is a confliciting platform filter, copy the state and reload it with a copy of the BundleDescription without the platform filter
117
                    if (!(filterSpec == null|| context.createFilter(filterSpec).match(environment))) {
118
                    	if (fStateCopy == null)
119
                    		copyState(TargetPlatformHelper.getState());
120
                    	BundleDescription desc = fStateCopy.removeBundle(bundle.getBundleId());
121
                    	BundleDescription newDesc = fStateCopy.getFactory().createBundleDescription(desc.getBundleId(), desc.getSymbolicName(), 
122
                    			desc.getVersion(), desc.getLocation(), desc.getRequiredBundles(), desc.getHost(), desc.getImportPackages(), 
123
                    			desc.getExportPackages(), desc.isSingleton(), desc.attachFragments(), desc.dynamicFragments(), null, 
124
                    			desc.getExecutionEnvironments(), desc.getGenericRequires(), desc.getGenericCapabilities());
125
                    	fStateCopy.addBundle(newDesc);
126
                    }
127
                } catch (InvalidSyntaxException e) {
128
                }
129
			}
130
		}
131
		if (fStateCopy != null) 
132
			fStateCopy.resolve(false);
133
		return plugins;
134
	}
135
136
	protected State getState(String os, String ws, String arch) {
137
		// the way plug-in export works, the os, ws and arch should ALWAYS equal the target settings.
138
		if (os.equals(TargetPlatform.getOS()) 
139
				&& ws.equals(TargetPlatform.getWS())
140
				&& arch.equals(TargetPlatform.getOSArch())
141
				&& fStateCopy != null) 
142
			return fStateCopy;
143
		return super.getState(os, ws, arch);
144
	}
145
	
26
}
146
}

Return to bug 114779