use of com.intellij.execution.process.OSProcessHandler in project intellij-community by JetBrains.
the class TestNGRunnableState method startProcess.
@NotNull
@Override
protected OSProcessHandler startProcess() throws ExecutionException {
final OSProcessHandler processHandler = new KillableColoredProcessHandler(createCommandLine());
ProcessTerminatedListener.attach(processHandler);
createSearchingForTestsTask().attachTaskToProcess(processHandler);
return processHandler;
}
use of com.intellij.execution.process.OSProcessHandler in project intellij-community by JetBrains.
the class CompileQrcAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
VirtualFile[] vFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
assert vFiles != null;
Module module = e.getData(LangDataKeys.MODULE);
String path = QtFileType.findQtTool(module, "pyrcc4");
if (path == null) {
path = QtFileType.findQtTool(module, "pyside-rcc");
}
if (path == null) {
Messages.showErrorDialog(project, "Could not find pyrcc4 or pyside-rcc for selected Python interpreter", "Compile .qrc file");
return;
}
CompileQrcDialog dialog = new CompileQrcDialog(project, vFiles);
dialog.show();
if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
return;
}
GeneralCommandLine cmdLine = new GeneralCommandLine(path, "-o", dialog.getOutputPath());
for (VirtualFile vFile : vFiles) {
cmdLine.addParameter(vFile.getPath());
}
try {
ProcessHandler process = new OSProcessHandler(cmdLine);
ProcessTerminatedListener.attach(process);
new RunContentExecutor(project, process).withTitle("Compile .qrc").run();
} catch (ExecutionException ex) {
Messages.showErrorDialog(project, "Error running " + path + ": " + ex.getMessage(), "Compile .qrc file");
}
}
use of com.intellij.execution.process.OSProcessHandler in project intellij-community by JetBrains.
the class XsltCommandLineState method startProcess.
@Override
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
final OSProcessHandler osProcessHandler = createJavaParameters().createOSProcessHandler();
osProcessHandler.putUserData(STATE, this);
osProcessHandler.addProcessListener(new MyProcessAdapter());
final List<XsltRunnerExtension> extensions = XsltRunnerExtension.getExtensions(myXsltRunConfiguration, myIsDebugger);
for (XsltRunnerExtension extension : extensions) {
osProcessHandler.addProcessListener(extension.createProcessListener(myXsltRunConfiguration.getProject(), myExtensionData));
}
return osProcessHandler;
}
use of com.intellij.execution.process.OSProcessHandler in project intellij-community by JetBrains.
the class MavenServerManager method createRunProfileState.
private RunProfileState createRunProfileState() {
return new CommandLineState(null) {
private SimpleJavaParameters createJavaParameters() {
final SimpleJavaParameters params = new SimpleJavaParameters();
final Sdk jdk = getJdk();
params.setJdk(jdk);
params.setWorkingDirectory(PathManager.getBinPath());
params.setMainClass(MAIN_CLASS);
Map<String, String> defs = new THashMap<>();
defs.putAll(MavenUtil.getPropertiesFromMavenOpts());
// pass ssl-related options
for (Map.Entry<Object, Object> each : System.getProperties().entrySet()) {
Object key = each.getKey();
Object value = each.getValue();
if (key instanceof String && value instanceof String && ((String) key).startsWith("javax.net.ssl")) {
defs.put((String) key, (String) value);
}
}
if (SystemInfo.isMac) {
String arch = System.getProperty("sun.arch.data.model");
if (arch != null) {
params.getVMParametersList().addParametersString("-d" + arch);
}
}
defs.put("java.awt.headless", "true");
for (Map.Entry<String, String> each : defs.entrySet()) {
params.getVMParametersList().defineProperty(each.getKey(), each.getValue());
}
params.getVMParametersList().addProperty("idea.version=", MavenUtil.getIdeaVersionToPassToMavenProcess());
boolean xmxSet = false;
boolean forceMaven2 = false;
if (myState.vmOptions != null) {
ParametersList mavenOptsList = new ParametersList();
mavenOptsList.addParametersString(myState.vmOptions);
for (String param : mavenOptsList.getParameters()) {
if (param.startsWith("-Xmx")) {
xmxSet = true;
}
if (param.equals(FORCE_MAVEN2_OPTION)) {
forceMaven2 = true;
}
params.getVMParametersList().add(param);
}
}
final File mavenHome;
final String mavenVersion;
final File currentMavenHomeFile = forceMaven2 ? BundledMavenPathHolder.myBundledMaven2Home : getCurrentMavenHomeFile();
if (currentMavenHomeFile == null) {
mavenHome = BundledMavenPathHolder.myBundledMaven3Home;
mavenVersion = getMavenVersion(mavenHome);
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
final Project project = openProjects.length == 1 ? openProjects[0] : null;
if (project != null) {
new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "", RunnerBundle.message("external.maven.home.invalid.substitution.warning.with.fix", myState.mavenHome, mavenVersion), NotificationType.WARNING, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
ShowSettingsUtil.getInstance().showSettingsDialog(project, MavenSettings.DISPLAY_NAME);
}
}).notify(null);
} else {
new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "", RunnerBundle.message("external.maven.home.invalid.substitution.warning", myState.mavenHome, mavenVersion), NotificationType.WARNING).notify(null);
}
} else {
mavenHome = currentMavenHomeFile;
mavenVersion = getMavenVersion(mavenHome);
}
assert mavenVersion != null;
params.getVMParametersList().addProperty(MavenServerEmbedder.MAVEN_EMBEDDER_VERSION, mavenVersion);
String sdkConfigLocation = "Settings | Build, Execution, Deployment | Build Tools | Maven | Importing | JDK for Importer";
verifyMavenSdkRequirements(jdk, mavenVersion, sdkConfigLocation);
final List<String> classPath = new ArrayList<>();
classPath.add(PathUtil.getJarPathForClass(org.apache.log4j.Logger.class));
if (StringUtil.compareVersionNumbers(mavenVersion, "3.1") < 0) {
classPath.add(PathUtil.getJarPathForClass(Logger.class));
classPath.add(PathUtil.getJarPathForClass(Log4jLoggerFactory.class));
}
classPath.addAll(PathManager.getUtilClassPath());
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(Query.class));
params.getClassPath().add(PathManager.getResourceRoot(getClass(), "/messages/CommonBundle.properties"));
params.getClassPath().addAll(classPath);
params.getClassPath().addAllFiles(collectClassPathAndLibsFolder(mavenVersion, mavenHome));
String embedderXmx = System.getProperty("idea.maven.embedder.xmx");
if (embedderXmx != null) {
params.getVMParametersList().add("-Xmx" + embedderXmx);
} else {
if (!xmxSet) {
params.getVMParametersList().add("-Xmx768m");
}
}
String mavenEmbedderDebugPort = System.getProperty("idea.maven.embedder.debug.port");
if (mavenEmbedderDebugPort != null) {
params.getVMParametersList().addParametersString("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" + mavenEmbedderDebugPort);
}
String mavenEmbedderParameters = System.getProperty("idea.maven.embedder.parameters");
if (mavenEmbedderParameters != null) {
params.getProgramParametersList().addParametersString(mavenEmbedderParameters);
}
String mavenEmbedderCliOptions = System.getProperty(MavenServerEmbedder.MAVEN_EMBEDDER_CLI_ADDITIONAL_ARGS);
if (mavenEmbedderCliOptions != null) {
params.getVMParametersList().addProperty(MavenServerEmbedder.MAVEN_EMBEDDER_CLI_ADDITIONAL_ARGS, mavenEmbedderCliOptions);
}
return params;
}
@NotNull
@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
ProcessHandler processHandler = startProcess();
return new DefaultExecutionResult(processHandler);
}
@Override
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
SimpleJavaParameters params = createJavaParameters();
GeneralCommandLine commandLine = params.toCommandLine();
OSProcessHandler processHandler = new OSProcessHandler(commandLine);
processHandler.setShouldDestroyProcessRecursively(false);
return processHandler;
}
};
}
use of com.intellij.execution.process.OSProcessHandler in project intellij-community by JetBrains.
the class StudyRunAction method executeFile.
private void executeFile(@NotNull final Project project, @NotNull final VirtualFile openedFile, @NotNull final String filePath) {
GeneralCommandLine cmd = new GeneralCommandLine();
cmd.withWorkDirectory(openedFile.getParent().getCanonicalPath());
TaskFile selectedTaskFile = StudyUtils.getTaskFile(project, openedFile);
assert selectedTaskFile != null;
final Task currentTask = selectedTaskFile.getTask();
final Sdk sdk = StudyUtils.findSdk(currentTask, project);
if (sdk == null) {
StudyUtils.showNoSdkNotification(currentTask, project);
return;
}
String sdkHomePath = sdk.getHomePath();
if (sdkHomePath != null) {
cmd.setExePath(sdkHomePath);
StudyUtils.setCommandLineParameters(cmd, project, filePath, sdkHomePath, currentTask);
try {
myHandler = new OSProcessHandler(cmd);
} catch (ExecutionException e) {
LOG.error(e);
return;
}
for (ProcessListener processListener : myProcessListeners) {
myHandler.addProcessListener(processListener);
}
final RunContentExecutor executor = StudyUtils.getExecutor(project, currentTask, myHandler);
if (executor != null) {
Disposer.register(project, executor);
executor.run();
}
EduUtils.synchronize();
}
}
Aggregations