private static void readMavenVersionInformation(LineConsumer cmdOutput) throws IOException { final CommandLine commandLine = new CommandLine(getMavenExecCommand()).add("-version"); final ProcessBuilder processBuilder = new ProcessBuilder().command(commandLine.toShellCommand()).redirectErrorStream(true); final Process process = processBuilder.start(); ProcessUtil.process(process, cmdOutput, LineConsumer.DEV_NULL); } }
/** * Adds set of options in command line. * * @param options options * @return this {@code CommandLine} * @see #addPair(String, String) */ public CommandLine add(Map<String, String> options) { if (options != null && !options.isEmpty()) { for (Map.Entry<String, String> entry : options.entrySet()) { addPair(entry.getKey(), entry.getValue()); } } return this; }
@Override public String toString() { final String[] str = asArray(); final StringBuilder sb = new StringBuilder(); for (String s : str) { if (sb.length() > 1) { sb.append(' '); } sb.append(s); } return sb.toString(); } }
@Override public String[] createShellCommand(CommandLine args) { final String[] array = args.asArray(); if (array.length == 0) { throw new IllegalArgumentException("Command line is empty");
@Override public String[] createShellCommand(CommandLine args) { final String[] array = args.asArray(); if (array.length == 0) { throw new IllegalArgumentException("Command line is empty");