throws IOException {
if (dir != null && !dir.exists()) {
throw new BuildException(dir + " doesn't exist.");
}
CommandLauncher vmLauncher = CommandLauncher.getVMLauncher(project);
CommandLauncher launcher = (useVM && vmLauncher != null)
? vmLauncher : CommandLauncher.getShellLauncher(project);
return launcher.exec(project, command, env, dir);
}