|
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 |
} |