use of org.eclipse.sisu.equinox.launching.BundleStartLevel in project tycho by eclipse.
the class P2ApplicationLauncher method execute.
public int execute(int forkedProcessTimeoutInSeconds) {
try {
File installationFolder = newTemporaryFolder();
try {
final EquinoxInstallationDescription description = new DefaultEquinoxInstallationDescription();
runtimeLocator.locateRuntime(new EquinoxRuntimeDescription() {
@Override
public void addPlatformProperty(String property, String value) {
description.addPlatformProperty(property, value);
}
@Override
public void addInstallation(File location) {
for (File file : new File(location, "plugins").listFiles()) {
P2ApplicationLauncher.this.addBundle(description, file);
}
}
@Override
public void addExtraSystemPackage(String systemPackages) {
}
@Override
public void addBundle(File location) {
P2ApplicationLauncher.this.addBundle(description, location);
}
@Override
public void addBundleStartLevel(String id, int level, boolean autostart) {
description.addBundleStartLevel(new BundleStartLevel(id, level, autostart));
}
});
EquinoxInstallation installation = installationFactory.createInstallation(description, installationFolder);
EquinoxLaunchConfiguration launchConfiguration = new EquinoxLaunchConfiguration(installation);
launchConfiguration.setWorkingDirectory(workingDirectory);
launchConfiguration.addProgramArguments("-configuration", installation.getConfigurationLocation().getAbsolutePath());
if (logger.isDebugEnabled()) {
launchConfiguration.addProgramArguments("-debug", "-consoleLog");
launchConfiguration.addProgramArguments("-console");
}
// application and application arguments
launchConfiguration.addProgramArguments("-nosplash", "-application", applicationName);
launchConfiguration.addProgramArguments(args.toArray(new String[args.size()]));
return launcher.execute(launchConfiguration, forkedProcessTimeoutInSeconds);
} finally {
try {
FileUtils.deleteDirectory(installationFolder);
} catch (IOException e) {
// this may happen if child process did not close all file handles
logger.warn("Failed to delete temp folder " + installationFolder);
}
}
} catch (Exception e) {
// TODO better exception?
throw new RuntimeException(e);
}
}
use of org.eclipse.sisu.equinox.launching.BundleStartLevel in project tycho by eclipse.
the class DefaultEquinoxInstallationFactoryTest method setup.
@Before
public void setup() {
bundles = new HashMap<>();
bundles.put(new DefaultArtifactKey("eclipse-plugin", "org.example.bundle1", "1.0"), mockFile("absolute/path/to/bundle1"));
bundles.put(new DefaultArtifactKey("eclipse-plugin", "org.example.bundle2", "1.0"), mockFile("absolute/path/to/bundle2"));
instDesc = new DefaultEquinoxInstallationDescription();
defaultLevel = new BundleStartLevel(null, 7, false);
subject = new DefaultEquinoxInstallationFactory(mock(Logger.class));
}
use of org.eclipse.sisu.equinox.launching.BundleStartLevel in project tycho by eclipse.
the class DefaultEquinoxInstallationFactoryTest method testExplicitlyConfiguredStartLevel.
@Test
public void testExplicitlyConfiguredStartLevel() throws IOException {
instDesc.addBundleStartLevel(new BundleStartLevel("org.example.bundle1", 6, false));
List<String> config = splitAtComma(subject.toOsgiBundles(bundles, instDesc.getBundleStartLevel(), defaultLevel));
assertThat(config, hasItem("reference:file:absolute/path/to/bundle1@6"));
}
use of org.eclipse.sisu.equinox.launching.BundleStartLevel in project tycho by eclipse.
the class DefaultEquinoxInstallationFactoryTest method testExplicitlyConfiguredAutoStart.
@Test
public void testExplicitlyConfiguredAutoStart() throws Exception {
// level attribute omitted
instDesc.addBundleStartLevel(new BundleStartLevel("org.example.bundle1", 0, true));
List<String> config = splitAtComma(subject.toOsgiBundles(bundles, instDesc.getBundleStartLevel(), defaultLevel));
// implicitly use default start level
assertThat(config, hasItem("reference:file:absolute/path/to/bundle1@start"));
}
Aggregations