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 269111 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/core/P2Utils.java (-71 / +29 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.pde.internal.core;
12
package org.eclipse.pde.internal.core;
12
13
Lines 18-24 Link Here
18
import org.eclipse.core.runtime.*;
19
import org.eclipse.core.runtime.*;
19
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
20
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
20
import org.eclipse.equinox.internal.provisional.simpleconfigurator.manipulator.SimpleConfiguratorManipulator;
21
import org.eclipse.equinox.internal.provisional.simpleconfigurator.manipulator.SimpleConfiguratorManipulator;
21
import org.eclipse.osgi.service.resolver.BundleDescription;
22
import org.eclipse.pde.core.plugin.IPluginBase;
22
import org.eclipse.pde.core.plugin.IPluginBase;
23
import org.eclipse.pde.core.plugin.IPluginModelBase;
23
import org.eclipse.pde.core.plugin.IPluginModelBase;
24
import org.eclipse.pde.internal.build.BundleHelper;
24
import org.eclipse.pde.internal.build.BundleHelper;
Lines 189-200 Link Here
189
	 * @param defaultStartLevel start level to use when "default" is the start level
189
	 * @param defaultStartLevel start level to use when "default" is the start level
190
	 * @param defaultAutoStart auto start setting to use when "default" is the auto start setting
190
	 * @param defaultAutoStart auto start setting to use when "default" is the auto start setting
191
	 * @param directory configuration directory to create the files in
191
	 * @param directory configuration directory to create the files in
192
	 * @param osgiBundleList a list of bundles coming from a template config.ini
192
	 * @return URL location of the bundles.info or <code>null</code>
193
	 * @return URL location of the bundles.info or <code>null</code>
193
	 */
194
	 */
194
	public static URL writeBundlesTxt(Map bundles, int defaultStartLevel, boolean defaultAutoStart, File directory) {
195
	public static URL writeBundlesTxt(Map bundles, int defaultStartLevel, boolean defaultAutoStart, File directory, String osgiBundleList) {
195
		if (bundles.size() == 0) {
196
		if (bundles.size() == 0) {
196
			return null;
197
			return null;
197
		}
198
		}
199
200
		// Parse the osgi bundle list for start levels
201
		Map osgiStartLevels = new HashMap();
202
		if (osgiBundleList != null) {
203
			StringTokenizer tokenizer = new StringTokenizer(osgiBundleList, ","); //$NON-NLS-1$
204
			while (tokenizer.hasMoreTokens()) {
205
				String token = tokenizer.nextToken();
206
				int index = token.indexOf('@');
207
				if (index != -1) {
208
					String modelName = token.substring(0, index);
209
					String startData = token.substring(index + 1);
210
					index = startData.indexOf(':');
211
					String level = index > 0 ? startData.substring(0, index) : "default"; //$NON-NLS-1$
212
					String auto = index > 0 && index < startData.length() - 1 ? startData.substring(index + 1) : "default"; //$NON-NLS-1$
213
					if ("start".equals(auto)) { //$NON-NLS-1$
214
						auto = "true"; //$NON-NLS-1$
215
					}
216
					osgiStartLevels.put(modelName, level + ':' + auto);
217
				}
218
			}
219
		}
220
198
		List bundleInfo = new ArrayList(bundles.size());
221
		List bundleInfo = new ArrayList(bundles.size());
199
		List sourceInfo = new ArrayList(bundles.size());
222
		List sourceInfo = new ArrayList(bundles.size());
200
		for (Iterator iterator = bundles.keySet().iterator(); iterator.hasNext();) {
223
		for (Iterator iterator = bundles.keySet().iterator(); iterator.hasNext();) {
Lines 215-220 Link Here
215
					info.setSymbolicName(base.getId());
238
					info.setSymbolicName(base.getId());
216
					info.setVersion(base.getVersion());
239
					info.setVersion(base.getVersion());
217
					String currentLevel = (String) bundles.get(currentModel);
240
					String currentLevel = (String) bundles.get(currentModel);
241
					// override the start level setting if something comes from the config.ini
242
					if (osgiStartLevels.containsKey(base.getId())) {
243
						currentLevel = (String) osgiStartLevels.get(base.getId());
244
					}
218
					int index = currentLevel.indexOf(':');
245
					int index = currentLevel.indexOf(':');
219
					String levelString = index > 0 ? currentLevel.substring(0, index) : "default"; //$NON-NLS-1$
246
					String levelString = index > 0 ? currentLevel.substring(0, index) : "default"; //$NON-NLS-1$
220
					String auto = index > 0 && index < currentLevel.length() - 1 ? currentLevel.substring(index + 1) : "default"; //$NON-NLS-1$
247
					String auto = index > 0 && index < currentLevel.length() - 1 ? currentLevel.substring(index + 1) : "default"; //$NON-NLS-1$
Lines 269-341 Link Here
269
		}
296
		}
270
	}
297
	}
271
298
272
	/**
273
	 * Creates a bundles.info file in the given directory containing the name,
274
	 * version, location, start level and expected state of every bundle in the
275
	 * given collection.  Will also create a source.info file containing
276
	 * a list of all source bundles found in the given collection. If a bundle
277
	 * has a specified start level in the osgi bundle list, that value is used
278
	 * instead of the default.  Returns the URL location of the bundle.txt or 
279
	 * <code>null</code> if there was a problem creating it.
280
	 * 
281
	 * @param bundles collection of IPluginModelBase objects to write into the bundles.info/source.info
282
	 * @param osgiBundleList comma separated list of bundles specified in a template config.ini, used to override start levels
283
	 * @param directory directory to create the bundles.info and source.info files in
284
	 * @return URL location of the bundles.info or <code>null</code>
285
	 */
286
	public static URL writeBundlesTxt(Collection bundles, String osgiBundleList, File directory) {
287
		// Parse the osgi bundle list for start levels
288
		Map osgiStartLevels = new HashMap();
289
		StringTokenizer tokenizer = new StringTokenizer(osgiBundleList, ","); //$NON-NLS-1$
290
		while (tokenizer.hasMoreTokens()) {
291
			String token = tokenizer.nextToken();
292
			int index = token.indexOf('@');
293
			if (index != -1) {
294
				String modelName = token.substring(0, index);
295
				String startData = token.substring(index + 1);
296
				index = startData.indexOf(':');
297
				String level = index > 0 ? startData.substring(0, index) : "default"; //$NON-NLS-1$
298
				String auto = index > 0 && index < startData.length() - 1 ? startData.substring(index + 1) : "default"; //$NON-NLS-1$
299
				if ("start".equals(auto)) { //$NON-NLS-1$
300
					auto = "true"; //$NON-NLS-1$
301
				}
302
				osgiStartLevels.put(modelName, level + ':' + auto);
303
			}
304
		}
305
306
		// Create a map of bundles to start levels
307
		String defaultAppend = "default:default"; //$NON-NLS-1$
308
		Map bundleMap = new HashMap(bundles.size());
309
		for (Iterator iterator = bundles.iterator(); iterator.hasNext();) {
310
			IPluginModelBase currentModel = (IPluginModelBase) iterator.next();
311
			BundleDescription desc = currentModel.getBundleDescription();
312
			if (desc != null) {
313
				String modelName = desc.getSymbolicName();
314
				if (modelName != null && osgiStartLevels.containsKey(modelName)) {
315
					bundleMap.put(currentModel, osgiStartLevels.get(modelName));
316
				} else if (IPDEBuildConstants.BUNDLE_DS.equals(modelName)) {
317
					bundleMap.put(currentModel, "1:true"); //$NON-NLS-1$ 
318
				} else if (IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR.equals(modelName)) {
319
					bundleMap.put(currentModel, "1:true"); //$NON-NLS-1$
320
				} else if (IPDEBuildConstants.BUNDLE_EQUINOX_COMMON.equals(modelName)) {
321
					bundleMap.put(currentModel, "2:true"); //$NON-NLS-1$
322
				} else if (IPDEBuildConstants.BUNDLE_OSGI.equals(modelName)) {
323
					bundleMap.put(currentModel, "-1:true"); //$NON-NLS-1$
324
				} else if (IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR.equals(modelName)) {
325
					bundleMap.put(currentModel, "3:true"); //$NON-NLS-1$
326
				} else if (IPDEBuildConstants.BUNDLE_CORE_RUNTIME.equals(modelName)) {
327
					if (TargetPlatformHelper.getTargetVersion() > 3.1) {
328
						bundleMap.put(currentModel, "default:true"); //$NON-NLS-1$
329
					} else {
330
						bundleMap.put(currentModel, "2:true"); //$NON-NLS-1$
331
					}
332
				} else {
333
					bundleMap.put(currentModel, defaultAppend);
334
				}
335
			}
336
		}
337
338
		return writeBundlesTxt(bundleMap, 4, false, directory);
339
	}
340
341
}
299
}
(-)src/org/eclipse/pde/internal/ui/launcher/OSGiValidationOperation.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 2009 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.launcher;
12
package org.eclipse.pde.internal.ui.launcher;
12
13
Lines 21-27 Link Here
21
	}
22
	}
22
23
23
	protected IPluginModelBase[] getModels() throws CoreException {
24
	protected IPluginModelBase[] getModels() throws CoreException {
24
		return BundleLauncherHelper.getMergedBundles(fLaunchConfiguration);
25
		return BundleLauncherHelper.getMergedBundles(fLaunchConfiguration, true);
25
	}
26
	}
26
27
27
}
28
}
(-)src/org/eclipse/pde/internal/ui/launcher/BundleLauncherHelper.java (-5 / +7 lines)
Lines 32-46 Link Here
32
		return getTargetBundleMap(configuration, null, IPDELauncherConstants.TARGET_BUNDLES);
32
		return getTargetBundleMap(configuration, null, IPDELauncherConstants.TARGET_BUNDLES);
33
	}
33
	}
34
34
35
	public static Map getMergedBundleMap(ILaunchConfiguration configuration) throws CoreException {
35
	public static Map getMergedBundleMap(ILaunchConfiguration configuration, boolean osgi) throws CoreException {
36
		Set set = new HashSet();
36
		Set set = new HashSet();
37
		Map map = getWorkspaceBundleMap(configuration, set, IPDELauncherConstants.WORKSPACE_BUNDLES);
37
		String workspace = osgi == false ? IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS : IPDELauncherConstants.WORKSPACE_BUNDLES;
38
		map.putAll(getTargetBundleMap(configuration, set, IPDELauncherConstants.TARGET_BUNDLES));
38
		String target = osgi == false ? IPDELauncherConstants.SELECTED_TARGET_PLUGINS : IPDELauncherConstants.TARGET_BUNDLES;
39
		Map map = getWorkspaceBundleMap(configuration, set, workspace);
40
		map.putAll(getTargetBundleMap(configuration, set, target));
39
		return map;
41
		return map;
40
	}
42
	}
41
43
42
	public static IPluginModelBase[] getMergedBundles(ILaunchConfiguration configuration) throws CoreException {
44
	public static IPluginModelBase[] getMergedBundles(ILaunchConfiguration configuration, boolean osgi) throws CoreException {
43
		Map map = getMergedBundleMap(configuration);
45
		Map map = getMergedBundleMap(configuration, osgi);
44
		return (IPluginModelBase[]) map.keySet().toArray(new IPluginModelBase[map.size()]);
46
		return (IPluginModelBase[]) map.keySet().toArray(new IPluginModelBase[map.size()]);
45
	}
47
	}
46
48
(-)src/org/eclipse/pde/internal/ui/launcher/LaunchConfigurationHelper.java (-26 / +8 lines)
Lines 79-85 Link Here
79
		return mgr.performStringSubstitution(text);
79
		return mgr.performStringSubstitution(text);
80
	}
80
	}
81
81
82
	public static Properties createConfigIniFile(ILaunchConfiguration configuration, String productID, Map map, File directory) throws CoreException {
82
	public static Properties createConfigIniFile(ILaunchConfiguration configuration, String productID, Map bundles, Map bundlesWithStartLevels, File directory) throws CoreException {
83
		Properties properties = null;
83
		Properties properties = null;
84
		// if we are to generate a config.ini, start with the values in the target platform's config.ini - bug 141918
84
		// if we are to generate a config.ini, start with the values in the target platform's config.ini - bug 141918
85
		if (configuration.getAttribute(IPDELauncherConstants.CONFIG_GENERATE_DEFAULT, true)) {
85
		if (configuration.getAttribute(IPDELauncherConstants.CONFIG_GENERATE_DEFAULT, true)) {
Lines 93-99 Link Here
93
			// if target's config.ini has the osgi.bundles header, then parse and compute the proper osgi.bundles value
93
			// if target's config.ini has the osgi.bundles header, then parse and compute the proper osgi.bundles value
94
			String bundleList = properties.getProperty(PROP_OSGI_BUNDLES);
94
			String bundleList = properties.getProperty(PROP_OSGI_BUNDLES);
95
			if (bundleList != null)
95
			if (bundleList != null)
96
				properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatformHelper.stripPathInformation(bundleList), map));
96
				properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatformHelper.stripPathInformation(bundleList), bundles));
97
		} else {
97
		} else {
98
			String templateLoc = configuration.getAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, (String) null);
98
			String templateLoc = configuration.getAttribute(IPDELauncherConstants.CONFIG_TEMPLATE_LOCATION, (String) null);
99
			if (templateLoc != null) {
99
			if (templateLoc != null) {
Lines 106-112 Link Here
106
		}
106
		}
107
		// whether we create a new config.ini or read from one as a template, we should add the required properties - bug 161265
107
		// whether we create a new config.ini or read from one as a template, we should add the required properties - bug 161265
108
		if (properties != null) {
108
		if (properties != null) {
109
			addRequiredProperties(properties, productID, map);
109
			addRequiredProperties(properties, productID, bundles);
110
		} else {
110
		} else {
111
			properties = new Properties();
111
			properties = new Properties();
112
		}
112
		}
Lines 119-162 Link Here
119
		boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, false);
119
		boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, false);
120
120
121
		// if we are launching using P2, write out P2 files (bundles.txt) and add P2 property to config.ini
121
		// if we are launching using P2, write out P2 files (bundles.txt) and add P2 property to config.ini
122
		if (osgiBundles != null && osgiBundles.indexOf(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR) != -1 && map.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) {
122
		if (osgiBundles != null && osgiBundles.indexOf(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR) != -1 && bundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) {
123
124
			// TODO we need to clean this up... our original list should have start level information
125
			// this causes a performance impact
126
			URL bundlesTxt = null;
123
			URL bundlesTxt = null;
127
			boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true);
124
			boolean usedefault = configuration.getAttribute(IPDELauncherConstants.USE_DEFAULT, true);
128
			boolean useFeatures = configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false);
125
			boolean useFeatures = configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false);
129
			if (usedefault || useFeatures) {
126
			if (usedefault || useFeatures) {
130
				bundlesTxt = P2Utils.writeBundlesTxt(map.values(), osgiBundles, directory);
127
				bundlesTxt = P2Utils.writeBundlesTxt(bundlesWithStartLevels, 4, false, directory, osgiBundles);
131
			} else {
128
			} else {
132
				Map models = new HashMap();
129
				bundlesTxt = P2Utils.writeBundlesTxt(bundlesWithStartLevels, start, autostart, directory, null);
133
				Map modelsWithStartLevels = new HashMap();
134
				modelsWithStartLevels.putAll(BundleLauncherHelper.getTargetBundleMap(configuration, Collections.EMPTY_SET, IPDELauncherConstants.SELECTED_TARGET_PLUGINS));
135
				boolean automaticAdd = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_ADD, true);
136
				String attribute = automaticAdd ? IPDELauncherConstants.DESELECTED_WORKSPACE_PLUGINS : IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS;
137
				modelsWithStartLevels.putAll(BundleLauncherHelper.getWorkspaceBundleMap(configuration, null, attribute));
138
				IPluginModelBase[] plugins = (IPluginModelBase[]) map.values().toArray(new IPluginModelBase[map.size()]);
139
				for (int i = 0; i < plugins.length; i++) {
140
					IPluginModelBase model = plugins[i];
141
					String startLevel = (String) modelsWithStartLevels.get(model);
142
					if (startLevel != null) {
143
						models.put(model, startLevel);
144
					}
145
				}
146
				bundlesTxt = P2Utils.writeBundlesTxt(models, start, autostart, directory);
147
			}
130
			}
148
131
149
			if (bundlesTxt != null) {
132
			if (bundlesTxt != null) {
150
				properties.setProperty("org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); //$NON-NLS-1$
133
				properties.setProperty("org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); //$NON-NLS-1$
151
152
				// if we have simple configurator and update configurator together, ensure update doesn't reconcile
134
				// if we have simple configurator and update configurator together, ensure update doesn't reconcile
153
				if (map.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) {
135
				if (bundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) {
154
					properties.setProperty("org.eclipse.update.reconcile", "false"); //$NON-NLS-1$ //$NON-NLS-2$
136
					properties.setProperty("org.eclipse.update.reconcile", "false"); //$NON-NLS-1$ //$NON-NLS-2$
155
				}
137
				}
156
			}
138
			}
157
		}
139
		}
158
140
159
		setBundleLocations(map, properties);
141
		setBundleLocations(bundles, properties);
160
142
161
		save(new File(directory, "config.ini"), properties); //$NON-NLS-1$
143
		save(new File(directory, "config.ini"), properties); //$NON-NLS-1$
162
		return properties;
144
		return properties;
(-)src/org/eclipse/pde/ui/launcher/EquinoxLaunchConfiguration.java (-3 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.pde.ui.launcher;
12
package org.eclipse.pde.ui.launcher;
12
13
Lines 74-80 Link Here
74
		String bundles = null;
75
		String bundles = null;
75
		if (fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) {
76
		if (fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) {
76
			// If simple configurator is being used, we need to write out the bundles.txt instead of writing out the list in the config.ini
77
			// If simple configurator is being used, we need to write out the bundles.txt instead of writing out the list in the config.ini
77
			URL bundlesTxt = P2Utils.writeBundlesTxt(fModels, start, autostart, getConfigDir(configuration));
78
			URL bundlesTxt = P2Utils.writeBundlesTxt(fModels, start, autostart, getConfigDir(configuration), null);
78
			if (bundlesTxt != null) {
79
			if (bundlesTxt != null) {
79
				properties.setProperty("org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); //$NON-NLS-1$
80
				properties.setProperty("org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); //$NON-NLS-1$
80
				if (fAllBundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) {
81
				if (fAllBundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) {
Lines 153-159 Link Here
153
	 * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
154
	 * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
154
	 */
155
	 */
155
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
156
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
156
		fModels = BundleLauncherHelper.getMergedBundleMap(configuration);
157
		fModels = BundleLauncherHelper.getMergedBundleMap(configuration, true);
157
		fAllBundles = new HashMap(fModels.size());
158
		fAllBundles = new HashMap(fModels.size());
158
		Iterator iter = fModels.keySet().iterator();
159
		Iterator iter = fModels.keySet().iterator();
159
		while (iter.hasNext()) {
160
		while (iter.hasNext()) {
(-)src/org/eclipse/pde/ui/launcher/EclipseApplicationLaunchConfiguration.java (-9 / +20 lines)
Lines 37-42 Link Here
37
 */
37
 */
38
public class EclipseApplicationLaunchConfiguration extends AbstractPDELaunchConfiguration {
38
public class EclipseApplicationLaunchConfiguration extends AbstractPDELaunchConfiguration {
39
39
40
	// used to generate the dev classpath entries
41
	// key is bundle ID, value is a model
42
	private Map fAllBundles;
43
44
	// key is a model, value is startLevel:autoStart
45
	private Map fModels;
46
40
	/**
47
	/**
41
	 * To avoid duplicating variable substitution (and duplicate prompts)
48
	 * To avoid duplicating variable substitution (and duplicate prompts)
42
	 * this variable will store the substituted workspace location.
49
	 * this variable will store the substituted workspace location.
Lines 76-84 Link Here
76
		}
83
		}
77
84
78
		boolean showSplash = true;
85
		boolean showSplash = true;
79
		// TODO fix getPluginstoRun to return a map that is model/startlevel
80
		// model after EquinoxLaunchConfiguration
81
		Map pluginMap = LaunchPluginValidator.getPluginsToRun(configuration);
82
		if (configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false)) {
86
		if (configuration.getAttribute(IPDELauncherConstants.USEFEATURES, false)) {
83
			validateFeatures();
87
			validateFeatures();
84
			IPath installPath = PDEPlugin.getWorkspace().getRoot().getLocation();
88
			IPath installPath = PDEPlugin.getWorkspace().getRoot().getLocation();
Lines 94-114 Link Here
94
			programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", true)); //$NON-NLS-1$
98
			programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", true)); //$NON-NLS-1$
95
		} else {
99
		} else {
96
			String productID = LaunchConfigurationHelper.getProductID(configuration);
100
			String productID = LaunchConfigurationHelper.getProductID(configuration);
97
			Properties prop = LaunchConfigurationHelper.createConfigIniFile(configuration, productID, pluginMap, getConfigDir(configuration));
101
			Properties prop = LaunchConfigurationHelper.createConfigIniFile(configuration, productID, fAllBundles, fModels, getConfigDir(configuration));
98
			showSplash = prop.containsKey("osgi.splashPath") || prop.containsKey("splashLocation"); //$NON-NLS-1$ //$NON-NLS-2$
102
			showSplash = prop.containsKey("osgi.splashPath") || prop.containsKey("splashLocation"); //$NON-NLS-1$ //$NON-NLS-2$
99
			String brandingId = LaunchConfigurationHelper.getContributingPlugin(productID);
103
			String brandingId = LaunchConfigurationHelper.getContributingPlugin(productID);
100
			TargetPlatform.createPlatformConfiguration(getConfigDir(configuration), (IPluginModelBase[]) pluginMap.values().toArray(new IPluginModelBase[pluginMap.size()]), brandingId != null ? (IPluginModelBase) pluginMap.get(brandingId) : null);
104
			TargetPlatform.createPlatformConfiguration(getConfigDir(configuration), (IPluginModelBase[]) fAllBundles.values().toArray(new IPluginModelBase[fAllBundles.size()]), brandingId != null ? (IPluginModelBase) fAllBundles.get(brandingId) : null);
101
			TargetPlatformHelper.checkPluginPropertiesConsistency(pluginMap, getConfigDir(configuration));
105
			TargetPlatformHelper.checkPluginPropertiesConsistency(fAllBundles, getConfigDir(configuration));
102
			programArgs.add("-configuration"); //$NON-NLS-1$
106
			programArgs.add("-configuration"); //$NON-NLS-1$
103
			programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
107
			programArgs.add("file:" + new Path(getConfigDir(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
104
108
105
			// add the output folder names
109
			// add the output folder names
106
			programArgs.add("-dev"); //$NON-NLS-1$
110
			programArgs.add("-dev"); //$NON-NLS-1$
107
			programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", pluginMap)); //$NON-NLS-1$
111
			programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigDir(configuration).toString() + "/dev.properties", fAllBundles)); //$NON-NLS-1$
108
		}
112
		}
109
		// necessary for PDE to know how to load plugins when target platform = host platform
113
		// necessary for PDE to know how to load plugins when target platform = host platform
110
		// see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode()
114
		// see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode()
111
		IPluginModelBase base = (IPluginModelBase) pluginMap.get(PDECore.PLUGIN_ID);
115
		IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID);
112
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) < 0) //$NON-NLS-1$
116
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) < 0) //$NON-NLS-1$
113
			programArgs.add("-pdelaunch"); //$NON-NLS-1$
117
			programArgs.add("-pdelaunch"); //$NON-NLS-1$
114
118
Lines 238-243 Link Here
238
	 */
242
	 */
239
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
243
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
240
		fWorkspaceLocation = null;
244
		fWorkspaceLocation = null;
245
		fModels = BundleLauncherHelper.getMergedBundleMap(configuration, false);
246
		fAllBundles = new HashMap(fModels.size());
247
		Iterator iter = fModels.keySet().iterator();
248
		while (iter.hasNext()) {
249
			IPluginModelBase model = (IPluginModelBase) iter.next();
250
			fAllBundles.put(model.getPluginBase().getId(), model);
251
		}
241
		validateConfigIni(configuration);
252
		validateConfigIni(configuration);
242
		super.preLaunchCheck(configuration, launch, monitor);
253
		super.preLaunchCheck(configuration, launch, monitor);
243
	}
254
	}
Lines 263-269 Link Here
263
	 */
274
	 */
264
	public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException {
275
	public String[] getVMArguments(ILaunchConfiguration configuration) throws CoreException {
265
		String[] vmArgs = super.getVMArguments(configuration);
276
		String[] vmArgs = super.getVMArguments(configuration);
266
		IPluginModelBase base = (IPluginModelBase) LaunchPluginValidator.getPluginsToRun(configuration).get(PDECore.PLUGIN_ID);
277
		IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID);
267
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0) { //$NON-NLS-1$
278
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0) { //$NON-NLS-1$
268
			// necessary for PDE to know how to load plugins when target platform = host platform
279
			// necessary for PDE to know how to load plugins when target platform = host platform
269
			// see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode()
280
			// see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode()
(-)src/org/eclipse/pde/ui/launcher/JUnitLaunchConfigurationDelegate.java (-18 / +26 lines)
Lines 7-21 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Code 9 Corporation - ongoing enhancements
10
 *     EclipseSource Corporation - ongoing enhancements
11
 *     David Saff <saff@mit.edu> - bug 102632
11
 *     David Saff <saff@mit.edu> - bug 102632
12
 *     Ketan Padegaonkar <KetanPadegaonkar@gmail.com> - bug 250340
12
 *     Ketan Padegaonkar <KetanPadegaonkar@gmail.com> - bug 250340
13
 *******************************************************************************/
13
 *******************************************************************************/
14
package org.eclipse.pde.ui.launcher;
14
package org.eclipse.pde.ui.launcher;
15
15
16
import java.io.File;
16
import java.io.File;
17
import java.util.List;
17
import java.util.*;
18
import java.util.Map;
19
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.resources.IProject;
20
import org.eclipse.core.runtime.*;
19
import org.eclipse.core.runtime.*;
21
import org.eclipse.debug.core.*;
20
import org.eclipse.debug.core.*;
Lines 47-53 Link Here
47
46
48
	protected File fConfigDir = null;
47
	protected File fConfigDir = null;
49
48
50
	private Map fPluginMap;
49
	// used to generate the dev classpath entries
50
	// key is bundle ID, value is a model
51
	private Map fAllBundles;
52
53
	// key is a model, value is startLevel:autoStart
54
	private Map fModels;
51
55
52
	/*
56
	/*
53
	 * (non-Javadoc)
57
	 * (non-Javadoc)
Lines 123-139 Link Here
123
127
124
		// Create the platform configuration for the runtime workbench
128
		// Create the platform configuration for the runtime workbench
125
		String productID = LaunchConfigurationHelper.getProductID(configuration);
129
		String productID = LaunchConfigurationHelper.getProductID(configuration);
126
		LaunchConfigurationHelper.createConfigIniFile(configuration, productID, fPluginMap, getConfigurationDirectory(configuration));
130
		LaunchConfigurationHelper.createConfigIniFile(configuration, productID, fAllBundles, fModels, getConfigurationDirectory(configuration));
127
		String brandingId = LaunchConfigurationHelper.getContributingPlugin(productID);
131
		String brandingId = LaunchConfigurationHelper.getContributingPlugin(productID);
128
		TargetPlatform.createPlatformConfiguration(getConfigurationDirectory(configuration), (IPluginModelBase[]) fPluginMap.values().toArray(new IPluginModelBase[fPluginMap.size()]), brandingId != null ? (IPluginModelBase) fPluginMap.get(brandingId) : null);
132
		TargetPlatform.createPlatformConfiguration(getConfigurationDirectory(configuration), (IPluginModelBase[]) fAllBundles.values().toArray(new IPluginModelBase[fAllBundles.size()]), brandingId != null ? (IPluginModelBase) fAllBundles.get(brandingId) : null);
129
		TargetPlatformHelper.checkPluginPropertiesConsistency(fPluginMap, getConfigurationDirectory(configuration));
133
		TargetPlatformHelper.checkPluginPropertiesConsistency(fAllBundles, getConfigurationDirectory(configuration));
130
134
131
		programArgs.add("-configuration"); //$NON-NLS-1$
135
		programArgs.add("-configuration"); //$NON-NLS-1$
132
		programArgs.add("file:" + new Path(getConfigurationDirectory(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
136
		programArgs.add("file:" + new Path(getConfigurationDirectory(configuration).getPath()).addTrailingSeparator().toString()); //$NON-NLS-1$
133
137
134
		// Specify the output folder names
138
		// Specify the output folder names
135
		programArgs.add("-dev"); //$NON-NLS-1$
139
		programArgs.add("-dev"); //$NON-NLS-1$
136
		programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigurationDirectory(configuration).toString() + "/dev.properties", fPluginMap)); //$NON-NLS-1$
140
		programArgs.add(ClasspathHelper.getDevEntriesProperties(getConfigurationDirectory(configuration).toString() + "/dev.properties", fAllBundles)); //$NON-NLS-1$
137
141
138
		// necessary for PDE to know how to load plugins when target platform = host platform
142
		// necessary for PDE to know how to load plugins when target platform = host platform
139
		// see PluginPathFinder.getPluginPaths()
143
		// see PluginPathFinder.getPluginPaths()
Lines 207-213 Link Here
207
		// if application is not set, we should launch the default UI test app
211
		// if application is not set, we should launch the default UI test app
208
		// Check to see if we should launch the legacy UI app
212
		// Check to see if we should launch the legacy UI app
209
		if (application == null) {
213
		if (application == null) {
210
			IPluginModelBase model = (IPluginModelBase) fPluginMap.get("org.eclipse.pde.junit.runtime"); //$NON-NLS-1$
214
			IPluginModelBase model = (IPluginModelBase) fAllBundles.get("org.eclipse.pde.junit.runtime"); //$NON-NLS-1$
211
			BundleDescription desc = model != null ? model.getBundleDescription() : null;
215
			BundleDescription desc = model != null ? model.getBundleDescription() : null;
212
			if (desc != null) {
216
			if (desc != null) {
213
				Version version = desc.getVersion();
217
				Version version = desc.getVersion();
Lines 252-265 Link Here
252
		String vmArgs = LaunchArgumentsHelper.getUserVMArguments(configuration);
256
		String vmArgs = LaunchArgumentsHelper.getUserVMArguments(configuration);
253
257
254
		// necessary for PDE to know how to load plugins when target platform = host platform
258
		// necessary for PDE to know how to load plugins when target platform = host platform
255
		// see PluginPathFinder.getPluginPaths() and PluginPathFinder.isDevLaunchMode()
259
		IPluginModelBase base = (IPluginModelBase) fAllBundles.get(PDECore.PLUGIN_ID);
256
		Map pluginsToRun = LaunchPluginValidator.getPluginsToRun(configuration);
257
		IPluginModelBase base = (IPluginModelBase) pluginsToRun.get(PDECore.PLUGIN_ID);
258
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0) { //$NON-NLS-1$
260
		if (base != null && VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0) { //$NON-NLS-1$
259
			vmArgs = concatArg(vmArgs, "-Declipse.pde.launch=true"); //$NON-NLS-1$
261
			vmArgs = concatArg(vmArgs, "-Declipse.pde.launch=true"); //$NON-NLS-1$
260
		}
262
		}
261
		// For p2 target, add "-Declipse.p2.data.area=@config.dir/p2" unless already specified by user
263
		// For p2 target, add "-Declipse.p2.data.area=@config.dir/p2" unless already specified by user
262
		if (pluginsToRun.containsKey("org.eclipse.equinox.p2.core")) { //$NON-NLS-1$
264
		if (fAllBundles.containsKey("org.eclipse.equinox.p2.core")) { //$NON-NLS-1$
263
			if (vmArgs.indexOf("-Declipse.p2.data.area=") < 0) { //$NON-NLS-1$
265
			if (vmArgs.indexOf("-Declipse.p2.data.area=") < 0) { //$NON-NLS-1$
264
				vmArgs = concatArg(vmArgs, "-Declipse.p2.data.area=@config.dir" + File.separator + "p2"); //$NON-NLS-1$ //$NON-NLS-2$
266
				vmArgs = concatArg(vmArgs, "-Declipse.p2.data.area=@config.dir" + File.separator + "p2"); //$NON-NLS-1$ //$NON-NLS-2$
265
			}
267
			}
Lines 381-397 Link Here
381
	 * @see org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
383
	 * @see org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
382
	 */
384
	 */
383
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
385
	protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
384
		// Get the list of plug-ins to run
385
		fPluginMap = LaunchPluginValidator.getPluginsToRun(configuration);
386
387
		fWorkspaceLocation = null;
386
		fWorkspaceLocation = null;
387
		fModels = BundleLauncherHelper.getMergedBundleMap(configuration, false);
388
		fAllBundles = new HashMap(fModels.size());
389
		Iterator iter = fModels.keySet().iterator();
390
		while (iter.hasNext()) {
391
			IPluginModelBase model = (IPluginModelBase) iter.next();
392
			fAllBundles.put(model.getPluginBase().getId(), model);
393
		}
388
394
389
		// implicitly add the plug-ins required for JUnit testing if necessary
395
		// implicitly add the plug-ins required for JUnit testing if necessary
390
		String[] requiredPlugins = getRequiredPlugins(configuration);
396
		String[] requiredPlugins = getRequiredPlugins(configuration);
391
		for (int i = 0; i < requiredPlugins.length; i++) {
397
		for (int i = 0; i < requiredPlugins.length; i++) {
392
			String id = requiredPlugins[i];
398
			String id = requiredPlugins[i];
393
			if (!fPluginMap.containsKey(id)) {
399
			if (!fAllBundles.containsKey(id)) {
394
				fPluginMap.put(id, findPlugin(id));
400
				IPluginModelBase model = findPlugin(id);
401
				fAllBundles.put(id, model);
402
				fModels.put(model, "default:default"); //$NON-NLS-1$
395
			}
403
			}
396
		}
404
		}
397
405
(-)src/org/eclipse/pde/internal/ui/wizards/feature/CreateFeatureProjectFromLaunchOperation.java (-4 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2008 IBM Corporation and others.
2
 * Copyright (c) 2007, 2009 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     EclipseSource Corporation - ongoing enhancements
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.pde.internal.ui.wizards.feature;
13
package org.eclipse.pde.internal.ui.wizards.feature;
Lines 21-27 Link Here
21
import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel;
22
import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel;
22
import org.eclipse.pde.internal.core.ifeature.IFeature;
23
import org.eclipse.pde.internal.core.ifeature.IFeature;
23
import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper;
24
import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper;
24
import org.eclipse.pde.internal.ui.launcher.LaunchPluginValidator;
25
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
25
import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
26
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
26
import org.eclipse.pde.ui.launcher.IPDELauncherConstants;
27
import org.eclipse.swt.widgets.Shell;
27
import org.eclipse.swt.widgets.Shell;
Lines 47-56 Link Here
47
			String id = type.getIdentifier();
47
			String id = type.getIdentifier();
48
			// if it is an Eclipse launch
48
			// if it is an Eclipse launch
49
			if (id.equals(EclipseLaunchShortcut.CONFIGURATION_TYPE))
49
			if (id.equals(EclipseLaunchShortcut.CONFIGURATION_TYPE))
50
				models = LaunchPluginValidator.getPluginList(fLaunchConfig);
50
				models = BundleLauncherHelper.getMergedBundles(fLaunchConfig, false);
51
			// else if it is an OSGi launch
51
			// else if it is an OSGi launch
52
			else if (id.equals(IPDELauncherConstants.OSGI_CONFIGURATION_TYPE))
52
			else if (id.equals(IPDELauncherConstants.OSGI_CONFIGURATION_TYPE))
53
				models = BundleLauncherHelper.getMergedBundles(fLaunchConfig);
53
				models = BundleLauncherHelper.getMergedBundles(fLaunchConfig, true);
54
		} catch (CoreException e) {
54
		} catch (CoreException e) {
55
		}
55
		}
56
		IPluginBase[] result = new IPluginBase[models == null ? 0 : models.length];
56
		IPluginBase[] result = new IPluginBase[models == null ? 0 : models.length];

Return to bug 269111