use of org.eclipse.tycho.model.BundleConfiguration in project tycho by eclipse.
the class WorkspaceTychoOsgiRuntimeLocator method addProduct.
public boolean addProduct(EquinoxRuntimeDescription result, Artifact pom) throws MavenExecutionException {
ProductConfiguration product;
try {
product = ProductConfiguration.read(new File(pom.getFile().getParentFile(), pom.getArtifactId() + ".product"));
} catch (IOException e) {
return false;
}
// the above fails with IOException if .product file is not available or can't be read
// we get here only when we have valid product instance
Set<String> missing = new LinkedHashSet<>();
for (PluginRef pluginRef : product.getPlugins()) {
DevBundleInfo bundleInfo = workspaceState.getBundleInfo(pluginRef.getId(), pluginRef.getVersion());
if (bundleInfo != null) {
addBundle(result, bundleInfo);
} else {
missing.add(pluginRef.toString());
}
}
if (!missing.isEmpty()) {
throw new MavenExecutionException("Inconsistent m2e-tycho workspace state, missing bundles: " + missing.toString(), (Throwable) null);
}
Map<String, BundleConfiguration> bundleConfigurations = product.getPluginConfiguration();
if (bundleConfigurations != null) {
for (BundleConfiguration bundleConfiguration : bundleConfigurations.values()) {
result.addBundleStartLevel(bundleConfiguration.getId(), bundleConfiguration.getStartLevel(), bundleConfiguration.isAutoStart());
}
}
return true;
}
use of org.eclipse.tycho.model.BundleConfiguration in project tycho by eclipse.
the class ProductConfigurationTest method testProductConfigurationParseWithStartLevel.
@Test
public void testProductConfigurationParseWithStartLevel() throws Exception {
ProductConfiguration config = ProductConfiguration.read(getClass().getResourceAsStream("/product/MyProduct.product"));
Map<String, BundleConfiguration> bundles = config.getPluginConfiguration();
// <plugin id="org.eclipse.core.contenttype" autoStart="true" startLevel="1" />
BundleConfiguration contentType = bundles.get("org.eclipse.core.contenttype");
Assert.assertNotNull(contentType);
Assert.assertTrue(contentType.isAutoStart());
Assert.assertEquals(1, contentType.getStartLevel());
// <plugin id="HeadlessProduct" autoStart="false" startLevel="2" />
BundleConfiguration headlessProduct = bundles.get("HeadlessProduct");
Assert.assertNotNull(headlessProduct);
Assert.assertFalse(headlessProduct.isAutoStart());
Assert.assertEquals(2, headlessProduct.getStartLevel());
}
use of org.eclipse.tycho.model.BundleConfiguration in project tycho by eclipse.
the class ProductExportMojo method generateOSGiBundles.
private void generateOSGiBundles(Properties props, TargetEnvironment environment) throws MojoFailureException {
Map<String, BundleConfiguration> bundlesToStart = productConfiguration.getPluginConfiguration();
if (bundlesToStart == null) {
bundlesToStart = new HashMap<>();
// This is the wellknown set of bundles for Eclipse based application for 3.3 and 3.4 without p2
//
bundlesToStart.put(//
"org.eclipse.equinox.common", new BundleConfiguration("org.eclipse.equinox.common", 2, true));
//
bundlesToStart.put(//
"org.eclipse.core.runtime", new BundleConfiguration("org.eclipse.core.runtime", -1, true));
}
Map<String, PluginDescription> bundles = new LinkedHashMap<>(getBundles(environment));
StringBuilder osgiBundles = new StringBuilder();
for (PluginDescription plugin : bundles.values()) {
String bundleId = plugin.getKey().getId();
// starts
if ("org.eclipse.osgi".equals(bundleId)) {
continue;
}
if (osgiBundles.length() > 0) {
osgiBundles.append(',');
}
osgiBundles.append(bundleId);
BundleConfiguration startup = bundlesToStart.get(bundleId);
if (startup != null) {
osgiBundles.append('@');
if (startup.getStartLevel() > 0) {
osgiBundles.append(startup.getStartLevel());
}
if (startup.isAutoStart()) {
if (startup.getStartLevel() > 0) {
osgiBundles.append(':');
}
osgiBundles.append("start");
}
}
}
setPropertyIfNotNull(props, "osgi.bundles", osgiBundles.toString());
}
Aggregations