|
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, bundlesWithStartLevels)); |
| 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, bundlesWithStartLevels); |
| 110 |
} else { |
110 |
} else { |
| 111 |
properties = new Properties(); |
111 |
properties = new Properties(); |
| 112 |
} |
112 |
} |
|
Lines 119-168
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; |
| 163 |
} |
145 |
} |
| 164 |
|
146 |
|
| 165 |
private static void addRequiredProperties(Properties properties, String productID, Map map) { |
147 |
private static void addRequiredProperties(Properties properties, String productID, Map bundles, Map bundlesWithStartLevels) { |
| 166 |
if (!properties.containsKey("osgi.install.area")) //$NON-NLS-1$ |
148 |
if (!properties.containsKey("osgi.install.area")) //$NON-NLS-1$ |
| 167 |
properties.setProperty("osgi.install.area", "file:" + TargetPlatform.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$ |
149 |
properties.setProperty("osgi.install.area", "file:" + TargetPlatform.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$ |
| 168 |
if (!properties.containsKey("osgi.configuration.cascaded")) //$NON-NLS-1$ |
150 |
if (!properties.containsKey("osgi.configuration.cascaded")) //$NON-NLS-1$ |
|
Lines 170-181
Link Here
|
| 170 |
if (!properties.containsKey(PROP_OSGI_FRAMEWORK)) |
152 |
if (!properties.containsKey(PROP_OSGI_FRAMEWORK)) |
| 171 |
properties.setProperty(PROP_OSGI_FRAMEWORK, IPDEBuildConstants.BUNDLE_OSGI); |
153 |
properties.setProperty(PROP_OSGI_FRAMEWORK, IPDEBuildConstants.BUNDLE_OSGI); |
| 172 |
if (!properties.containsKey("osgi.splashPath") && productID != null) //$NON-NLS-1$ |
154 |
if (!properties.containsKey("osgi.splashPath") && productID != null) //$NON-NLS-1$ |
| 173 |
addSplashLocation(properties, productID, map); |
155 |
addSplashLocation(properties, productID, bundles); |
| 174 |
// if osgi.splashPath is set, try to resolve relative paths to absolute paths |
156 |
// if osgi.splashPath is set, try to resolve relative paths to absolute paths |
| 175 |
if (properties.containsKey("osgi.splashPath")) //$NON-NLS-1$ |
157 |
if (properties.containsKey("osgi.splashPath")) //$NON-NLS-1$ |
| 176 |
resolveLocationPath(properties.getProperty("osgi.splashPath"), properties, map); //$NON-NLS-1$ |
158 |
resolveLocationPath(properties.getProperty("osgi.splashPath"), properties, bundles); //$NON-NLS-1$ |
| 177 |
if (!properties.containsKey(PROP_OSGI_BUNDLES)) |
159 |
if (!properties.containsKey(PROP_OSGI_BUNDLES)) |
| 178 |
properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatform.getBundleList(), map)); |
160 |
properties.setProperty(PROP_OSGI_BUNDLES, computeOSGiBundles(TargetPlatform.getBundleList(), bundles, bundlesWithStartLevels)); |
| 179 |
if (!properties.containsKey("osgi.bundles.defaultStartLevel")) //$NON-NLS-1$ |
161 |
if (!properties.containsKey("osgi.bundles.defaultStartLevel")) //$NON-NLS-1$ |
| 180 |
properties.setProperty("osgi.bundles.defaultStartLevel", "4"); //$NON-NLS-1$ //$NON-NLS-2$ |
162 |
properties.setProperty("osgi.bundles.defaultStartLevel", "4"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 181 |
} |
163 |
} |
|
Lines 186-201
Link Here
|
| 186 |
* launching with. The list of bundles must have already had it's path information |
168 |
* launching with. The list of bundles must have already had it's path information |
| 187 |
* removed. |
169 |
* removed. |
| 188 |
* @param bundleList list of bundles without path information |
170 |
* @param bundleList list of bundles without path information |
| 189 |
* @param map map of bundle id to bundle model, contains all bundles being launched with |
171 |
* @param bundles map of bundle id to bundle model, contains all bundles being launched with |
|
|
172 |
* @param bundlesWithStartLevels map of bundles of start level |
| 190 |
* @return string list of osgi bundles |
173 |
* @return string list of osgi bundles |
| 191 |
*/ |
174 |
*/ |
| 192 |
private static String computeOSGiBundles(String bundleList, Map map) { |
175 |
private static String computeOSGiBundles(String bundleList, Map bundles, Map bundlesWithStartLevels) { |
| 193 |
|
176 |
|
| 194 |
// if p2 and only simple configurator and |
177 |
// if p2 and only simple configurator and |
| 195 |
// if simple configurator isn't selected & isn't in bundle list... hack it |
178 |
// if simple configurator isn't selected & isn't in bundle list... hack it |
| 196 |
|
179 |
|
| 197 |
// if using p2's simple configurator, a bundles.txt will be written, so we only need simple configurator in the config.ini |
180 |
// if using p2's simple configurator, a bundles.txt will be written, so we only need simple configurator in the config.ini |
| 198 |
if (map.get(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR) != null) |
181 |
if (bundles.get(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR) != null) |
| 199 |
return "org.eclipse.equinox.simpleconfigurator@1:start"; //$NON-NLS-1$ |
182 |
return "org.eclipse.equinox.simpleconfigurator@1:start"; //$NON-NLS-1$ |
| 200 |
|
183 |
|
| 201 |
StringBuffer buffer = new StringBuffer(); |
184 |
StringBuffer buffer = new StringBuffer(); |
|
Lines 205-211
Link Here
|
| 205 |
String token = tokenizer.nextToken(); |
188 |
String token = tokenizer.nextToken(); |
| 206 |
int index = token.indexOf('@'); |
189 |
int index = token.indexOf('@'); |
| 207 |
String id = index != -1 ? token.substring(0, index) : token; |
190 |
String id = index != -1 ? token.substring(0, index) : token; |
| 208 |
if (map.containsKey(id)) { |
191 |
if (bundles.containsKey(id)) { |
| 209 |
if (buffer.length() > 0) |
192 |
if (buffer.length() > 0) |
| 210 |
buffer.append(','); |
193 |
buffer.append(','); |
| 211 |
buffer.append(id); |
194 |
buffer.append(id); |
|
Lines 218-234
Link Here
|
| 218 |
// if org.eclipse.update.configurator is not included (LIKE IN BASIC RCP APPLICATION), then write out all bundles in osgi.bundles - bug 170772 |
201 |
// if org.eclipse.update.configurator is not included (LIKE IN BASIC RCP APPLICATION), then write out all bundles in osgi.bundles - bug 170772 |
| 219 |
if (!initialBundleSet.contains(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR)) { |
202 |
if (!initialBundleSet.contains(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR)) { |
| 220 |
initialBundleSet.add(IPDEBuildConstants.BUNDLE_OSGI); |
203 |
initialBundleSet.add(IPDEBuildConstants.BUNDLE_OSGI); |
| 221 |
Iterator iter = map.keySet().iterator(); |
204 |
Iterator iter = bundlesWithStartLevels.keySet().iterator(); |
| 222 |
while (iter.hasNext()) { |
205 |
while (iter.hasNext()) { |
| 223 |
String id = iter.next().toString(); |
206 |
IPluginModelBase model = (IPluginModelBase) iter.next(); |
|
|
207 |
String id = model.getPluginBase().getId(); |
| 224 |
if (!initialBundleSet.contains(id)) { |
208 |
if (!initialBundleSet.contains(id)) { |
| 225 |
if (buffer.length() > 0) |
209 |
if (buffer.length() > 0) |
| 226 |
buffer.append(','); |
210 |
buffer.append(','); |
|
|
211 |
|
| 212 |
String slinfo = (String) bundlesWithStartLevels.get(model); |
| 227 |
buffer.append(id); |
213 |
buffer.append(id); |
| 228 |
// if we are working with core.runtime, we need to ensure it's started |
214 |
buffer.append('@'); |
| 229 |
if (IPDEBuildConstants.BUNDLE_CORE_RUNTIME.equals(id)) { |
215 |
buffer.append(slinfo); |
| 230 |
buffer.append("@start"); //$NON-NLS-1$ |
|
|
| 231 |
} |
| 232 |
} |
216 |
} |
| 233 |
} |
217 |
} |
| 234 |
} |
218 |
} |
|
Lines 360-374
Link Here
|
| 360 |
while (tokenizer.hasMoreTokens()) { |
344 |
while (tokenizer.hasMoreTokens()) { |
| 361 |
String token = tokenizer.nextToken().trim(); |
345 |
String token = tokenizer.nextToken().trim(); |
| 362 |
String url = getBundleURL(token, map, false); |
346 |
String url = getBundleURL(token, map, false); |
| 363 |
int index = -1; |
347 |
int i = -1; |
| 364 |
if (url == null) { |
348 |
if (url == null) { |
| 365 |
index = token.indexOf('@'); |
349 |
i = token.indexOf('@'); |
| 366 |
if (index != -1) |
350 |
if (i != -1) { |
| 367 |
url = getBundleURL(token.substring(0, index), map, false); |
351 |
url = getBundleURL(token.substring(0, i), map, false); |
|
|
352 |
} |
| 368 |
if (url == null) { |
353 |
if (url == null) { |
| 369 |
index = token.indexOf(':'); |
354 |
i = token.indexOf(':'); |
| 370 |
if (index != -1) |
355 |
if (i != -1) |
| 371 |
url = getBundleURL(token.substring(0, index), map, false); |
356 |
url = getBundleURL(token.substring(0, i), map, false); |
| 372 |
} |
357 |
} |
| 373 |
} |
358 |
} |
| 374 |
if (url != null) { |
359 |
if (url != null) { |
|
Lines 376-389
Link Here
|
| 376 |
buffer.append(","); //$NON-NLS-1$ |
361 |
buffer.append(","); //$NON-NLS-1$ |
| 377 |
} |
362 |
} |
| 378 |
buffer.append("reference:" + url); //$NON-NLS-1$ |
363 |
buffer.append("reference:" + url); //$NON-NLS-1$ |
| 379 |
if (index != -1) |
364 |
if (i != -1) { |
| 380 |
buffer.append(token.substring(index)); |
365 |
String slinfo = token.substring(i + 1); |
|
|
366 |
buffer.append(getStartData(slinfo, false)); |
| 367 |
} |
| 381 |
} |
368 |
} |
| 382 |
} |
369 |
} |
| 383 |
properties.setProperty(PROP_OSGI_BUNDLES, buffer.toString()); |
370 |
properties.setProperty(PROP_OSGI_BUNDLES, buffer.toString()); |
| 384 |
} |
371 |
} |
| 385 |
} |
372 |
} |
| 386 |
|
373 |
|
|
|
374 |
/** |
| 375 |
* Convenience method to parses the startData ("startLevel:autoStart"), convert it to the |
| 376 |
* format expected by the OSGi bundles property, and append to a StringBuffer. |
| 377 |
* @param startData data to parse ("startLevel:autoStart") |
| 378 |
* @param defaultAuto default auto start setting |
| 379 |
*/ |
| 380 |
public static String getStartData(String startData, boolean defaultAuto) { |
| 381 |
StringBuffer buffer = new StringBuffer(); |
| 382 |
int index = startData.indexOf(':'); |
| 383 |
String level = index > 0 ? startData.substring(0, index) : "default"; //$NON-NLS-1$ |
| 384 |
String auto = index > 0 && index < startData.length() - 1 ? startData.substring(index + 1) : "default"; //$NON-NLS-1$ |
| 385 |
if ("default".equals(auto)) //$NON-NLS-1$ |
| 386 |
auto = Boolean.toString(defaultAuto); |
| 387 |
if (!level.equals("default") || "true".equals(auto) || "start".equals(auto)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 388 |
buffer.append("@"); //$NON-NLS-1$ |
| 389 |
|
| 390 |
if (!level.equals("default")) { //$NON-NLS-1$ |
| 391 |
buffer.append(level); |
| 392 |
if ("start".equals(auto) || "true".equals(auto)) //$NON-NLS-1$ //$NON-NLS-2$ |
| 393 |
buffer.append(":"); //$NON-NLS-1$ |
| 394 |
} |
| 395 |
if ("start".equals(auto) || "true".equals(auto)) { //$NON-NLS-1$ //$NON-NLS-2$ |
| 396 |
buffer.append("start"); //$NON-NLS-1$ |
| 397 |
} |
| 398 |
return buffer.toString(); |
| 399 |
} |
| 400 |
|
| 387 |
public static void save(File file, Properties properties) { |
401 |
public static void save(File file, Properties properties) { |
| 388 |
try { |
402 |
try { |
| 389 |
FileOutputStream stream = new FileOutputStream(file); |
403 |
FileOutputStream stream = new FileOutputStream(file); |