return (ExecutionFailure) waitForStop(true);
}
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);
}