@Override public int getExitValue() { return result.getExitValue(); }
@Override public int getExitValue() { return result.getExitValue(); }
@Override public int getExitValue() { return execResult.getExitValue(); }
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."); } }
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."); } }
@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() + "]"); } }
PexExecOutputParser(PexExecSpecAction pexExecSpecAction, ExecResult execResult) { this(pexExecSpecAction.getOutputStream().toString().trim(), execResult.getExitValue()); }
PexExecOutputParser(PexExecSpecAction pexExecSpecAction, ExecResult execResult) { this(pexExecSpecAction.getOutputStream().toString().trim(), execResult.getExitValue()); }
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(); } } };
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(); } } };
public static PythonVersion parsePythonVersion(final Project project, final File pythonInterpreter) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult execResult = project.exec(execSpec -> { execSpec.setExecutable(pythonInterpreter.getAbsolutePath()); execSpec.setArgs(Collections.singletonList("--version")); execSpec.setStandardOutput(outputStream); execSpec.setErrorOutput(outputStream); execSpec.setIgnoreExitValue(true); }); String output = outputStream.toString(); if (execResult.getExitValue() != 0) { throw new GradleException(output); } String versionString = output.trim().split(" ")[1]; return new PythonVersion(versionString); } }
private boolean runSingleCollection(File collection) { nodeExecRunner.setArguments(asList( getWrapperAbsolutePath().toString(), getNewmanConfiguration(collection))); try { return nodeExecRunner.execute().getExitValue() == 0; } catch (ExecException ignored) { return false; } }
@TaskAction void generate() { ExecResult result = getProject().javaexec(new Action<JavaExecSpec>() { @Override public void execute(JavaExecSpec spec) { getLogger().lifecycle(CONFIG_MESSAGE, getFormat(), formatPath(getBaseDir()), formatPath(getDestDir())); getLogger().info("Using main class {}", getMainClass()); Configuration configuration = getProject().getConfigurations().getAt(CONFIGURATION_NAME); String toolPath = configuration.getAsPath(); spec.setIgnoreExitValue(true); spec.setClasspath(createToolClasspath(configuration)); spec.setMain(getMainClass()); spec.args(getFormat(), getBaseDir().getAbsolutePath(), getDestDir().getAbsolutePath(), toolPath); } private FileCollection createToolClasspath(Configuration teamcityClasspath) { File toolJar = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath()); List<Object> classPath = new ArrayList<>(); classPath.add(toolJar); classPath.add(teamcityClasspath); return getProject().files(classPath); } }); if (result.getExitValue() != 0) { String message = "Process generating TeamCity configurations failed. See the report at: "; String dslReportUrl = asClickableFileUrl(new File(getDestDir(), DSL_EXCEPTION_FILENAME)); throw new GradleException(message + dslReportUrl); } }
public static PythonVersion parsePythonVersion(final Project project, final File pythonInterpreter) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult execResult = project.exec(execSpec -> { execSpec.setExecutable(pythonInterpreter.getAbsolutePath()); execSpec.setArgs(Collections.singletonList("--version")); execSpec.setStandardOutput(outputStream); execSpec.setErrorOutput(outputStream); execSpec.setIgnoreExitValue(true); }); String output = outputStream.toString(); if (execResult.getExitValue() != 0) { throw new GradleException(output); } String versionString = output.trim().split(" ")[1]; return new PythonVersion(versionString); } }
@Override public boolean isSatisfiedBy(Task task) { try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { ExecAction execAction = SetupCondaBuild.this.getExecActionFactory().newExecAction(); execAction.executable(condaExec); execAction.args("build", "-V"); // will error if build is not installed, otherwise just print stuff execAction.setIgnoreExitValue(true); execAction.setErrorOutput(os); String expectedOutput = "conda-build " + miniconda.getCondaBuildVersion(); ExecResult result = execAction.execute(); return result.getExitValue() == 0 && (miniconda.getCondaBuildVersion() == null || os.toString("UTF-8").trim().equals(expectedOutput)); } catch (IOException e) { return false; } } });
@Override void doPipOperation(PackageInfo packageInfo, List<String> extraArgs) { throwIfPythonVersionIsNotSupported(packageInfo); if (!packageSettings.requiresSourceBuild(packageInfo) && doesWheelExist(packageInfo)) { return; } if (PythonHelpers.isPlainOrVerbose(project)) { logger.lifecycle("Building {} wheel", packageInfo.toShortHand()); } Map<String, String> mergedEnv = environmentMerger.mergeEnvironments( Arrays.asList(baseEnvironment, packageSettings.getEnvironment(packageInfo))); List<String> commandLine = makeCommandLine(packageInfo, extraArgs); OutputStream stream = new ByteArrayOutputStream(); ExecResult installResult = execCommand(mergedEnv, commandLine, stream); if (installResult.getExitValue() != 0) { logger.error("Error installing package using `{}`", commandLine); logger.error(stream.toString().trim()); throw PipExecutionException.failedWheel(packageInfo, stream.toString().trim()); } else { logger.info(stream.toString().trim()); } }
@Override void doPipOperation(PackageInfo packageInfo, List<String> extraArgs) { throwIfPythonVersionIsNotSupported(packageInfo); if (!packageSettings.requiresSourceBuild(packageInfo) && doesWheelExist(packageInfo)) { return; } if (PythonHelpers.isPlainOrVerbose(project)) { logger.lifecycle("Building {} wheel", packageInfo.toShortHand()); } Map<String, String> mergedEnv = environmentMerger.mergeEnvironments( Arrays.asList(baseEnvironment, packageSettings.getEnvironment(packageInfo))); List<String> commandLine = makeCommandLine(packageInfo, extraArgs); OutputStream stream = new ByteArrayOutputStream(); ExecResult installResult = execCommand(mergedEnv, commandLine, stream); if (installResult.getExitValue() != 0) { logger.error("Error installing package using `{}`", commandLine); logger.error(stream.toString().trim()); throw PipExecutionException.failedWheel(packageInfo, stream.toString().trim()); } else { logger.info(stream.toString().trim()); } }
private void execute(Action<JavaExecSpec> execSpecAction, TestResultProcessor resultProcessor) { Object rootTestId = "eta-test-root"; Object testId = "eta-test"; resultProcessor.started (new DefaultTestSuiteDescriptor(rootTestId, "Eta Root"), new TestStartEvent(System.currentTimeMillis())); resultProcessor.started (new DefaultTestDescriptor(testId, "eta.main", "Default Eta Test"), new TestStartEvent(System.currentTimeMillis())); ExecResult execResult = project.javaexec(execSpec -> { execSpecAction.execute(execSpec); execSpec.setMain("eta.main"); }); ResultType resultType = (execResult.getExitValue() == 0)? ResultType.SUCCESS : ResultType.FAILURE; resultProcessor.completed (testId, new TestCompleteEvent(System.currentTimeMillis(), resultType)); resultProcessor.completed (rootTestId, new TestCompleteEvent(System.currentTimeMillis(), resultType)); } }
if (installResult.getExitValue() != 0) {
@Override public WorkResult execute(JavaCompileSpec javaCompileSpec) { LOGGER.info("Compiling sources using eclipse compiler for java ["+this.ecjArtifact+"]"); final List<String> remainingArguments = new JavaCompilerArgumentsBuilder(javaCompileSpec).includeSourceFiles(true).build(); ExecResult result = project.javaexec(exec -> { exec.setWorkingDir(javaCompileSpec.getWorkingDir()); exec.setClasspath(compilerConfiguration); exec.setMain("org.eclipse.jdt.internal.compiler.batch.Main"); exec.args(shortenArgs(javaCompileSpec.getTempDir(), remainingArguments)); }); if (result.getExitValue() != 0) { throw new CompilationFailedException(result.getExitValue()); } return () -> true; }