Java Code Examples for com.intellij.execution.configurations.GeneralCommandLine#withEnvironment()
The following examples show how to use
com.intellij.execution.configurations.GeneralCommandLine#withEnvironment() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlutterCommand.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Creates the command line to run. * <p> * If a project is supplied, it will be used to determine the ANDROID_HOME variable for the subprocess. */ @NotNull public GeneralCommandLine createGeneralCommandLine(@Nullable Project project) { final GeneralCommandLine line = new GeneralCommandLine(); line.setCharset(CharsetToolkit.UTF8_CHARSET); line.withEnvironment(FlutterSdkUtil.FLUTTER_HOST_ENV, FlutterSdkUtil.getFlutterHostEnvValue()); final String androidHome = IntelliJAndroidSdk.chooseAndroidHome(project, false); if (androidHome != null) { line.withEnvironment("ANDROID_HOME", androidHome); } line.setExePath(FileUtil.toSystemDependentName(sdk.getHomePath() + "/bin/" + FlutterSdkUtil.flutterScriptName())); if (workDir != null) { line.setWorkDirectory(workDir.getPath()); } if (!isDoctorCommand()) { line.addParameter("--no-color"); } line.addParameters(type.subCommand); line.addParameters(args); return line; }
Example 2
Source File: FlutterCommand.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Creates the command line to run. * <p> * If a project is supplied, it will be used to determine the ANDROID_HOME variable for the subprocess. */ @NotNull public GeneralCommandLine createGeneralCommandLine(@Nullable Project project) { final GeneralCommandLine line = new GeneralCommandLine(); line.setCharset(CharsetToolkit.UTF8_CHARSET); line.withEnvironment(FlutterSdkUtil.FLUTTER_HOST_ENV, FlutterSdkUtil.getFlutterHostEnvValue()); final String androidHome = IntelliJAndroidSdk.chooseAndroidHome(project, false); if (androidHome != null) { line.withEnvironment("ANDROID_HOME", androidHome); } line.setExePath(FileUtil.toSystemDependentName(sdk.getHomePath() + "/bin/" + FlutterSdkUtil.flutterScriptName())); if (workDir != null) { line.setWorkDirectory(workDir.getPath()); } if (!isDoctorCommand()) { line.addParameter("--no-color"); } line.addParameters(type.subCommand); line.addParameters(args); return line; }
Example 3
Source File: BashRunConfigUtil.java From BashSupport with Apache License 2.0 | 6 votes |
@NotNull public static GeneralCommandLine createCommandLine(String workingDir, BashRunConfiguration runConfig) { String interpreterPath; if (runConfig.isUseProjectInterpreter()) { interpreterPath = BashProjectSettings.storedSettings(runConfig.getProject()).getProjectInterpreter(); } else { interpreterPath = runConfig.getInterpreterPath(); } GeneralCommandLine cmd = new GeneralCommandLine(); cmd.setExePath(interpreterPath); cmd.getParametersList().addParametersString(runConfig.getInterpreterOptions()); cmd.addParameter(runConfig.getScriptName()); cmd.getParametersList().addParametersString(runConfig.getProgramParameters()); cmd.withWorkDirectory(workingDir); cmd.withParentEnvironmentType(runConfig.isPassParentEnvs() ? GeneralCommandLine.ParentEnvironmentType.CONSOLE : GeneralCommandLine.ParentEnvironmentType.NONE); cmd.withEnvironment(runConfig.getEnvs()); return cmd; }
Example 4
Source File: GaugeRunConfiguration.java From Intellij-Plugin with Apache License 2.0 | 6 votes |
private void addProgramArguments(GeneralCommandLine commandLine) { if (programParameters == null) { return; } String parameters = programParameters.getProgramParameters(); if (!Strings.isEmpty(parameters)) { commandLine.addParameters(programParameters.getProgramParameters().split(" ")); } Map<String, String> envs = programParameters.getEnvs(); if (!envs.isEmpty()) { commandLine.withEnvironment(envs); } if (Strings.isNotEmpty(programParameters.getWorkingDirectory())) { commandLine.setWorkDirectory(new File(programParameters.getWorkingDirectory())); } }
Example 5
Source File: BuckCommandHandler.java From buck with Apache License 2.0 | 6 votes |
/** * @param project a project * @param command a command to execute (if empty string, the parameter is ignored) * @param doStartNotify true if the handler should call OSHandler#startNotify */ public BuckCommandHandler(Project project, BuckCommand command, boolean doStartNotify) { this.doStartNotify = doStartNotify; String buckExecutable = BuckExecutableSettingsProvider.getInstance(project).resolveBuckExecutable(); this.project = project; this.buckModule = project.getComponent(BuckModule.class); this.command = command; commandLine = new GeneralCommandLine(); commandLine.setExePath(buckExecutable); commandLine.withWorkDirectory(calcWorkingDirFor(project)); commandLine.withEnvironment(EnvironmentUtil.getEnvironmentMap()); commandLine.addParameter(command.name()); for (String parameter : command.getParameters()) { commandLine.addParameter(parameter); } }
Example 6
Source File: DeviceDaemon.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private GeneralCommandLine toCommandLine() { final GeneralCommandLine result = new GeneralCommandLine().withWorkDirectory(workDir); result.setCharset(CharsetToolkit.UTF8_CHARSET); result.setExePath(FileUtil.toSystemDependentName(command)); result.withEnvironment(FlutterSdkUtil.FLUTTER_HOST_ENV, FlutterSdkUtil.getFlutterHostEnvValue()); if (androidHome != null) { result.withEnvironment("ANDROID_HOME", androidHome); } for (String param : parameters) { result.addParameter(param); } return result; }
Example 7
Source File: DeviceDaemon.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private GeneralCommandLine toCommandLine() { final GeneralCommandLine result = new GeneralCommandLine().withWorkDirectory(workDir); result.setCharset(CharsetToolkit.UTF8_CHARSET); result.setExePath(FileUtil.toSystemDependentName(command)); result.withEnvironment(FlutterSdkUtil.FLUTTER_HOST_ENV, FlutterSdkUtil.getFlutterHostEnvValue()); if (androidHome != null) { result.withEnvironment("ANDROID_HOME", androidHome); } for (String param : parameters) { result.addParameter(param); } return result; }
Example 8
Source File: Runner.java From phpstorm-plugin with MIT License | 5 votes |
protected OSProcessHandler prepareProcessHandler(@NotNull String exePath, @Nullable String workingDirectory, String[] parameters, @Nullable Map<String, String> environment) throws ExecutionException { GeneralCommandLine commandLine = new GeneralCommandLine(exePath); commandLine.addParameters(parameters); if (workingDirectory != null) { commandLine.setWorkDirectory(workingDirectory); } commandLine.withEnvironment(environment); return new ColoredProcessHandler(commandLine); }
Example 9
Source File: BuckWSServerPortUtils.java From buck with Apache License 2.0 | 5 votes |
/** Returns the port number of Buck's HTTP server, if it can be determined. */ public static int getPort(Project project, String path) throws NumberFormatException, IOException, ExecutionException { String exec = BuckExecutableSettingsProvider.getInstance(project).resolveBuckExecutable(); if (Strings.isNullOrEmpty(exec)) { throw new RuntimeException("Buck executable is not defined in settings."); } GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.setExePath(exec); commandLine.withWorkDirectory(path); commandLine.withEnvironment(EnvironmentUtil.getEnvironmentMap()); commandLine.addParameter("server"); commandLine.addParameter("status"); commandLine.addParameter("--reuse-current-config"); commandLine.addParameter("--http-port"); commandLine.setRedirectErrorStream(true); Process p = commandLine.createProcess(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = reader.readLine()) != null) { if (line.startsWith(SEARCH_FOR)) { return Integer.parseInt(line.substring(SEARCH_FOR.length())); } } throw new RuntimeException( "Configured buck executable did not report a valid port string," + " ensure " + commandLine.getCommandLineString() + " can be run from " + path); }
Example 10
Source File: EnvironmentVariablesData.java From consulo with Apache License 2.0 | 5 votes |
public void configureCommandLine(@Nonnull GeneralCommandLine commandLine, boolean consoleParentEnvs) { if (myPassParentEnvs) { commandLine.withParentEnvironmentType(consoleParentEnvs ? GeneralCommandLine.ParentEnvironmentType.CONSOLE : GeneralCommandLine.ParentEnvironmentType.SYSTEM); } else { commandLine.withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.NONE); } commandLine.withEnvironment(myEnvs); }
Example 11
Source File: ProcessHelper.java From azure-devops-intellij with MIT License | 4 votes |
/** * Adds current Java to the PATH environment variable for the passed command line. */ public static GeneralCommandLine patchPathEnvironmentVariable(GeneralCommandLine commandLine) { return commandLine.withEnvironment("PATH", getPatchedPathWithCurrentJavaBinLocation()); }