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


Java ExecResult.getExitValue方法代码示例

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


在下文中一共展示了ExecResult.getExitValue方法的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: stopExecution

import org.gradle.process.ExecResult; //导入方法依赖的package包/类
public static Action<ExecResult> stopExecution() {
    return new Action<ExecResult>() {
        public void execute(ExecResult exec) {
            if (exec.getExitValue() != 0) {
                LOG.info("External process returned exit code: {}. Stopping the execution of the task.");
                //Cleanly stop executing the task, without making the task failed.
                throw new StopExecutionException();
            }
        }
    };
}
 
开发者ID:mockito,项目名称:shipkit,代码行数:12,代码来源:ExecCommandFactory.java

示例10: mapJarFile

import org.gradle.process.ExecResult; //导入方法依赖的package包/类
public void mapJarFile(File input, File output, ModGradleExtension extension) {
    ExecResult result = getProject().javaexec(new Closure<JavaExecSpec>(this) {
        public JavaExecSpec call() {
            JavaExecSpec exec = (JavaExecSpec) getDelegate();
            exec.args(
                    Constants.SPECIALSOURCE_JAR.getAbsolutePath(),
                    "map",
                    "-i",
                    input.getAbsolutePath(),
                    "-m",
                    Constants.MAPPING_SRG.get(extension).getAbsolutePath(),
                    "-o",
                    output.getAbsolutePath()
            );
            exec.setMain("-jar");
            exec.setWorkingDir(Constants.CACHE_FILES);
            exec.classpath(Constants.getClassPath());
            //exec.setStandardOutput(System.out); // TODO: store the logs?
            exec.setMaxHeapSize("512M");

            return exec;
        }

        public JavaExecSpec call(Object obj) {
            return call();
        }
    });
    int exitValue = result.getExitValue();
    if (exitValue != 0) {
        this.getLogger().error(":SpecialSource exit value: " + exitValue);
        throw new RuntimeException("SpecialSource failed to decompile");
    }
}
 
开发者ID:OpenModLoader,项目名称:ModGradle,代码行数:34,代码来源:MapJarsTask.java

示例11: getGitTagDescriptions

import org.gradle.process.ExecResult; //导入方法依赖的package包/类
static String getGitTagDescriptions(final Project project) {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ExecResult res = project.exec(new Action<ExecSpec>() {
        @Override
        public void execute(final ExecSpec execSpec) {
            execSpec.setWorkingDir(project.getProjectDir());
            execSpec.commandLine("git", "describe", "--tags", "--long");
            execSpec.setStandardOutput(baos);
        }
    });
    System.out.println(String.format("getGitTagDescriptions:exit '%d'", res.getExitValue()));
    if (res.getExitValue() == 0) {
        final String str = baos.toString().trim();
        if (str == null || str.length() == 0) {
            return "1.0.0";
        } else {
            final String[] arr = str.split("-");
            // [0] - fullVersionTag
            // [1] - versionBuild
            // [2] - gitSHA
            System.out.println(String.format("getGitTagDescriptions '%s' {fullVersion=%s}", str, arr[0]));
            return arr[0];
        }
    } else {
        return "1.0.0";
    }
}
 
开发者ID:mitchwongho,项目名称:appversion-plugin,代码行数:28,代码来源:AppVersionPlugin.java

示例12: invokeCompiler

import org.gradle.process.ExecResult; //导入方法依赖的package包/类
@Override
public void invokeCompiler(ProgramArguments arguments) throws Exception {
    ExecResult execResult = project.javaexec(executor(arguments));

    if (execResult.getExitValue() != 0) {
        throw new IllegalStateException("JJTree failed with error code: [" + execResult.getExitValue() + "]");
    }
}
 
开发者ID:johnmartel,项目名称:javaccPlugin,代码行数:9,代码来源:AbstractProgramInvoker.java

示例13: ensureSucceeded

import org.gradle.process.ExecResult; //导入方法依赖的package包/类
static void ensureSucceeded(ExecResult result, String prefix) {
    if (result.getExitValue() != 0) {
        throw new GradleException("External process failed with exit code " + result.getExitValue() + "\n" +
                "Please inspect the command output prefixed with '" + prefix.trim() + "' the build log.");
    }
}
 
开发者ID:mockito,项目名称:shipkit,代码行数:7,代码来源:ExecCommandFactory.java

示例14: decompile

import org.gradle.process.ExecResult; //导入方法依赖的package包/类
@TaskAction
public void decompile() {
    try {
        ModGradleExtension extension = this.getProject().getExtensions().getByType(ModGradleExtension.class);
        if (!Constants.MINECRAFT_FERN_OUTPUT_JAR.get(extension).exists()) {
            this.getLogger().lifecycle(":decompiling Minecraft");

            // TODO: Separate task
            ExecResult result = getProject().javaexec(new Closure<JavaExecSpec>(this) {
                public JavaExecSpec call() {
                    JavaExecSpec exec = (JavaExecSpec) getDelegate();
                    Constants.MINECRAFT_FERN_OUTPUT.mkdir();
                    exec.args(
                            Constants.FERNFLOWER_JAR.getAbsolutePath(),
                            "-dgs=1",
                            "-hdc=0",
                            "-asc=1",
                            "-udv=0",
                            "-din=1",
                            "-rbr=0",
                            "-rsy=1",
                            "-ind=    ",
                            //"-udv=1",
                            "-log=ERROR",
                            Constants.MINECRAFT_MERGED.get(extension).getAbsolutePath(),
                            Constants.MINECRAFT_FERN_OUTPUT.getAbsolutePath()
                    );
                    exec.setMain("-jar");
                    exec.setWorkingDir(Constants.CACHE_FILES);
                    exec.classpath(Constants.getClassPath());
                    //exec.setStandardOutput(System.out); // TODO: store the logs?
                    exec.setMaxHeapSize("512M");

                    return exec;
                }

                public JavaExecSpec call(Object obj) {
                    return call();
                }
            });

            int exitValue = result.getExitValue();
            if (exitValue != 0) {
                this.getLogger().error(":FernFlower exit value: " + exitValue);
                throw new RuntimeException("FernFlower failed to decompile");
            }
        }

        if (Constants.MINECRAFT_SRC_PATCHED.exists()) {
            FileUtils.deleteDirectory(Constants.MINECRAFT_SRC_PATCHED);
        }

        if (Constants.MINECRAFT_SRC_DECOMP.exists()) {
            FileUtils.deleteDirectory(Constants.MINECRAFT_SRC_DECOMP);
        }

        ZipUtil.unpack(Constants.MINECRAFT_FERN_OUTPUT_JAR.get(extension), Constants.MINECRAFT_SRC_DECOMP);
        FileUtils.copyDirectory(Constants.MINECRAFT_SRC_DECOMP, Constants.MINECRAFT_SRC_PATCHED);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:OpenModLoader,项目名称:ModGradle,代码行数:63,代码来源:DecompileTask.java

示例15: runWsimport

import org.gradle.process.ExecResult; //导入方法依赖的package包/类
/**
 * Run wsimport on a WSDL file
 *
 * @param baseDir Base directory
 * @param wsdlFile WSDL file to compile
 */
protected void runWsimport(Path baseDir, Path wsdlFile) {
    JavaExecAction action = getActionFactory().newJavaExecAction();
    String packageName = Optional.ofNullable(wsdlFile.getParent()).map(p -> PACKAGE_JOINER.join(p)).orElse(null);

    Multimap<String, Object> options = Multimaps.newListMultimap(new HashMap<>(), () -> new ArrayList<>());

    if (packageName != null) {
        options.put("p", packageName);
    }

    options.put("wsdllocation", wsdlFile.getFileName().toString());
    options.put("s", getDestinationDir());
    options.put("extension", true);
    options.put("Xnocompile", true);
    options.put("B-classpath", getProject().getConfigurations().getAt("xjc").getAsPath());

    for (String extension : getXjcExtensions()) {
        options.put("B-X" + extension, true);
    }

    if (getProject().getLogger().isDebugEnabled()) {
        options.put("Xdebug", true);
    }
    else {
        options.put("quiet", true);
    }

    for (File bindingFile : Objects.requireNonNull(getBindings()).getFiles()) {
        if (bindingFile.isFile()) {
            options.put("b", bindingFile);
        }
    }

    List<String> arguments = createArguments(options);
    arguments.add(wsdlFile.toString());

    getLogger().debug("Running wsimport with arguments {}", Joiner.on(' ').join(arguments));

    action.setArgs(arguments);
    action.setClasspath(getProject().getConfigurations().getAt("jaxws"));
    action.setMain("com.sun.tools.ws.WsImport");
    action.setWorkingDir(baseDir.toFile());

    ExecResult result = action.execute();

    if (result.getExitValue() != 0) {
        throw new GradleException("Error running wsimport");
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-wsimport-plugin,代码行数:56,代码来源:WsimportTask.java


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