Search in sources :

Example 61 with GeneralCommandLine

use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-community by JetBrains.

the class JdkUtil method setupJVMCommandLine.

public static GeneralCommandLine setupJVMCommandLine(@NotNull SimpleJavaParameters javaParameters) throws CantRunException {
    Sdk jdk = javaParameters.getJdk();
    if (jdk == null)
        throw new CantRunException(ExecutionBundle.message("run.configuration.error.no.jdk.specified"));
    SdkTypeId type = jdk.getSdkType();
    if (!(type instanceof JavaSdkType))
        throw new CantRunException(ExecutionBundle.message("run.configuration.error.no.jdk.specified"));
    String exePath = ((JavaSdkType) type).getVMExecutablePath(jdk);
    if (exePath == null)
        throw new CantRunException(ExecutionBundle.message("run.configuration.cannot.find.vm.executable"));
    GeneralCommandLine commandLine = new GeneralCommandLine(exePath);
    setupCommandLine(commandLine, javaParameters);
    return commandLine;
}
Also used : CantRunException(com.intellij.execution.CantRunException) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine)

Example 62 with GeneralCommandLine

use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-community by JetBrains.

the class JdkUtil method setupJVMCommandLine.

/** @deprecated use {@link SimpleJavaParameters#toCommandLine()} (to be removed in IDEA 2018) */
public static GeneralCommandLine setupJVMCommandLine(final String exePath, final SimpleJavaParameters javaParameters, final boolean forceDynamicClasspath) {
    try {
        javaParameters.setUseDynamicClasspath(forceDynamicClasspath);
        GeneralCommandLine commandLine = new GeneralCommandLine(exePath);
        setupCommandLine(commandLine, javaParameters);
        return commandLine;
    } catch (CantRunException e) {
        throw new RuntimeException(e);
    }
}
Also used : CantRunException(com.intellij.execution.CantRunException) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine)

Example 63 with GeneralCommandLine

use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-community by JetBrains.

the class JdkPopupAction method retrieveJDKLocations.

private static ArrayList<Pair<File, String>> retrieveJDKLocations() {
    ArrayList<Pair<File, String>> jdkLocations = new ArrayList<>();
    Collection<String> homePaths = JavaSdk.getInstance().suggestHomePaths();
    for (final String path : homePaths) {
        try {
            File file = new File(path);
            File javaExe = new File(new File(file, "bin"), "java.exe");
            ProcessOutput output = ExecUtil.execAndGetOutput(new GeneralCommandLine(javaExe.getAbsolutePath(), "-version"));
            List<String> lines = output.getStderrLines();
            if (lines.isEmpty()) {
                lines = output.getStdoutLines();
            }
            StringBuilder stringBuilder = new StringBuilder();
            if (lines.size() == 3) {
                stringBuilder.append("JDK ");
                String line = lines.get(1);
                int pos = line.indexOf("(build ");
                if (pos != -1) {
                    stringBuilder.append(line.substring(pos + 7, line.length() - 1));
                }
                line = lines.get(2);
                pos = line.indexOf(" (build");
                if (pos != -1) {
                    String substring = line.substring(0, pos);
                    stringBuilder.append(" (").append(substring).append(")");
                }
            } else {
                stringBuilder.append(file.getName());
            }
            jdkLocations.add(Pair.create(file, stringBuilder.toString()));
        } catch (ExecutionException e) {
            LOG.debug(e);
        }
    }
    return jdkLocations;
}
Also used : ProcessOutput(com.intellij.execution.process.ProcessOutput) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ArrayList(java.util.ArrayList) ExecutionException(com.intellij.execution.ExecutionException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Pair(com.intellij.openapi.util.Pair)

Example 64 with GeneralCommandLine

use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-plugins by JetBrains.

the class PhoneGapCommandLine method serve.

private OSProcessHandler serve(String extraArg) throws ExecutionException {
    GeneralCommandLine commandLine = new GeneralCommandLine(concat(newArrayList(myPath, "serve"), parseArgs(extraArg)));
    commandLine.withWorkDirectory(myWorkDir);
    return new KillableColoredProcessHandler(commandLine, true);
}
Also used : GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine)

Example 65 with GeneralCommandLine

use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-plugins by JetBrains.

the class PhoneGapCommandLine method createProcessHandler.

private OSProcessHandler createProcessHandler(String... commands) throws ExecutionException {
    GeneralCommandLine commandLine = new GeneralCommandLine(commands);
    commandLine.withWorkDirectory(myWorkDir);
    return new KillableColoredProcessHandler(commandLine, true);
}
Also used : GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine)

Aggregations

GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)179 ExecutionException (com.intellij.execution.ExecutionException)70 NotNull (org.jetbrains.annotations.NotNull)47 File (java.io.File)41 VirtualFile (com.intellij.openapi.vfs.VirtualFile)31 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)25 ProcessOutput (com.intellij.execution.process.ProcessOutput)25 Key (com.intellij.openapi.util.Key)18 ProcessEvent (com.intellij.execution.process.ProcessEvent)15 Project (com.intellij.openapi.project.Project)15 IOException (java.io.IOException)15 Nullable (org.jetbrains.annotations.Nullable)15 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)14 CapturingProcessHandler (com.intellij.execution.process.CapturingProcessHandler)13 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)12 Sdk (com.intellij.openapi.projectRoots.Sdk)9 PsiFile (com.intellij.psi.PsiFile)9 ArrayList (java.util.ArrayList)9 Module (com.intellij.openapi.module.Module)8 ProcessHandler (com.intellij.execution.process.ProcessHandler)7