public static Dictionary getTargetEnvironment() { Dictionary result = new Hashtable(); result.put(ICoreConstants.OSGI_OS, TargetPlatform.getOS()); result.put(ICoreConstants.OSGI_WS, TargetPlatform.getWS()); result.put(ICoreConstants.OSGI_NL, TargetPlatform.getNL()); result.put(ICoreConstants.OSGI_ARCH, TargetPlatform.getOSArch()); result.put(ICoreConstants.OSGI_RESOLVE_OPTIONAL, "true"); // $NON-NLS-1$ result.put(ICoreConstants.OSGI_RESOLVER_MODE, "development"); // $NON-NLS-1$ return result; }
public static Properties getConfigIniProperties() { File iniFile = new File(TargetPlatform.getLocation(), "configuration/config.ini"); // $NON-NLS-1$ if (!iniFile.exists()) return null; Properties pini = new Properties(); FileInputStream fis = null; try { fis = new FileInputStream(iniFile); pini.load(fis); fis.close(); return pini; } catch (IOException e) { MDECore.logException(e); } finally { try { if (fis != null) fis.close(); } catch (IOException e) { MDECore.logException(e); } } return null; }
private boolean resourceExists(String location) { String bundleJar = null; IPath path = new Path(location); if ("platform:".equals(path.getDevice()) && path.segmentCount() > 2) { // $NON-NLS-1$ if ("plugin".equals(path.segment(0))) { // $NON-NLS-1$ String id = path.segment(1); IMonitorModelBase model = MonitorRegistry.findModel(id); if (model != null && model.isEnabled()) { path = path.setDevice(null).removeFirstSegments(2); String bundleLocation = model.getInstallLocation(); if (bundleLocation.endsWith(".jar")) { // $NON-NLS-1$ bundleJar = bundleLocation; } else { path = new Path(model.getInstallLocation()).append(path); } location = path.toString(); } } } else if (path.getDevice() == null && path.segmentCount() > 3 && "platform:".equals(path.segment(0))) { // $NON-NLS-1$ if ("plugin".equals(path.segment(1))) { // $NON-NLS-1$ String id = path.segment(2); IMonitorModelBase model = MonitorRegistry.findModel(id); if (model != null && model.isEnabled()) { path = path.removeFirstSegments(3); String bundleLocation = model.getInstallLocation(); if (bundleLocation.endsWith(".jar")) { // $NON-NLS-1$ bundleJar = bundleLocation; } else { path = new Path(model.getInstallLocation()).append(path); } location = path.toString(); } } } ArrayList paths = new ArrayList(); if (location.indexOf("$nl$") != -1) { // $NON-NLS-1$ StringTokenizer tokenizer = new StringTokenizer(TargetPlatform.getNL(), "_"); // $NON-NLS-1$ String language = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null; String country = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null; if (language != null && country != null) paths.add( location.replaceAll( "\\$nl\\$", "nl" + IPath.SEPARATOR + language + IPath.SEPARATOR + country)); //$NON-NLS-1$ //$NON-NLS-2$ if (language != null) paths.add( location.replaceAll( "\\$nl\\$", "nl" + IPath.SEPARATOR + language)); // $NON-NLS-1$ //$NON-NLS-2$ paths.add(location.replaceAll("\\$nl\\$", "")); // $NON-NLS-1$ //$NON-NLS-2$ } else { paths.add(location); } for (int i = 0; i < paths.size(); i++) { if (bundleJar == null) { IPath currPath = new Path(paths.get(i).toString()); if (currPath.isAbsolute() && currPath.toFile().exists()) return true; if (PDEProject.getBundleRoot(fFile.getProject()).findMember(currPath) != null) return true; if (fBuildModel != null && fBuildModel.getEntry("source." + paths.get(i)) != null) // $NON-NLS-1$ return true; } else { if (CoreUtility.jarContainsResource(new File(bundleJar), paths.get(i).toString(), false)) return true; } } return false; }
private void saveConfigurationFile(ILaunchConfiguration configuration) throws CoreException { Properties properties = new Properties(); properties.setProperty( "osgi.install.area", "file:" + TargetPlatform.getLocation()); // $NON-NLS-1$ //$NON-NLS-2$ properties.setProperty("osgi.configuration.cascaded", "false"); // $NON-NLS-1$ //$NON-NLS-2$ properties.put( "osgi.framework", LaunchConfigurationHelper.getBundleURL( IPDEBuildConstants.BUNDLE_OSGI, fAllBundles, false)); // $NON-NLS-1$ int start = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4); properties.put("osgi.bundles.defaultStartLevel", Integer.toString(start)); // $NON-NLS-1$ boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true); String bundles = null; if (fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) { // If update configurator is set to its default start level, override it as simple/update // configurators should not be autostarted together Object updateConfiguratorBundle = fAllBundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR); if (updateConfiguratorBundle != null) { String startLevel = (String) fModels.get(updateConfiguratorBundle); if (startLevel != null && startLevel.equals(BundleLauncherHelper.DEFAULT_UPDATE_CONFIGURATOR_START_LEVEL)) { fModels.put(updateConfiguratorBundle, "4:false"); // $NON-NLS-1$ } } // If simple configurator is being used, we need to write out the bundles.txt instead of // writing out the list in the config.ini URL bundlesTxt = P2Utils.writeBundlesTxt(fModels, start, autostart, getConfigDir(configuration), null); if (bundlesTxt != null) { properties.setProperty( "org.eclipse.equinox.simpleconfigurator.configUrl", bundlesTxt.toString()); // $NON-NLS-1$ if (fAllBundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) { properties.setProperty( "org.eclipse.update.reconcile", "false"); // $NON-NLS-1$ //$NON-NLS-2$ } } StringBuffer buffer = new StringBuffer(); IMonitorModelBase model = (IMonitorModelBase) fAllBundles.get(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR); buffer.append(LaunchConfigurationHelper.getBundleURL(model, true)); appendStartData(buffer, (String) fModels.get(model), autostart); bundles = buffer.toString(); } else { bundles = getBundles(autostart); } if (bundles.length() > 0) properties.put("osgi.bundles", bundles); // $NON-NLS-1$ if (!"3.3" .equals( configuration.getAttribute( IPDEConstants.LAUNCHER_PDE_VERSION, ""))) { // $NON-NLS-1$ //$NON-NLS-2$ properties.put("eclipse.ignoreApp", "true"); // $NON-NLS-1$ //$NON-NLS-2$ properties.put("osgi.noShutdown", "true"); // $NON-NLS-1$ //$NON-NLS-2$ } LaunchConfigurationHelper.save( new File(getConfigDir(configuration), "config.ini"), properties); // $NON-NLS-1$ }