use of com.intellij.execution.process.BaseOSProcessHandler in project ballerina by ballerina-lang.
the class BallerinaExecutor method showOutput.
private void showOutput(@NotNull OSProcessHandler originalHandler, @NotNull BallerinaHistoryProcessListener historyProcessListener) {
if (myShowOutputOnError) {
BaseOSProcessHandler outputHandler = new KillableColoredProcessHandler(originalHandler.getProcess(), null);
RunContentExecutor runContentExecutor = new RunContentExecutor(myProject, outputHandler).withTitle(getPresentableName()).withActivateToolWindow(myShowOutputOnError).withFilter(new BallerinaConsoleFilter(myProject, myModule, myWorkDirectory != null ? VfsUtilCore.pathToUrl(myWorkDirectory) : null));
Disposer.register(myProject, runContentExecutor);
runContentExecutor.run();
historyProcessListener.apply(outputHandler);
}
if (myShowNotificationsOnError) {
showNotification("Failed to run", NotificationType.ERROR);
}
}
use of com.intellij.execution.process.BaseOSProcessHandler in project android by JetBrains.
the class AndroidCommonUtils method handleDexCompilationResult.
public static void handleDexCompilationResult(@NotNull Process process, @NotNull String commandLine, @NotNull String outputFilePath, @NotNull final Map<AndroidCompilerMessageKind, List<String>> messages, boolean multiDex) {
final BaseOSProcessHandler handler = new BaseOSProcessHandler(process, commandLine, null);
handler.addProcessListener(new ProcessAdapter() {
private AndroidCompilerMessageKind myCategory = null;
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
String[] msgs = event.getText().split("\\n");
for (String msg : msgs) {
msg = msg.trim();
String msglc = msg.toLowerCase();
if (outputType == ProcessOutputTypes.STDERR) {
if (WARNING_PATTERN.matcher(msglc).matches()) {
myCategory = AndroidCompilerMessageKind.WARNING;
}
if (ERROR_PATTERN.matcher(msglc).matches() || EXCEPTION_PATTERN.matcher(msglc).matches() || myCategory == null) {
myCategory = AndroidCompilerMessageKind.ERROR;
}
messages.get(myCategory).add(msg);
} else if (outputType == ProcessOutputTypes.STDOUT) {
if (!msglc.startsWith("processing")) {
messages.get(AndroidCompilerMessageKind.INFORMATION).add(msg);
}
}
LOG.debug(msg);
}
}
});
handler.startNotify();
handler.waitFor();
final List<String> errors = messages.get(AndroidCompilerMessageKind.ERROR);
if (new File(outputFilePath).isFile()) {
// if compilation finished correctly, show all errors as warnings
messages.get(AndroidCompilerMessageKind.WARNING).addAll(errors);
errors.clear();
} else if (errors.size() == 0 && !multiDex) {
errors.add("Cannot create classes.dex file");
}
}
use of com.intellij.execution.process.BaseOSProcessHandler in project intellij-community by JetBrains.
the class ForkedGroovyc method runGroovyc.
@Override
public GroovycContinuation runGroovyc(Collection<String> compilationClassPath, boolean forStubs, JpsGroovySettings settings, File tempFile, final GroovycOutputParser parser) throws Exception {
List<String> classpath = new ArrayList<>();
if (myOptimizeClassLoading) {
classpath.addAll(GroovyBuilder.getGroovyRtRoots());
classpath.add(ClasspathBootstrap.getResourcePath(Function.class));
classpath.add(ClasspathBootstrap.getResourcePath(UrlClassLoader.class));
classpath.add(ClasspathBootstrap.getResourceFile(THashMap.class).getPath());
} else {
classpath.addAll(compilationClassPath);
}
List<String> vmParams = ContainerUtilRt.newArrayList();
vmParams.add("-Xmx" + System.getProperty("groovyc.heap.size", settings.heapSize) + "m");
vmParams.add("-Dfile.encoding=" + System.getProperty("file.encoding"));
if ("false".equals(System.getProperty(GroovyRtConstants.GROOVYC_ASM_RESOLVING_ONLY))) {
vmParams.add("-D" + GroovyRtConstants.GROOVYC_ASM_RESOLVING_ONLY + "=false");
}
String configScript = settings.configScript;
if (StringUtil.isNotEmpty(configScript)) {
vmParams.add("-D" + GroovyRtConstants.GROOVYC_CONFIG_SCRIPT + "=" + configScript);
}
String grapeRoot = System.getProperty(GroovycOutputParser.GRAPE_ROOT);
if (grapeRoot != null) {
vmParams.add("-D" + GroovycOutputParser.GRAPE_ROOT + "=" + grapeRoot);
}
final List<String> cmd = ExternalProcessUtil.buildJavaCommandLine(getJavaExecutable(myChunk), "org.jetbrains.groovy.compiler.rt.GroovycRunner", Collections.<String>emptyList(), classpath, vmParams, getProgramParams(tempFile, settings, forStubs));
final Process process = Runtime.getRuntime().exec(ArrayUtil.toStringArray(cmd));
ProcessHandler handler = new BaseOSProcessHandler(process, StringUtil.join(cmd, " "), null) {
@NotNull
@Override
protected Future<?> executeOnPooledThread(@NotNull Runnable task) {
return SharedThreadPool.getInstance().executeOnPooledThread(task);
}
@Override
public void notifyTextAvailable(String text, Key outputType) {
parser.notifyTextAvailable(text, outputType);
}
};
handler.startNotify();
handler.waitFor();
parser.notifyFinished(process.exitValue());
return null;
}
use of com.intellij.execution.process.BaseOSProcessHandler in project intellij-elixir by KronicDeth.
the class ElixirBuilder method runMix.
private static void runMix(@NotNull ElixirTarget target, @NotNull String elixirPath, @NotNull String mixPath, @Nullable String contentRootPath, @NotNull ElixirCompilerOptions compilerOptions, @NotNull CompileContext context) throws ProjectBuildException {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.withWorkDirectory(contentRootPath);
commandLine.setExePath(elixirPath);
commandLine.addParameter(mixPath);
commandLine.addParameter(target.isTests() ? "test" : "compile");
addCompileOptions(commandLine, compilerOptions);
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, MIX_NAME, commandLine.getWorkDirectory().getPath());
handler.addProcessListener(adapter);
handler.startNotify();
handler.waitFor();
}
use of com.intellij.execution.process.BaseOSProcessHandler in project intellij-elixir by KronicDeth.
the class ElixirBuilder method runElixirc.
private static void runElixirc(ElixirTarget target, CompileContext context, ElixirCompilerOptions compilerOptions, Collection<File> files, File outputDirectory) throws ProjectBuildException {
GeneralCommandLine commandLine = getElixircCommandLine(target, context, compilerOptions, files, outputDirectory);
Process process;
try {
process = commandLine.createProcess();
} catch (ExecutionException e) {
throw new ProjectBuildException("Failed to launch elixir compiler", e);
}
BaseOSProcessHandler handler = new BaseOSProcessHandler(process, commandLine.getCommandLineString(), Charset.defaultCharset());
ProcessAdapter adapter = new ElixirCompilerProcessAdapter(context, ElIXIRC_NAME, "");
handler.addProcessListener(adapter);
handler.startNotify();
handler.waitFor();
}
Aggregations