use of com.intellij.execution.configurations.GeneralCommandLine in project intellij by bazelbuild.
the class BlazeGDBDriverConfigurationBase method createDriverCommandLine.
@Override
public GeneralCommandLine createDriverCommandLine(DebuggerDriver driver, Installer installer) throws ExecutionException {
GeneralCommandLine commandLine = super.createDriverCommandLine(driver, installer);
modifyCommandLine(commandLine);
return commandLine;
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij by bazelbuild.
the class BlazeGDBDriverConfigurationBase method createDriverCommandLine.
@Override
public GeneralCommandLine createDriverCommandLine(DebuggerDriver driver) throws ExecutionException {
GeneralCommandLine commandLine = super.createDriverCommandLine(driver);
modifyCommandLine(commandLine);
return commandLine;
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij by bazelbuild.
the class AaptUtil method getAaptBadging.
/**
* Uses aapt to dump badging information for the given apk, and extracts information from the
* output matching the given pattern.
*/
@Nullable
private static MatchResult getAaptBadging(Project project, File apk, Pattern pattern) throws AaptUtilException {
if (!apk.exists()) {
throw new AaptUtilException("apk file does not exist: " + apk);
}
AndroidPlatform androidPlatform = SdkUtil.getAndroidPlatform(project);
if (androidPlatform == null) {
throw new AaptUtilException("Could not find Android platform sdk for project " + project.getName());
}
BuildToolInfo toolInfo = androidPlatform.getSdkData().getLatestBuildTool();
if (toolInfo == null) {
throw new AaptUtilException("Could not find Android sdk build-tools for project " + project.getName());
}
String aapt = toolInfo.getPath(PathId.AAPT);
GeneralCommandLine commandLine = new GeneralCommandLine(aapt, "dump", "badging", apk.getAbsolutePath());
OSProcessHandler handler;
try {
handler = new OSProcessHandler(commandLine);
} catch (ExecutionException e) {
throw new AaptUtilException("Could not execute aapt to extract apk information.", e);
}
// The wrapped stream is closed by the process handler.
BufferedReader reader = new BufferedReader(new InputStreamReader(handler.getProcess().getInputStream()));
try {
String line;
while ((line = reader.readLine()) != null) {
Matcher matcher = pattern.matcher(line);
if (matcher.find()) {
return matcher.toMatchResult();
}
}
} catch (IOException e) {
throw new AaptUtilException("Could not read aapt output.", e);
}
return null;
}
use of com.intellij.execution.configurations.GeneralCommandLine in project ballerina by ballerina-lang.
the class BallerinaRunningState method startProcess.
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
BallerinaExecutor executor = patchExecutor(createCommonExecutor());
// We only need to set parameters.
GeneralCommandLine commandLine = executor.withParameterString(myConfiguration.getParams()).createCommandLine();
KillableColoredProcessHandler handler = new KillableColoredProcessHandler(commandLine, true);
ProcessTerminatedListener.attach(handler);
return handler;
}
use of com.intellij.execution.configurations.GeneralCommandLine in project ballerina by ballerina-lang.
the class BallerinaExecutor method execute.
public boolean execute() {
Logger.getInstance(getClass()).assertTrue(!ApplicationManager.getApplication().isDispatchThread(), "It's bad idea to run external tool on EDT");
Logger.getInstance(getClass()).assertTrue(myProcessHandler == null, "Process has already run with this executor instance");
Ref<Boolean> result = Ref.create(false);
GeneralCommandLine commandLine = null;
try {
commandLine = createCommandLine();
GeneralCommandLine finalCommandLine = commandLine;
myProcessHandler = new KillableColoredProcessHandler(finalCommandLine, true) {
@Override
public void startNotify() {
if (myShowBallerinaEnvVariables) {
BallerinaRunUtil.printBallerinaEnvVariables(finalCommandLine, this);
}
super.startNotify();
}
};
BallerinaHistoryProcessListener historyProcessListener = new BallerinaHistoryProcessListener();
myProcessHandler.addProcessListener(historyProcessListener);
for (ProcessListener listener : myProcessListeners) {
myProcessHandler.addProcessListener(listener);
}
CapturingProcessAdapter processAdapter = new CapturingProcessAdapter(myProcessOutput) {
@Override
public void processTerminated(@NotNull ProcessEvent event) {
super.processTerminated(event);
boolean success = event.getExitCode() == 0 && myProcessOutput.getStderr().isEmpty();
boolean nothingToShow = myProcessOutput.getStdout().isEmpty() && myProcessOutput.getStderr().isEmpty();
boolean cancelledByUser = (event.getExitCode() == -1 || event.getExitCode() == 2) && nothingToShow;
result.set(success);
if (success) {
if (myShowNotificationsOnSuccess) {
showNotification("Finished successfully", NotificationType.INFORMATION);
}
} else if (cancelledByUser) {
if (myShowNotificationsOnError) {
showNotification("Interrupted", NotificationType.WARNING);
}
} else if (myShowOutputOnError) {
ApplicationManager.getApplication().invokeLater(() -> showOutput(myProcessHandler, historyProcessListener));
}
}
};
myProcessHandler.addProcessListener(processAdapter);
myProcessHandler.startNotify();
ExecutionModes.SameThreadMode sameThreadMode = new ExecutionModes.SameThreadMode(getPresentableName());
ExecutionHelper.executeExternalProcess(myProject, myProcessHandler, sameThreadMode, commandLine);
LOGGER.debug("Finished `" + getPresentableName() + "` with result: " + result.get());
return result.get();
} catch (ExecutionException e) {
if (myShowOutputOnError) {
ExecutionHelper.showErrors(myProject, Collections.singletonList(e), getPresentableName(), null);
}
if (myShowNotificationsOnError) {
showNotification(StringUtil.notNullize(e.getMessage(), "Unknown error, see logs for details"), NotificationType.ERROR);
}
String commandLineInfo = commandLine != null ? commandLine.getCommandLineString() : "not constructed";
LOGGER.debug("Finished `" + getPresentableName() + "` with an exception. Commandline: " + commandLineInfo, e);
return false;
}
}
Aggregations