use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-elixir by KronicDeth.
the class MixBuilder method runMix.
private static void runMix(@NotNull String elixirPath, @NotNull String mixPath, @Nullable String contentRootPath, boolean addDebugInfo, @NotNull CompileContext context) throws ProjectBuildException {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.withWorkDirectory(contentRootPath);
commandLine.setExePath(elixirPath);
commandLine.addParameter(mixPath);
commandLine.addParameter("compile");
if (!addDebugInfo) {
commandLine.addParameter("--no-debug-info");
}
Process process;
try {
process = commandLine.createProcess();
} catch (ExecutionException e) {
throw new ProjectBuildException("Failed to run mix.", e);
}
BaseOSProcessHandler handler = new BaseOSProcessHandler(process, commandLine.getCommandLineString(), Charset.defaultCharset());
ProcessAdapter adapter = new ElixirCompilerProcessAdapter(context, NAME, commandLine.getWorkDirectory().getPath());
handler.addProcessListener(adapter);
handler.startNotify();
handler.waitFor();
}
use of com.intellij.execution.configurations.GeneralCommandLine in project Intellij-Plugin by getgauge.
the class GaugeCommandLine method getInstance.
public static GeneralCommandLine getInstance(Module module, Project project) {
GeneralCommandLine commandLine = new GeneralCommandLine();
try {
GaugeSettingsModel settings = GaugeUtil.getGaugeSettings();
commandLine.setExePath(settings.getGaugePath());
Map<String, String> environment = commandLine.getEnvironment();
environment.put(Constants.GAUGE_HOME, settings.getHomePath());
} catch (GaugeNotFoundException e) {
commandLine.setExePath(Constants.GAUGE);
} finally {
commandLine.setWorkDirectory(project.getBasePath());
if (module != null)
commandLine.setWorkDirectory(GaugeUtil.moduleDir(module));
return commandLine;
}
}
use of com.intellij.execution.configurations.GeneralCommandLine in project teamcity-powershell by JetBrains.
the class PowerShellServiceUnix method enableExecution.
private static void enableExecution(@NotNull final File filePath) {
final GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath("chmod");
commandLine.addParameter("+x");
commandLine.addParameter(filePath.getName());
commandLine.setWorkDirectory(filePath.getParent());
final ExecResult execResult = SimpleCommandLineProcessRunner.runCommand(commandLine, null);
if (execResult.getExitCode() != 0) {
LOG.warn("Failed to set executable attribute for " + filePath + ": chmod +x exit code is " + execResult.getExitCode());
}
}
use of com.intellij.execution.configurations.GeneralCommandLine in project flutter-intellij by flutter.
the class AndroidEmulator method startEmulator.
public void startEmulator() {
final VirtualFile emulator = androidSdk.getEmulatorToolExecutable();
if (emulator == null) {
FlutterMessages.showError("Error Opening Emulator", "Unable to locate the emulator tool in the Android SDK.");
return;
}
final String emulatorPath = emulator.getCanonicalPath();
assert (emulatorPath != null);
final GeneralCommandLine cmd = new GeneralCommandLine().withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE).withWorkDirectory(androidSdk.getHome().getCanonicalPath()).withExePath(emulatorPath).withParameters("-avd", this.id);
try {
final StringBuilder stdout = new StringBuilder();
final OSProcessHandler process = new OSProcessHandler(cmd);
process.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
if (outputType == ProcessOutputTypes.STDERR || outputType == ProcessOutputTypes.STDOUT) {
stdout.append(event.getText());
}
}
public void processTerminated(ProcessEvent event) {
final int exitCode = event.getExitCode();
if (exitCode != 0) {
final String message = stdout.length() == 0 ? "Android emulator terminated with exit code " + exitCode : stdout.toString().trim();
FlutterMessages.showError("Error Opening Emulator", message);
}
}
});
process.startNotify();
} catch (ExecutionException | RuntimeException e) {
FlutterMessages.showError("Error Opening Emulator", e.toString());
}
}
use of com.intellij.execution.configurations.GeneralCommandLine in project flutter-intellij by flutter.
the class AndroidSdk method getEmulators.
@NotNull
public List<AndroidEmulator> getEmulators() {
// Execute $ANDROID_HOME/tools/emulator -list-avds and parse the results.
final VirtualFile emulator = getEmulatorToolExecutable();
if (emulator == null) {
return Collections.emptyList();
}
final String emulatorPath = emulator.getCanonicalPath();
assert (emulatorPath != null);
final GeneralCommandLine cmd = new GeneralCommandLine().withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE).withWorkDirectory(home.getCanonicalPath()).withExePath(emulatorPath).withParameters("-list-avds");
try {
final StringBuilder stringBuilder = new StringBuilder();
final OSProcessHandler process = new OSProcessHandler(cmd);
process.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
if (outputType == ProcessOutputTypes.STDOUT) {
stringBuilder.append(event.getText());
}
}
});
process.startNotify();
// We wait a maximum of 2000ms.
if (!process.waitFor(2000)) {
return Collections.emptyList();
}
final Integer exitCode = process.getExitCode();
if (exitCode == null || process.getExitCode() != 0) {
return Collections.emptyList();
}
// 'emulator -list-avds' results are in the form "foo\nbar\nbaz\n".
final List<AndroidEmulator> emulators = new ArrayList<>();
for (String str : stringBuilder.toString().split("\n")) {
str = str.trim();
if (str.isEmpty()) {
continue;
}
emulators.add(new AndroidEmulator(this, str));
}
return emulators;
} catch (ExecutionException | RuntimeException e) {
LOG.warn("Error listing android emulators", e);
return Collections.emptyList();
}
}
Aggregations