use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-elixir by KronicDeth.
the class MixProjectRootStep method getMixPath.
/**
* private methods
* */
@NotNull
private static String getMixPath(@Nullable String directory) {
if (directory != null) {
File mix = new File(directory, "mix");
if (mix.exists() && mix.canExecute()) {
return mix.getPath();
}
}
String output = "";
GeneralCommandLine generalCommandLine = null;
if (SystemInfo.isWindows) {
generalCommandLine = new GeneralCommandLine("where");
generalCommandLine.addParameter("mix.bat");
} else if (SystemInfo.isMac || SystemInfo.isLinux || SystemInfo.isUnix) {
generalCommandLine = new GeneralCommandLine("which");
generalCommandLine.addParameter("mix");
}
if (generalCommandLine != null) {
try {
output = ScriptRunnerUtil.getProcessOutput(generalCommandLine);
} catch (Exception ignored) {
LOG.warn(ignored);
}
}
return output.trim();
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-elixir by KronicDeth.
the class MixProjectRootStep method fetchDependencies.
private static void fetchDependencies(@NotNull final VirtualFile projectRoot, @NotNull final String mixPath) {
final Project project = ProjectImportBuilder.getCurrentProject();
String sdkPath = project != null ? ElixirSdkType.getSdkPath(project) : null;
final String elixirPath = sdkPath != null ? JpsElixirSdkType.getScriptInterpreterExecutable(sdkPath).getAbsolutePath() : JpsElixirSdkType.getExecutableFileName(JpsElixirSdkType.SCRIPT_INTERPRETER);
ProgressManager.getInstance().run(new Task.Modal(project, "Fetching dependencies", true) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
indicator.setIndeterminate(true);
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.withWorkDirectory(projectRoot.getCanonicalPath());
commandLine.setExePath(elixirPath);
commandLine.addParameter(mixPath);
commandLine.addParameter("deps.get");
try {
OSProcessHandler handler = new OSProcessHandler(commandLine.createProcess(), commandLine.getPreparedCommandLine(Platform.current()));
handler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
String text = event.getText();
indicator.setText2(text);
}
});
ProcessTerminatedListener.attach(handler);
handler.startNotify();
handler.waitFor();
indicator.setText2("Refreshing");
} catch (ExecutionException e) {
LOG.warn(e);
}
}
});
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-elixir by KronicDeth.
the class ElixirSystemUtil method getProcessOutput.
@NotNull
public static ProcessOutput getProcessOutput(int timeout, @Nullable String workDir, @NotNull String exePath, @NotNull String... arguments) throws ExecutionException {
if (workDir == null || !new File(workDir).isDirectory() || !new File(exePath).canExecute()) {
return new ProcessOutput();
}
GeneralCommandLine cmd = new GeneralCommandLine();
cmd.withWorkDirectory(workDir);
cmd.setExePath(exePath);
cmd.addParameters(arguments);
return execute(cmd, timeout);
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-community by JetBrains.
the class GroovyConsole method createProcessHandler.
private static ProcessHandler createProcessHandler(Module module) {
try {
final JavaParameters javaParameters = createJavaParameters(module);
final GeneralCommandLine commandLine = javaParameters.toCommandLine();
return new OSProcessHandler(commandLine) {
@Override
public boolean isSilentlyDestroyOnClose() {
return true;
}
};
} catch (ExecutionException e) {
LOG.warn(e);
return null;
}
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-community by JetBrains.
the class SshTunnelRuntimeModule method buildTunnelCommandLine.
@NotNull
private GeneralCommandLine buildTunnelCommandLine(@NotNull String sshPath) {
GeneralCommandLine result = new GeneralCommandLine(sshPath);
boolean isPuttyLinkClient = StringUtil.endsWithIgnoreCase(FileUtil.getNameWithoutExtension(sshPath), "plink");
SvnConfigurationState state = getState();
// quiet mode
if (!isPuttyLinkClient) {
result.addParameter("-q");
}
result.addParameters(isPuttyLinkClient ? "-P" : "-p", String.valueOf(state.sshPort));
if (!StringUtil.isEmpty(state.sshUserName)) {
result.addParameters("-l", state.sshUserName);
}
if (SvnConfiguration.SshConnectionType.PRIVATE_KEY.equals(state.sshConnectionType) && !StringUtil.isEmpty(state.sshPrivateKeyPath)) {
result.addParameters("-i", FileUtil.toSystemIndependentName(state.sshPrivateKeyPath));
}
return result;
}
Aggregations