Java Code Examples for org.gradle.process.internal.ExecHandle#waitForFinish()
The following examples show how to use
org.gradle.process.internal.ExecHandle#waitForFinish() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ForkingGradleHandle.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
protected ExecutionResult waitForStop(boolean expectFailure) { ExecHandle execHandle = getExecHandle(); ExecResult execResult = execHandle.waitForFinish(); execResult.rethrowFailure(); // nop if all ok String output = getStandardOutput(); String error = getErrorOutput(); boolean didFail = execResult.getExitValue() != 0; if (didFail != expectFailure) { String message = String.format("Gradle execution %s in %s with: %s %s%nOutput:%n%s%n-----%nError:%n%s%n-----%n", expectFailure ? "did not fail" : "failed", execHandle.getDirectory(), execHandle.getCommand(), execHandle.getArguments(), output, error); throw new UnexpectedBuildFailure(message); } ExecutionResult executionResult = expectFailure ? toExecutionFailure(output, error) : toExecutionResult(output, error); resultAssertion.execute(executionResult); return executionResult; }
Example 2
Source File: ForkingGradleHandle.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
protected ExecutionResult waitForStop(boolean expectFailure) { ExecHandle execHandle = getExecHandle(); ExecResult execResult = execHandle.waitForFinish(); execResult.rethrowFailure(); // nop if all ok String output = getStandardOutput(); String error = getErrorOutput(); boolean didFail = execResult.getExitValue() != 0; if (didFail != expectFailure) { String message = String.format("Gradle execution %s in %s with: %s %s%nOutput:%n%s%n-----%nError:%n%s%n-----%n", expectFailure ? "did not fail" : "failed", execHandle.getDirectory(), execHandle.getCommand(), execHandle.getArguments(), output, error); throw new UnexpectedBuildFailure(message); } ExecutionResult executionResult = expectFailure ? toExecutionFailure(output, error) : toExecutionResult(output, error); resultAssertion.execute(executionResult); return executionResult; }
Example 3
Source File: ForkingGradleHandle.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
protected ExecutionResult waitForStop(boolean expectFailure) { ExecHandle execHandle = getExecHandle(); ExecResult execResult = execHandle.waitForFinish(); execResult.rethrowFailure(); // nop if all ok String output = getStandardOutput(); String error = getErrorOutput(); boolean didFail = execResult.getExitValue() != 0; if (didFail != expectFailure) { String message = String.format("Gradle execution %s in %s with: %s %s%nOutput:%n%s%n-----%nError:%n%s%n-----%n", expectFailure ? "did not fail" : "failed", execHandle.getDirectory(), execHandle.getCommand(), execHandle.getArguments(), output, error); throw new UnexpectedBuildFailure(message); } ExecutionResult executionResult = expectFailure ? toExecutionFailure(output, error) : toExecutionResult(output, error); resultAssertion.execute(executionResult); return executionResult; }
Example 4
Source File: ForkingGradleHandle.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
protected ExecutionResult waitForStop(boolean expectFailure) { ExecHandle execHandle = getExecHandle(); ExecResult execResult = execHandle.waitForFinish(); execResult.rethrowFailure(); // nop if all ok String output = getStandardOutput(); String error = getErrorOutput(); boolean didFail = execResult.getExitValue() != 0; if (didFail != expectFailure) { String message = String.format("Gradle execution %s in %s with: %s %s%nOutput:%n%s%n-----%nError:%n%s%n-----%n", expectFailure ? "did not fail" : "failed", execHandle.getDirectory(), execHandle.getCommand(), execHandle.getArguments(), output, error); throw new UnexpectedBuildFailure(message); } ExecutionResult executionResult = expectFailure ? toExecutionFailure(output, error) : toExecutionResult(output, error); resultAssertion.execute(executionResult); return executionResult; }
Example 5
Source File: CommandLineJavaCompiler.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void executeCompiler(ExecHandle handle) { handle.start(); ExecResult result = handle.waitForFinish(); if (result.getExitValue() != 0) { throw new CompilationFailedException(result.getExitValue()); } }
Example 6
Source File: CommandLineJavaCompiler.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void executeCompiler(ExecHandle handle) { handle.start(); ExecResult result = handle.waitForFinish(); if (result.getExitValue() != 0) { throw new CompilationFailedException(result.getExitValue()); } }
Example 7
Source File: AspectJCompiler.java From gradle-plugins with MIT License | 5 votes |
private void executeCompiler(ExecHandle handle) { handle.start(); ExecResult result = handle.waitForFinish(); if (result.getExitValue() != 0) { throw new CompilationFailedException(result.getExitValue()); } }
Example 8
Source File: AspectJCompiler.java From gradle-plugins with MIT License | 5 votes |
private void executeCompiler(ExecHandle handle) { handle.start(); ExecResult result = handle.waitForFinish(); if (result.getExitValue() != 0) { throw new CompilationFailedException(result.getExitValue()); } }
Example 9
Source File: CommandLineJavaCompiler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void executeCompiler(ExecHandle handle) { handle.start(); ExecResult result = handle.waitForFinish(); if (result.getExitValue() != 0) { throw new CompilationFailedException(result.getExitValue()); } }
Example 10
Source File: CommandLineJavaCompiler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void executeCompiler(ExecHandle handle) { handle.start(); ExecResult result = handle.waitForFinish(); if (result.getExitValue() != 0) { throw new CompilationFailedException(result.getExitValue()); } }
Example 11
Source File: ProcessLauncherServer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
/** * 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 ExecHandleBuilder(); 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()); setExternalProcess(null); //clear our external process member variable (we're using our local variable below). This is so we know the process has already stopped. executionInfo.processExecutionComplete(); notifyClientExited(result.getExitValue(), output.toString()); } }); thread.start(); }
Example 12
Source File: ProcessLauncherServer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
/** * 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 ExecHandleBuilder(); 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()); setExternalProcess(null); //clear our external process member variable (we're using our local variable below). This is so we know the process has already stopped. executionInfo.processExecutionComplete(); notifyClientExited(result.getExitValue(), output.toString()); } }); thread.start(); }