use of org.eclipse.sisu.equinox.launching.EquinoxInstallation 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.EquinoxInstallation in project tycho by eclipse.
the class TestMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (shouldSkip()) {
getLog().info("Skipping tests");
return;
}
if (!"eclipse-test-plugin".equals(project.getPackaging())) {
getLog().warn("Unsupported packaging type " + project.getPackaging());
return;
}
EquinoxInstallation equinoxTestRuntime;
if ("p2Installed".equals(testRuntime)) {
equinoxTestRuntime = createProvisionedInstallation();
} else if ("default".equals(testRuntime)) {
equinoxTestRuntime = createEclipseInstallation();
} else {
throw new MojoExecutionException("Configured testRuntime parameter value '" + testRuntime + "' is unkown. Allowed values: 'default', 'p2Installed'.");
}
runTest(equinoxTestRuntime);
}
Aggregations