当前位置: 首页>>代码示例>>Java>>正文


Java ExecResult类代码示例

本文整理汇总了Java中org.gradle.process.ExecResult的典型用法代码示例。如果您正苦于以下问题:Java ExecResult类的具体用法?Java ExecResult怎么用?Java ExecResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExecResult类属于org.gradle.process包,在下文中一共展示了ExecResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: waitForStop

import org.gradle.process.ExecResult; //导入依赖的package包/类
protected ExecutionResult waitForStop(boolean expectFailure) {
    ExecHandle execHandle = getExecHandle();
    ExecResult execResult = execHandle.waitForFinish();
    if (durationMeasurement != null) {
        durationMeasurement.stop();
    }
    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;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:ForkingGradleHandle.java

示例2: transform

import org.gradle.process.ExecResult; //导入依赖的package包/类
private String transform(File gccBinary, List<String> args) {
    ExecAction exec = execActionFactory.newExecAction();
    exec.executable(gccBinary.getAbsolutePath());
    exec.setWorkingDir(gccBinary.getParentFile());
    exec.args(args);
    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();
    } else {
        return null;
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:GccVersionDeterminer.java

示例3: waitForFinish

import org.gradle.process.ExecResult; //导入依赖的package包/类
public ExecResult waitForFinish() {
    lock.lock();
    try {
        while (!stateIn(ExecHandleState.SUCCEEDED, ExecHandleState.ABORTED, ExecHandleState.FAILED, ExecHandleState.DETACHED)) {
            try {
                condition.await();
            } catch (InterruptedException e) {
                //ok, wrapping up...
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
    } finally {
        lock.unlock();
    }

    executor.stop();

    return result();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:DefaultExecHandle.java

示例4: getGitTags

import org.gradle.process.ExecResult; //导入依赖的package包/类
static Integer getGitTags(final Project project) {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ExecResult res = project.exec(new Action<ExecSpec>() {
        @Override
        public void execute(final ExecSpec execSpec) {
            execSpec.commandLine("git", "tag");
            execSpec.setStandardOutput(baos);
        }
    });
    System.out.println(String.format("getGitTags:exit '%d'", res.getExitValue()));
    if (res.getExitValue() == 0) {
        final String str = baos.toString().trim();
        final int numTags = (str == null || str.length() == 0) ? 1 : str.split("\n").length;
        System.out.println(String.format("getGitTags 'num=%d'", numTags));
        return numTags;
    } else {
        return 1;
    }
}
 
开发者ID:mitchwongho,项目名称:appversion-plugin,代码行数:20,代码来源:AppVersionPlugin.java

示例5: waitForFinish

import org.gradle.process.ExecResult; //导入依赖的package包/类
public ExecResult waitForFinish() {
    lock.lock();
    try {
        while (!stateIn(ExecHandleState.SUCCEEDED, ExecHandleState.ABORTED, ExecHandleState.FAILED, ExecHandleState.DETACHED)) {
            try {
                stateChanged.await();
            } catch (InterruptedException e) {
                //ok, wrapping up...
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
    } finally {
        lock.unlock();
    }

    executor.stop();

    return result();
}
 
开发者ID:pedjak,项目名称:gradle-dockerized-test-plugin,代码行数:20,代码来源:DockerizedExecHandle.java

示例6: javaExec

import org.gradle.process.ExecResult; //导入依赖的package包/类
/** Calls javaExec() in a way which is friendly with windows classpath limitations. */
public static ExecResult javaExec(Project project, Action<JavaExecSpec> spec) throws IOException {
	if (OS.getNative().isWindows()) {
		Box.Nullable<File> classpathJarBox = Box.Nullable.ofNull();
		ExecResult execResult = project.javaexec(execSpec -> {
			// handle the user
			spec.execute(execSpec);
			// create a jar which embeds the classpath
			File classpathJar = toJarWithClasspath(execSpec.getClasspath());
			classpathJar.deleteOnExit();
			// set the classpath to be just that one jar
			execSpec.setClasspath(project.files(classpathJar));
			// save the jar so it can be deleted later
			classpathJarBox.set(classpathJar);
		});
		// delete the jar after the task has finished
		Errors.suppress().run(() -> FileMisc.forceDelete(classpathJarBox.get()));
		return execResult;
	} else {
		return project.javaexec(spec);
	}
}
 
开发者ID:diffplug,项目名称:goomph,代码行数:23,代码来源:JavaExecWinFriendly.java

示例7: waitForStop

import org.gradle.process.ExecResult; //导入依赖的package包/类
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;
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:20,代码来源:ForkingGradleHandle.java

示例8: transform

import org.gradle.process.ExecResult; //导入依赖的package包/类
private String transform(File gccBinary, List<String> args) {
    ExecAction exec = execActionFactory.newExecAction();
    exec.executable(gccBinary.getAbsolutePath());
    exec.setWorkingDir(gccBinary.getParentFile());
    exec.args(args);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    exec.setStandardOutput(baos);
    exec.setErrorOutput(new ByteArrayOutputStream());
    exec.setIgnoreExitValue(true);
    ExecResult result = exec.execute();

    int exitValue = result.getExitValue();
    if (exitValue == 0) {
        return new String(baos.toByteArray());
    } else {
        return null;
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:19,代码来源:GccVersionDeterminer.java

示例9: waitForFinish

import org.gradle.process.ExecResult; //导入依赖的package包/类
public ExecResult waitForFinish() {
    lock.lock();
    try {
        while (!stateIn(ExecHandleState.SUCCEEDED, ExecHandleState.ABORTED, ExecHandleState.FAILED, ExecHandleState.DETACHED)) {
            try {
                condition.await();
            } catch (InterruptedException e) {
                //ok, wrapping up...
            }
        }
    } finally {
        lock.unlock();
    }

    executor.stop();

    return result();
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:19,代码来源:DefaultExecHandle.java

示例10: transform

import org.gradle.process.ExecResult; //导入依赖的package包/类
public String transform(File gccBinary) {
    ExecAction exec = execActionFactory.newExecAction();
    exec.executable(gccBinary.getAbsolutePath());
    exec.setWorkingDir(gccBinary.getParentFile());
    exec.args("-dM", "-E", "-");
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    exec.setStandardOutput(baos);
    exec.setIgnoreExitValue(true);
    ExecResult result = exec.execute();

    int exitValue = result.getExitValue();
    if (exitValue == 0) {
        return new String(baos.toByteArray());
    } else {
        return null;
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:18,代码来源:GccVersionDeterminer.java

示例11: prepareMessage

import org.gradle.process.ExecResult; //导入依赖的package包/类
private String prepareMessage(String output, ExecResult result) {
        StringBuilder sb = new StringBuilder();
        sb.append(DaemonMessages.UNABLE_TO_START_DAEMON);
        //TODO SF if possible, include the exit value.
//        if (result.getExitValue()) {
//            sb.append("\nThe process has exited with value: ");
//            sb.append(result.getExecResult().getExitValue()).append(".");
//        } else {
//            sb.append("\nThe process may still be running.");
//        }
        sb.append("\nThis problem might be caused by incorrect configuration of the daemon.");
        sb.append("\nFor example, an unrecognized jvm option is used.");
        sb.append("\nPlease refer to the user guide chapter on the daemon at ");
        sb.append(documentationRegistry.getDocumentationFor("gradle_daemon"));
        sb.append("\nPlease read below process output to find out more:");
        sb.append("\n-----------------------\n");
        sb.append(output);
        return sb.toString();
    }
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:20,代码来源:DaemonGreeter.java

示例12: execute

import org.gradle.process.ExecResult; //导入依赖的package包/类
public ExecResult execute() {
    ExecHandle execHandle = build();
    ExecResult execResult = execHandle.start().waitForFinish();
    if (!isIgnoreExitValue()) {
        execResult.assertNormalExitValue();
    }
    return execResult;
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:9,代码来源:DefaultExecAction.java

示例13: getMetadataInternal

import org.gradle.process.ExecResult; //导入依赖的package包/类
private EnumMap<SysProp, String> getMetadataInternal(File jdkPath) {
    JavaExecAction exec = factory.newJavaExecAction();
    exec.executable(javaExe(jdkPath, "java"));
    File workingDir = Files.createTempDir();
    exec.setWorkingDir(workingDir);
    exec.setClasspath(new SimpleFileCollection(workingDir));
    try {
        writeProbe(workingDir);
        exec.setMain(JavaProbe.CLASSNAME);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        exec.setStandardOutput(baos);
        ByteArrayOutputStream errorOutput = new ByteArrayOutputStream();
        exec.setErrorOutput(errorOutput);
        exec.setIgnoreExitValue(true);
        ExecResult result = exec.execute();
        int exitValue = result.getExitValue();
        if (exitValue == 0) {
            return parseExecOutput(baos.toString());
        }
        return error("Command returned unexpected result code: " + exitValue + "\nError output:\n" + errorOutput);
    } catch (ExecException ex) {
        return error(ex.getMessage());
    } finally {
        try {
            FileUtils.deleteDirectory(workingDir);
        } catch (IOException e) {
            throw new GradleException("Unable to delete temp directory", e);
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:31,代码来源:JavaInstallationProbe.java

示例14: executeCompiler

import org.gradle.process.ExecResult; //导入依赖的package包/类
private void executeCompiler(ExecHandle handle) {
    handle.start();
    ExecResult result = handle.waitForFinish();
    if (result.getExitValue() != 0) {
        throw new CompilationFailedException(result.getExitValue());
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:CommandLineJavaCompiler.java

示例15: result

import org.gradle.process.ExecResult; //导入依赖的package包/类
private ExecResult result() {
    lock.lock();
    try {
        execResult.rethrowFailure();
        return execResult;
    } finally {
        lock.unlock();
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:DefaultExecHandle.java


注:本文中的org.gradle.process.ExecResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。