use of org.eclipse.sisu.equinox.launching.EquinoxLaunchingException in project tycho by eclipse.
the class DefaultEquinoxLauncher method execute.
@Override
public int execute(LaunchConfiguration configuration, int forkedProcessTimeoutInSeconds) throws EquinoxLaunchingException {
String executable = configuration.getJvmExecutable();
if (executable == null || "".equals(executable)) {
// use the same JVM as the one used to run Maven (the "java.home" one)
executable = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
if (File.separatorChar == '\\') {
executable = executable + ".exe";
}
}
CommandLine cli = new CommandLine(executable);
final boolean handleQuotes = false;
cli.addArguments(configuration.getVMArguments(), handleQuotes);
cli.addArguments(new String[] { "-jar", getCanonicalPath(configuration.getLauncherJar()) }, handleQuotes);
cli.addArguments(configuration.getProgramArguments(), handleQuotes);
log.info("Command line:\n\t" + cli.toString());
DefaultExecutor executor = new DefaultExecutor();
ExecuteWatchdog watchdog = null;
if (forkedProcessTimeoutInSeconds > 0) {
watchdog = new ExecuteWatchdog(forkedProcessTimeoutInSeconds * 1000L);
executor.setWatchdog(watchdog);
}
// best effort to avoid orphaned child process
executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
executor.setWorkingDirectory(configuration.getWorkingDirectory());
try {
return executor.execute(cli, getMergedEnvironment(configuration));
} catch (ExecuteException e) {
if (watchdog != null && watchdog.killedProcess()) {
log.error("Timeout " + forkedProcessTimeoutInSeconds + " s exceeded. Process was killed.");
}
return e.getExitValue();
} catch (IOException e) {
throw new EquinoxLaunchingException(e);
}
}
Aggregations