use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-plugins by JetBrains.
the class PhoneGapTargets method list.
protected List<String> list(String executableName, Function<String, String> parser, boolean errorOut, String... params) {
List<String> result = ContainerUtil.newArrayList();
File deployExecutable = PathEnvironmentVariableUtil.findInPath(executableName);
if (deployExecutable == null)
return result;
try {
GeneralCommandLine line = new GeneralCommandLine(deployExecutable.getAbsolutePath());
line.addParameters(params);
ProcessOutput output = ExecUtil.execAndGetOutput(line);
List<String> lines = null;
if (errorOut) {
if (!StringUtil.isEmpty(output.getStderr())) {
lines = output.getStderrLines();
}
}
if (lines == null) {
lines = output.getStdoutLines();
}
if (output.getExitCode() != 0)
return result;
for (String value : lines) {
ContainerUtil.addIfNotNull(result, parser.fun(value));
}
} catch (ExecutionException e) {
LOGGER.debug(e.getMessage(), e);
}
return result;
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-plugins by JetBrains.
the class KarmaServer method startServer.
private KillableColoredProcessHandler startServer(@NotNull KarmaServerSettings serverSettings) throws IOException {
GeneralCommandLine commandLine = new GeneralCommandLine();
serverSettings.getEnvData().configureCommandLine(commandLine, true);
commandLine.withWorkDirectory(serverSettings.getConfigurationFile().getParentFile());
commandLine.setExePath(serverSettings.getNodeInterpreter().getInterpreterSystemDependentPath());
File serverFile = myKarmaJsSourcesLocator.getServerAppFile();
//NodeCommandLineUtil.addNodeOptionsForDebugging(commandLine, Collections.emptyList(), 34598, true,
// serverSettings.getNodeInterpreter(), true);
commandLine.addParameter(serverFile.getAbsolutePath());
commandLine.addParameter("--karmaPackageDir=" + myServerSettings.getKarmaPackage().getSystemDependentPath());
commandLine.addParameter("--configFile=" + serverSettings.getConfigurationFilePath());
String browsers = serverSettings.getBrowsers();
if (!StringUtil.isEmptyOrSpaces(browsers)) {
commandLine.addParameter("--browsers=" + browsers);
}
if (myCoveragePeer != null) {
commandLine.addParameter("--coverageTempDir=" + myCoveragePeer.getCoverageTempDir());
}
if (serverSettings.isDebug()) {
commandLine.addParameter("--debug=true");
}
commandLine.setCharset(CharsetToolkit.UTF8_CHARSET);
KillableColoredProcessHandler processHandler;
try {
processHandler = new KillableColoredProcessHandler(commandLine);
} catch (ExecutionException e) {
throw new IOException("Can not start Karma server: " + commandLine.getCommandLineString(), e);
}
final int processHashCode = System.identityHashCode(processHandler.getProcess());
LOG.info("Karma server " + processHashCode + " started successfully: " + commandLine.getCommandLineString());
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(final ProcessEvent event) {
LOG.info("Karma server " + processHashCode + " terminated with exit code " + event.getExitCode());
Disposer.dispose(myDisposable);
fireOnTerminated(event.getExitCode());
}
});
ProcessTerminatedListener.attach(processHandler);
processHandler.setShouldDestroyProcessRecursively(true);
return processHandler;
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-plugins by JetBrains.
the class JstdServer method createCommandLine.
private static GeneralCommandLine createCommandLine(@NotNull JstdServerSettings settings) {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(System.getProperty("java.home") + File.separator + "bin" + File.separator + "java");
Charset charset = StandardCharsets.UTF_8;
commandLine.setCharset(charset);
commandLine.addParameter("-Dfile.encoding=" + charset.name());
//commandLine.addParameter("-Xdebug");
//commandLine.addParameter("-Xrunjdwp:transport=dt_socket,address=5000,server=y,suspend=y");
File file = new File(PathUtil.getJarPathForClass(JsTestDriverServer.class));
commandLine.setWorkDirectory(file.getParentFile());
commandLine.addParameter("-cp");
commandLine.addParameter(getClasspath());
commandLine.addParameter("com.google.jstestdriver.idea.rt.server.JstdServerMain");
commandLine.addParameter("--port");
commandLine.addParameter(String.valueOf(settings.getPort()));
commandLine.addParameter("--runnerMode");
commandLine.addParameter(settings.getRunnerMode().name());
commandLine.addParameter("--browserTimeout");
commandLine.addParameter(String.valueOf(settings.getBrowserTimeoutMillis()));
return commandLine;
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-plugins by JetBrains.
the class JstdServer method start.
@NotNull
private static OSProcessHandler start(@NotNull JstdServerSettings settings, int id) throws IOException {
GeneralCommandLine commandLine = createCommandLine(settings);
OSProcessHandler processHandler;
try {
processHandler = new KillableColoredProcessHandler(commandLine);
} catch (ExecutionException e) {
throw new IOException("Cannot start " + formatName(id, null) + ".\nCommand: " + commandLine.getCommandLineString(), e);
}
LOG.info(formatName(id, processHandler.getProcess()) + " started successfully: " + commandLine.getCommandLineString());
ProcessTerminatedListener.attach(processHandler);
processHandler.setShouldDestroyProcessRecursively(true);
return processHandler;
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-plugins by JetBrains.
the class Flexmojos4GenerateConfigTask method runGeneratorServer.
private void runGeneratorServer(MavenProjectsManager mavenProjectsManager, Project project) throws IOException, ExecutionException, MavenProcessCanceledException {
final SimpleJavaParameters params = new SimpleJavaParameters();
params.setJdk(new SimpleJavaSdkType().createJdk("tmp", SystemProperties.getJavaHome()));
final MavenGeneralSettings mavenGeneralSettings = mavenProjectsManager.getGeneralSettings();
final ParametersList programParametersList = params.getProgramParametersList();
programParametersList.add(getSettingsFilePath(mavenGeneralSettings.getEffectiveGlobalSettingsIoFile()));
programParametersList.add(getSettingsFilePath(mavenGeneralSettings.getEffectiveUserSettingsIoFile()));
programParametersList.add(mavenGeneralSettings.getEffectiveLocalRepository().getAbsolutePath());
programParametersList.add(mavenGeneralSettings.isWorkOffline() ? "t" : "f");
//noinspection ConstantConditions
programParametersList.add(project.getBaseDir().getPath() + "/.idea/flexmojos");
configureMavenClassPath(mavenGeneralSettings, params.getClassPath());
final File userVmP = new File(SystemProperties.getUserHome(), "fcg-vmp");
if (userVmP.exists()) {
params.getVMParametersList().addParametersString(FileUtil.loadFile(userVmP));
}
params.setMainClass("com.intellij.flex.maven.GeneratorServer");
final GeneralCommandLine commandLine = params.toCommandLine();
commandLine.setRedirectErrorStream(true);
LOG.info("Generate Flex Configs Task:" + commandLine.getCommandLineString());
indicator.checkCanceled();
process = commandLine.createProcess();
ApplicationManager.getApplication().executeOnPooledThread(new OutputReader(project));
//noinspection IOResourceOpenedButNotSafelyClosed
out = new DataOutputStream(new BufferedOutputStream(process.getOutputStream()));
writeExplicitProfiles(mavenProjectsManager.getExplicitProfiles().getEnabledProfiles());
writeWorkspaceMap(myTree.getProjects());
out.writeUTF(FlexCommonUtils.getPathToBundledJar("flexmojos-idea-configurator.jar"));
out.writeUTF(getIdeaConfiguratorClassName());
}
Aggregations