|
9 | 9 | import org.apache.commons.lang3.SystemUtils; |
10 | 10 | import org.apache.maven.plugin.MojoExecutionException; |
11 | 11 | import org.codehaus.plexus.util.cli.CommandLineException; |
12 | | -import org.codehaus.plexus.util.cli.Commandline; |
13 | 12 |
|
14 | 13 | public class CommandUtils { |
15 | 14 |
|
@@ -52,21 +51,18 @@ public static String execute(File workingDirectory, String executable, Object... |
52 | 51 |
|
53 | 52 | Commandline command = new Commandline(); |
54 | 53 | command.setWorkingDirectory(workingDirectory); |
| 54 | + command.setExecutable(executable); |
| 55 | + command.getShell().setQuotedArgumentsEnabled(false); |
55 | 56 |
|
56 | 57 | if (SystemUtils.IS_OS_WINDOWS) { |
57 | | - command.setExecutable(executable); |
58 | 58 | command.getShell().setShellArgs(new String[] { "/s", "/c" } ); |
59 | | - command.getShell().setQuotedArgumentsEnabled(false); |
60 | | - createArguments(command, arguments); |
61 | 59 | } else { |
62 | | - Commandline bash = new Commandline(); |
63 | | - bash.setExecutable(executable); |
64 | | - createArguments(bash, arguments); |
65 | | - command.setExecutable("/bin/bash"); |
66 | | - command.createArg().setValue("-c"); |
67 | | - command.createArg().setValue("\"" + StringUtils.join(bash.getCommandline(), " ") + "\""); |
| 60 | + command.getShell().setShellArgs(new String[] { "-c" } ); |
68 | 61 | } |
| 62 | + |
| 63 | + createArguments(command, arguments); |
69 | 64 |
|
| 65 | + Logger.info("Shell: " + command.getShell().getShellCommand()); |
70 | 66 | Logger.info("Executing command: " + StringUtils.join(command.getCommandline(), " ")); |
71 | 67 |
|
72 | 68 | Process process = command.execute(); |
|
0 commit comments