- // Env variables
- Map<String, String> environmentVariablesToUse = environmentVariables
- .size() > 0 ? environmentVariables : null;
+ if (redirectStreams) {
+ // Redirect standard streams
+ executor.setStreamHandler(createExecuteStreamHandler(stdOutWriter,
+ stdOutputStream, stdErrWriter, stdInStream));
+ } else {
+ // Dummy stream handler (otherwise pump is used)
+ executor.setStreamHandler(new DummyexecuteStreamHandler());
+ }
+
+ executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
+ executor.setWorkingDirectory(dir);
+
+ // Command line to use
+ final CommandLine commandLine = createCommandLine();
+ if (logCommand)
+ log.info("Execute command:\n" + commandLine
+ + "\n in working directory: \n" + dir + "\n");
+
+ // Env variables
+ Map<String, String> environmentVariablesToUse = null;
+ if (environmentVariables.size() > 0) {
+ environmentVariablesToUse = new HashMap<String, String>();
+ if (mergeEnvironmentVariables)
+ environmentVariablesToUse.putAll(System.getenv());
+ environmentVariablesToUse.putAll(environmentVariables);
+ }