* @author traff
*/
public class RunnerMediator {
- public static final Logger LOG = Logger.getInstance("#com.intellij.execution.process.RunnerMediator");
+ private static final Logger LOG = Logger.getInstance("#com.intellij.execution.process.RunnerMediator");
private static final char IAC = (char)5;
private static final char BRK = (char)3;
private static final char C = (char)5;
private static final String STANDARD_RUNNERW = "runnerw.exe";
+ private static final String IDEA_RUNNERW = "IDEA_RUNNERW";
/**
* Creates default runner mediator
@Nullable
private static String getRunnerPath() {
- if (SystemInfo.isWindows) {
- final String path = System.getenv("IDEA_RUNNERW");
- if (path != null && new File(path).exists()) {
+ if (!SystemInfo.isWindows) {
+ throw new IllegalStateException("There is no need of runner under unix based OS");
+ }
+ final String path = System.getenv(IDEA_RUNNERW);
+ if (path != null) {
+ if (new File(path).exists()) {
return path;
}
- File runnerw = new File(PathManager.getBinPath(), STANDARD_RUNNERW);
- if (runnerw.exists()) {
- return runnerw.getPath();
- }
- return null;
+ LOG.warn("Cannot locate " + STANDARD_RUNNERW + " by " + IDEA_RUNNERW + " environment variable (" + path + ")");
}
- else {
- throw new IllegalStateException("There is no need of runner under unix based OS");
+ File runnerw = new File(PathManager.getBinPath(), STANDARD_RUNNERW);
+ if (runnerw.exists()) {
+ return runnerw.getPath();
}
+ LOG.warn("Cannot locate " + STANDARD_RUNNERW + " by default path (" + runnerw.getAbsolutePath() + ")");
+ return null;
}
- static void injectRunnerCommand(@NotNull GeneralCommandLine commandLine) {
+ static boolean injectRunnerCommand(@NotNull GeneralCommandLine commandLine) {
final String path = getRunnerPath();
if (path != null) {
commandLine.getParametersList().addAt(0, commandLine.getExePath());
commandLine.setExePath(path);
+ return true;
}
+ return false;
}
/**
}
@NotNull
- public static RunnerWinProcess create(@NotNull GeneralCommandLine commandLine) throws ExecutionException {
+ public static Process create(@NotNull GeneralCommandLine commandLine) throws ExecutionException {
if (!SystemInfo.isWindows) {
throw new RuntimeException(RunnerWinProcess.class.getSimpleName() + " works on Windows only!");
}
- RunnerMediator.injectRunnerCommand(commandLine);
+ boolean success = RunnerMediator.injectRunnerCommand(commandLine);
Process process = commandLine.createProcess();
- return new RunnerWinProcess(process);
+ return success ? new RunnerWinProcess(process) : process;
}
-
}