public Process execute()

in src/main/java/org/apache/maven/shared/utils/cli/Commandline.java [371:397]


    public Process execute() throws CommandLineException {
        Process process;

        String[] environment = getEnvironmentVariables();

        File workingDir = shell.getWorkingDirectory();

        try {
            if (workingDir == null) {
                process = Runtime.getRuntime().exec(getShellCommandline(), environment);
            } else {
                if (!workingDir.exists()) {
                    throw new CommandLineException(
                            "Working directory \"" + workingDir.getPath() + "\" does not exist!");
                } else if (!workingDir.isDirectory()) {
                    throw new CommandLineException(
                            "Path \"" + workingDir.getPath() + "\" does not specify a directory.");
                }

                process = Runtime.getRuntime().exec(getShellCommandline(), environment, workingDir);
            }
        } catch (IOException ex) {
            throw new CommandLineException("Error while executing process.", ex);
        }

        return process;
    }