public CommandExecutorResult executeCommand()

in artifactregistry-gradle-plugin/src/main/java/com/google/cloud/artifactregistry/gradle/plugin/ProviderFactoryCommandExecutor.java [22:46]


    public CommandExecutorResult executeCommand(String command, String... args) throws IOException {
        List<String> argList = new ArrayList<>();
        argList.add(command);
        argList.addAll(Arrays.asList(args));

        ExecOutput execOutput;
        try {
            execOutput = providerFactory.exec(execSpec -> {
                execSpec.commandLine(argList);
            });
        } catch (ExecException e) {
            // Downstream cannot handle Gradle specific exceptions
            throw new IOException(e);
        }

        int exitCode = execOutput.getResult().get().getExitValue();
        String stdOut = execOutput.getStandardOutput().getAsText().get();
        String stdErr = execOutput.getStandardError().getAsText().get();

        return new CommandExecutorResult(
                exitCode,
                stdOut,
                stdErr
        );
    }