Package org.gradle.process.internal

Examples of org.gradle.process.internal.ExecHandle


        builder.args(getAllArgs());

        LOG.info(String.format("Execute in %s with: %s %s", builder.getWorkingDir(), builder.getExecutable(),
                builder.getArgs()));

        ExecHandle proc = builder.build();
        int exitValue = proc.start().waitForFinish().getExitValue();

        String output = outStream.toString();
        String error = errStream.toString();
        boolean failed = exitValue != 0;
View Full Code Here


    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();
View Full Code Here

    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();
View Full Code Here

    public ExecutionFailure waitForFailure() {
        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);
        }

        ExecutionResult executionResult = expectFailure ? toExecutionFailure(output, error) : toExecutionResult(output, error);
        resultAssertion.execute(executionResult);
View Full Code Here

        Clock clock = new Clock();
        try {
            GFileUtils.mkdirs(workingDir);

            DaemonOutputConsumer outputConsumer = new DaemonOutputConsumer();
            ExecHandle handle = new DaemonExecHandleBuilder().build(args, workingDir, outputConsumer);

            handle.start();
            LOGGER.debug("Gradle daemon process is starting. Waiting for the daemon to detach...");
            ExecResult result = handle.waitForFinish();
            LOGGER.debug("Gradle daemon process is now detached.");

            return daemonGreeter.parseDaemonOutput(outputConsumer.getProcessOutput(), result);
        } catch (GradleException e) {
            throw e;
View Full Code Here

    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);
    }
View Full Code Here

TOP

Related Classes of org.gradle.process.internal.ExecHandle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.