org.gradle.process.internal.ExecHandle Java Examples

The following examples show how to use org.gradle.process.internal.ExecHandle. 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 vote down vote up
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 Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 vote down vote up
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 Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void executeCompiler(ExecHandle handle) {
    handle.start();
    ExecResult result = handle.waitForFinish();
    if (result.getExitValue() != 0) {
        throw new CompilationFailedException(result.getExitValue());
    }
}
 
Example #6
Source File: ForkingGradleHandle.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected ExecHandle getExecHandle() {
    if (execHandle == null) {
        throw new IllegalStateException("you must call start() before calling this method");
    }

    return execHandle;
}
 
Example #7
Source File: CommandLineJavaCompiler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private ExecHandle createCompilerHandle(String executable, JavaCompileSpec spec) {
    ExecHandleBuilder builder = new ExecHandleBuilder();
    builder.setWorkingDir(workingDir);
    builder.setExecutable(executable);
    argumentsGenerator.collectArguments(spec, new ExecSpecBackedArgCollector(builder));
    builder.setIgnoreExitValue(true);
    return builder.build();
}
 
Example #8
Source File: CommandLineJavaCompiler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public WorkResult execute(JavaCompileSpec spec) {
    String executable = spec.getCompileOptions().getForkOptions().getExecutable();
    LOGGER.info("Compiling with Java command line compiler '{}'.", executable);

    ExecHandle handle = createCompilerHandle(executable, spec);
    executeCompiler(handle);

    return new SimpleWorkResult(true);
}
 
Example #9
Source File: DaemonExecHandleBuilder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ExecHandle build(List<String> args, File workingDir, DaemonOutputConsumer outputConsumer) {
    builder.commandLine(args);
    builder.setWorkingDir(workingDir);
    builder.redirectErrorStream();
    builder.setTimeout(30000);
    builder.setDaemon(true);
    builder.setDisplayName("Gradle build daemon");
    builder.streamsHandler(outputConsumer);
    return builder.build();
}
 
Example #10
Source File: ForkingGradleHandle.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected ExecHandle getExecHandle() {
    if (execHandle == null) {
        throw new IllegalStateException("you must call start() before calling this method");
    }

    return execHandle;
}
 
Example #11
Source File: CommandLineJavaCompiler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void executeCompiler(ExecHandle handle) {
    handle.start();
    ExecResult result = handle.waitForFinish();
    if (result.getExitValue() != 0) {
        throw new CompilationFailedException(result.getExitValue());
    }
}
 
Example #12
Source File: CommandLineJavaCompiler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private ExecHandle createCompilerHandle(String executable, JavaCompileSpec spec) {
    ExecHandleBuilder builder = new ExecHandleBuilder();
    builder.setWorkingDir(spec.getWorkingDir());
    builder.setExecutable(executable);
    argumentsGenerator.collectArguments(spec, new ExecSpecBackedArgCollector(builder));
    builder.setIgnoreExitValue(true);
    return builder.build();
}
 
Example #13
Source File: CommandLineJavaCompiler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public WorkResult execute(JavaCompileSpec spec) {
    String executable = spec.getCompileOptions().getForkOptions().getExecutable();
    LOGGER.info("Compiling with Java command line compiler '{}'.", executable);

    ExecHandle handle = createCompilerHandle(executable, spec);
    executeCompiler(handle);

    return new SimpleWorkResult(true);
}
 
Example #14
Source File: DaemonExecHandleBuilder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ExecHandle build(List<String> args, File workingDir, DaemonOutputConsumer outputConsumer) {
    builder.commandLine(args);
    builder.setWorkingDir(workingDir);
    builder.redirectErrorStream();
    builder.setTimeout(30000);
    builder.setDaemon(true);
    builder.setDisplayName("Gradle build daemon");
    builder.streamsHandler(outputConsumer);
    return builder.build();
}
 
Example #15
Source File: ForkingGradleHandle.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected ExecHandle getExecHandle() {
    if (execHandle == null) {
        throw new IllegalStateException("you must call start() before calling this method");
    }

    return execHandle;
}
 
Example #16
Source File: AspectJCompiler.java    From gradle-plugins with MIT License 5 votes vote down vote up
private void executeCompiler(ExecHandle handle) {
    handle.start();
    ExecResult result = handle.waitForFinish();
    if (result.getExitValue() != 0) {
        throw new CompilationFailedException(result.getExitValue());
    }
}
 
Example #17
Source File: DaemonExecHandleBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ExecHandle build(List<String> args, File workingDir, DaemonOutputConsumer outputConsumer) {
    builder.commandLine(args);
    builder.setWorkingDir(workingDir);
    builder.redirectErrorStream();
    builder.setTimeout(30000);
    builder.setDaemon(true);
    builder.setDisplayName("Gradle build daemon");
    builder.streamsHandler(outputConsumer);
    return builder.build();
}
 
Example #18
Source File: DaemonExecHandleBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ExecHandle build(List<String> args, File workingDir, DaemonOutputConsumer outputConsumer) {
    builder.commandLine(args);
    builder.setWorkingDir(workingDir);
    builder.redirectErrorStream();
    builder.setTimeout(30000);
    builder.setDaemon(true);
    builder.setDisplayName("Gradle build daemon");
    builder.streamsHandler(outputConsumer);
    return builder.build();
}
 
Example #19
Source File: CommandLineJavaCompiler.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public WorkResult execute(JavaCompileSpec spec) {
    String executable = spec.getCompileOptions().getForkOptions().getExecutable();
    LOGGER.info("Compiling with Java command line compiler '{}'.", executable);

    ExecHandle handle = createCompilerHandle(executable, spec);
    executeCompiler(handle);

    return new SimpleWorkResult(true);
}
 
Example #20
Source File: CommandLineJavaCompiler.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private ExecHandle createCompilerHandle(String executable, JavaCompileSpec spec) {
    ExecHandleBuilder builder = new ExecHandleBuilder();
    builder.setWorkingDir(spec.getWorkingDir());
    builder.setExecutable(executable);
    argumentsGenerator.collectArguments(spec, new ExecSpecBackedArgCollector(builder));
    builder.setIgnoreExitValue(true);
    return builder.build();
}
 
Example #21
Source File: CommandLineJavaCompiler.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void executeCompiler(ExecHandle handle) {
    handle.start();
    ExecResult result = handle.waitForFinish();
    if (result.getExitValue() != 0) {
        throw new CompilationFailedException(result.getExitValue());
    }
}
 
Example #22
Source File: ForkingGradleHandle.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected ExecHandle getExecHandle() {
    if (execHandle == null) {
        throw new IllegalStateException("you must call start() before calling this method");
    }

    return execHandle;
}
 
Example #23
Source File: AspectJCompiler.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public WorkResult execute(AspectJCompileSpec spec) {

    ExecHandle handle = createCompilerHandle(spec);
    executeCompiler(handle);

    return WorkResults.didWork(true);
}
 
Example #24
Source File: CommandLineJavaCompiler.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public WorkResult execute(JavaCompileSpec spec) {
    String executable = spec.getCompileOptions().getForkOptions().getExecutable();
    LOGGER.info("Compiling with Java command line compiler '{}'.", executable);

    ExecHandle handle = createCompilerHandle(executable, spec);
    executeCompiler(handle);

    return new SimpleWorkResult(true);
}
 
Example #25
Source File: CommandLineJavaCompiler.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private ExecHandle createCompilerHandle(String executable, JavaCompileSpec spec) {
    ExecHandleBuilder builder = new ExecHandleBuilder();
    builder.setWorkingDir(workingDir);
    builder.setExecutable(executable);
    argumentsGenerator.collectArguments(spec, new ExecSpecBackedArgCollector(builder));
    builder.setIgnoreExitValue(true);
    return builder.build();
}
 
Example #26
Source File: CommandLineJavaCompiler.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void executeCompiler(ExecHandle handle) {
    handle.start();
    ExecResult result = handle.waitForFinish();
    if (result.getExitValue() != 0) {
        throw new CompilationFailedException(result.getExitValue());
    }
}
 
Example #27
Source File: AspectJCompiler.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public WorkResult execute(AspectJCompileSpec spec) {

    ExecHandle handle = createCompilerHandle(spec);
    executeCompiler(handle);

    return WorkResults.didWork(true);
}
 
Example #28
Source File: AspectJCompiler.java    From gradle-plugins with MIT License 5 votes vote down vote up
private void executeCompiler(ExecHandle handle) {
    handle.start();
    ExecResult result = handle.waitForFinish();
    if (result.getExitValue() != 0) {
        throw new CompilationFailedException(result.getExitValue());
    }
}
 
Example #29
Source File: ProcessLauncherServer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setExternalProcess(ExecHandle externalProcess) {
    this.externalProcess = externalProcess;
}
 
Example #30
Source File: ProcessLauncherServer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setExternalProcess(ExecHandle externalProcess) {
    this.externalProcess = externalProcess;
}