IDEA-98218 (diagnostic)

This commit is contained in:
Roman Shevchenko
2013-01-15 12:35:32 +01:00
parent 53770f012e
commit 4b8fc07bc7
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package com.intellij.execution.configurations;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.process.ProcessNotCreatedException;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.UserDataHolder;
@@ -48,6 +49,8 @@ import java.util.Map;
public class GeneralCommandLine implements UserDataHolder {
public static Key<Boolean> DO_NOT_ESCAPE_QUOTES = Key.create("GeneralCommandLine.do.not.escape.quotes");
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.configurations.GeneralCommandLine");
private String myExePath = null;
private File myWorkDirectory = null;
private Map<String, String> myEnvParams = null;
@@ -187,22 +190,34 @@ public class GeneralCommandLine implements UserDataHolder {
}
public Process createProcess() throws ExecutionException {
checkWorkingDirectory();
if (LOG.isDebugEnabled()) {
LOG.debug("Executing [" + getCommandLineString() + "]");
}
final String[] commands = prepareCommands();
if (StringUtil.isEmptyOrSpaces(commands[0])) {
throw new ExecutionException(IdeBundle.message("run.configuration.error.executable.not.specified"));
String[] commands;
try {
checkWorkingDirectory();
commands = prepareCommands();
if (StringUtil.isEmptyOrSpaces(commands[0])) {
throw new ExecutionException(IdeBundle.message("run.configuration.error.executable.not.specified"));
}
}
catch (ExecutionException e) {
LOG.warn(e);
throw e;
}
try {
final ProcessBuilder builder = new ProcessBuilder(commands);
final Map<String, String> environment = builder.environment();
ProcessBuilder builder = new ProcessBuilder(commands);
Map<String, String> environment = builder.environment();
setupEnvironment(environment);
builder.directory(myWorkDirectory);
builder.redirectErrorStream(myRedirectErrorStream);
return builder.start();
}
catch (IOException e) {
LOG.warn(e);
throw new ProcessNotCreatedException(e.getMessage(), e, this);
}
}
@@ -212,8 +227,7 @@ public class GeneralCommandLine implements UserDataHolder {
return;
}
if (!myWorkDirectory.exists()) {
throw new ExecutionException(
IdeBundle.message("run.configuration.error.working.directory.does.not.exist", myWorkDirectory.getAbsolutePath()));
throw new ExecutionException(IdeBundle.message("run.configuration.error.working.directory.does.not.exist", myWorkDirectory.getAbsolutePath()));
}
if (!myWorkDirectory.isDirectory()) {
throw new ExecutionException(IdeBundle.message("run.configuration.error.working.directory.not.directory"));