use of com.intellij.execution.ExecutionException in project android by JetBrains.
the class AndroidMavenExecutor method generateResources.
public static Map<CompilerMessageCategory, List<String>> generateResources(final Module module) {
MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(module.getProject());
final MavenRunnerParameters parameters = new MavenRunnerParameters(true, projectsManager.findProject(module).getDirectory(), Collections.singletonList("process-resources"), projectsManager.getExplicitProfiles());
final Map<CompilerMessageCategory, List<String>> result = new HashMap<CompilerMessageCategory, List<String>>();
result.put(CompilerMessageCategory.ERROR, new ArrayList<String>());
try {
JavaParameters javaParams = ApplicationManager.getApplication().runReadAction(new Computable<JavaParameters>() {
@Nullable
@Override
public JavaParameters compute() {
try {
return MavenExternalParameters.createJavaParameters(module.getProject(), parameters);
} catch (ExecutionException e) {
LOG.info(e);
result.get(CompilerMessageCategory.ERROR).add(e.getMessage());
return null;
}
}
});
if (javaParams == null) {
return result;
}
GeneralCommandLine commandLine = javaParams.toCommandLine();
final StringBuildingOutputProcessor processor = new StringBuildingOutputProcessor();
boolean success = AndroidUtils.executeCommand(commandLine, processor, WaitingStrategies.WaitForever.getInstance()) == ExecutionStatus.SUCCESS;
String message = processor.getMessage();
if (!success) {
LOG.info(message);
String lcmessage = message.toLowerCase();
int buildErrorIndex = lcmessage.indexOf(BUILD_ERROR_INDICATOR);
if (buildErrorIndex >= 0) {
result.get(CompilerMessageCategory.ERROR).add(message.substring(buildErrorIndex));
}
}
} catch (ExecutionException e) {
LOG.info(e);
result.get(CompilerMessageCategory.ERROR).add(e.getMessage());
}
return result;
}
use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.
the class GitExecutableDetector method runs.
/**
* Checks if it is possible to run the specified program.
* Made protected for tests not to start a process there.
*/
protected boolean runs(@NotNull String exec) {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(exec);
commandLine.setCharset(CharsetToolkit.getDefaultSystemCharset());
try {
CapturingProcessHandler handler = new CapturingProcessHandler(commandLine);
ProcessOutput result = handler.runProcess((int) TimeUnit.SECONDS.toMillis(5));
return !result.isTimeout();
} catch (ExecutionException e) {
return false;
}
}
use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.
the class Tool method execute.
public void execute(AnActionEvent event, DataContext dataContext, long executionId, @Nullable final ProcessListener processListener) {
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return;
}
FileDocumentManager.getInstance().saveAllDocuments();
try {
if (isUseConsole()) {
ExecutionEnvironment environment = ExecutionEnvironmentBuilder.create(project, DefaultRunExecutor.getRunExecutorInstance(), new ToolRunProfile(this, dataContext)).build();
environment.setExecutionId(executionId);
environment.getRunner().execute(environment, new ProgramRunner.Callback() {
@Override
public void processStarted(RunContentDescriptor descriptor) {
ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler != null && processListener != null) {
LOG.assertTrue(!processHandler.isStartNotified(), "ProcessHandler is already startNotified, the listener won't be correctly notified");
processHandler.addProcessListener(processListener);
}
}
});
} else {
GeneralCommandLine commandLine = createCommandLine(dataContext);
if (commandLine == null) {
return;
}
OSProcessHandler handler = new OSProcessHandler(commandLine);
handler.addProcessListener(new ToolProcessAdapter(project, synchronizeAfterExecution(), getName()));
if (processListener != null) {
handler.addProcessListener(processListener);
}
handler.startNotify();
}
} catch (ExecutionException ex) {
ExecutionErrorDialog.show(ex, ToolsBundle.message("tools.process.start.error"), project);
}
}
use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.
the class BrowserLauncherAppless method doLaunch.
private boolean doLaunch(@Nullable String url, @NotNull List<String> command, @Nullable WebBrowser browser, @Nullable Project project, @NotNull String[] additionalParameters, @Nullable Runnable launchTask) {
GeneralCommandLine commandLine = new GeneralCommandLine(command);
if (url != null && url.startsWith("jar:")) {
return false;
}
if (url != null) {
commandLine.addParameter(url);
}
final BrowserSpecificSettings browserSpecificSettings = browser == null ? null : browser.getSpecificSettings();
if (browserSpecificSettings != null) {
commandLine.getEnvironment().putAll(browserSpecificSettings.getEnvironmentVariables());
}
addArgs(commandLine, browserSpecificSettings, additionalParameters);
try {
Process process = commandLine.createProcess();
checkCreatedProcess(browser, project, commandLine, process, launchTask);
return true;
} catch (ExecutionException e) {
showError(e.getMessage(), browser, project, null, null);
return false;
}
}
use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.
the class GeneralCommandLine method createProcess.
@NotNull
public Process createProcess() throws ExecutionException {
if (LOG.isDebugEnabled()) {
LOG.debug("Executing [" + getCommandLineString() + "]");
LOG.debug(" environment: " + myEnvParams + " (+" + myParentEnvironmentType + ")");
LOG.debug(" charset: " + myCharset);
}
List<String> commands;
try {
checkWorkingDirectory();
if (StringUtil.isEmptyOrSpaces(myExePath)) {
throw new ExecutionException(IdeBundle.message("run.configuration.error.executable.not.specified"));
}
commands = CommandLineUtil.toCommandLine(myExePath, myProgramParams.getList());
} catch (ExecutionException e) {
LOG.info(e);
throw e;
}
try {
return startProcess(commands);
} catch (IOException e) {
LOG.info(e);
throw new ProcessNotCreatedException(e.getMessage(), e, this);
}
}
Aggregations