in src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkToolchainExecutor.java [148:195]
private int executeCommand(Commandline cmd) throws MojoExecutionException {
if (getLog().isDebugEnabled()) {
// no quoted arguments ???
getLog().debug(CommandLineUtils.toString(cmd.getCommandline()).replaceAll("'", ""));
}
CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
try {
int exitCode = CommandLineUtils.executeCommandLine(cmd, out, err);
String output = StringUtils.isEmpty(out.getOutput())
? null
: '\n' + out.getOutput().trim();
if (exitCode != 0) {
if (output != null && !output.isEmpty()) {
// Reconsider to use WARN / ERROR ?
// getLog().error( output );
for (String outputLine : output.split("\n")) {
getLog().error(outputLine);
}
}
StringBuilder msg = new StringBuilder("\nExit code: ");
msg.append(exitCode);
if (StringUtils.isNotEmpty(err.getOutput())) {
msg.append(" - ").append(err.getOutput());
}
msg.append('\n');
msg.append("Command line was: ").append(cmd).append('\n').append('\n');
throw new MojoExecutionException(msg.toString());
}
if (output != null && !output.isEmpty()) {
// getLog().info( output );
for (String outputLine : output.split("\n")) {
getLog().info(outputLine);
}
}
return exitCode;
} catch (CommandLineException e) {
throw new MojoExecutionException("Unable to execute jlink command: " + e.getMessage(), e);
}
}