use of org.gradle.process.ExecResult in project gradle by gradle.
the class DefaultWorkerProcess method setExecHandle.
public void setExecHandle(ExecHandle execHandle) {
this.execHandle = execHandle;
execHandle.addListener(new ExecHandleListener() {
public void executionStarted(ExecHandle execHandle) {
}
public void executionFinished(ExecHandle execHandle, ExecResult execResult) {
onProcessStop(execResult);
}
});
}
use of org.gradle.process.ExecResult in project gradle by gradle.
the class DefaultExecAction method execute.
public ExecResult execute() {
ExecHandle execHandle = build();
ExecResult execResult = execHandle.start().waitForFinish();
if (!isIgnoreExitValue()) {
execResult.assertNormalExitValue();
}
return execResult;
}
use of org.gradle.process.ExecResult in project gradle by gradle.
the class DefaultJavaExecAction method execute.
public ExecResult execute() {
ExecHandle execHandle = build();
ExecResult execResult = execHandle.start().waitForFinish();
if (!isIgnoreExitValue()) {
execResult.assertNormalExitValue();
}
return execResult;
}
use of org.gradle.process.ExecResult in project gradle by gradle.
the class ProcessLauncherServer method launchExternalProcess.
/**
* This launches an external process in a thread and waits for it to exit.
*/
private void launchExternalProcess() {
Thread thread = new Thread(new Runnable() {
public void run() {
ExecutionInfo executionInfo = null;
ExecHandle execHandle = null;
ByteArrayOutputStream output = null;
try {
executionInfo = protocol.getExecutionInfo(getPort());
ExecHandleBuilder builder = new DefaultExecHandleBuilder();
builder.workingDir(executionInfo.getWorkingDirectory());
builder.commandLine((Object[]) executionInfo.getCommandLineArguments());
builder.environment(executionInfo.getEnvironmentVariables());
output = new ByteArrayOutputStream();
builder.setStandardOutput(output);
builder.setErrorOutput(output);
execHandle = builder.build();
setExternalProcess(execHandle);
execHandle.start();
} catch (Throwable e) {
LOGGER.error("Starting external process", e);
notifyClientExited(-1, e.getMessage());
setExternalProcess(null);
return;
}
ExecResult result = execHandle.waitForFinish();
LOGGER.debug("External process completed with exit code {}", result.getExitValue());
//clear our external process member variable (we're using our local variable below). This is so we know the process has already stopped.
setExternalProcess(null);
executionInfo.processExecutionComplete();
notifyClientExited(result.getExitValue(), output.toString());
}
});
thread.start();
}
use of org.gradle.process.ExecResult in project gradle by gradle.
the class CommandLineToolVersionLocator method getVswhereOutput.
private String getVswhereOutput(File vswhereBinary, List<String> args) {
ExecAction exec = execActionFactory.newExecAction();
exec.args(args);
exec.executable(vswhereBinary.getAbsolutePath());
exec.setWorkingDir(vswhereBinary.getParentFile());
StreamByteBuffer buffer = new StreamByteBuffer();
exec.setStandardOutput(buffer.getOutputStream());
exec.setErrorOutput(NullOutputStream.INSTANCE);
exec.setIgnoreExitValue(true);
ExecResult result = exec.execute();
int exitValue = result.getExitValue();
if (exitValue == 0) {
return buffer.readAsString("UTF-8");
} else {
LOGGER.debug("vswhere.exe returned a non-zero exit value ({}) - ignoring", result.getExitValue());
return null;
}
}
Aggregations