com.intellij.util.EnvironmentUtil Java Examples
The following examples show how to use
com.intellij.util.EnvironmentUtil.
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: GaugeUtil.java From Intellij-Plugin with Apache License 2.0 | 6 votes |
private static GaugeSettingsModel getSettingsFromPATH(GaugeSettingsModel model) throws GaugeNotFoundException { String path = EnvironmentUtil.getValue("PATH"); LOG.info("PATH => " + path); if (!StringUtils.isEmpty(path)) { for (String entry : path.split(File.pathSeparator)) { File file = new File(entry, gaugeExecutable()); if (isValidGaugeExec(file)) { LOG.info("executable path from `PATH`: " + file.getAbsolutePath()); return new GaugeSettingsModel(file.getAbsolutePath(), model.getHomePath(), model.useIntelliJTestRunner()); } } } String msg = "Could not find executable in `PATH`. Please make sure Gauge is installed." + "\nIf Gauge is installed then set the Gauge executable path in settings -> tools -> gauge."; throw new GaugeNotFoundException(msg); }
Example #2
Source File: ProgramParametersConfigurator.java From consulo with Apache License 2.0 | 6 votes |
public void configureConfiguration(SimpleProgramParameters parameters, CommonProgramRunConfigurationParameters configuration) { Project project = configuration.getProject(); Module module = getModule(configuration); parameters.getProgramParametersList().addParametersString(expandPath(configuration.getProgramParameters(), module, project)); parameters.setWorkingDirectory(getWorkingDir(configuration, project, module)); Map<String, String> envs = new HashMap<>(configuration.getEnvs()); EnvironmentUtil.inlineParentOccurrences(envs); for (Map.Entry<String, String> each : envs.entrySet()) { each.setValue(expandPath(each.getValue(), module, project)); } parameters.setEnv(envs); parameters.setPassParentEnvs(configuration.isPassParentEnvs()); }
Example #3
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 #4
Source File: RNPathUtil.java From react-native-console with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected GeneralCommandLine createDefaultTtyCommandLine() { // here just run one command: python freeline.py PtyCommandLine commandLine = new PtyCommandLine(); if (!SystemInfo.isWindows) { commandLine.getEnvironment().put("TERM", "xterm-256color"); } // commandLine.withConsoleMode(false); // commandLine.withInitialColumns(120); // ExecutionEnvironment environment = getEnvironment(); // commandLine.setWorkDirectory(environment.getProject().getBasePath()); String defaultShell = ObjectUtils.notNull(EnvironmentUtil.getValue("SHELL"), "/bin/sh"); commandLine.setExePath(defaultShell); // commandLine.setExePath("npm"); // commandLine.addParameters("run-script"); // commandLine.addParameters("start"); return commandLine; }
Example #5
Source File: IntelliJAndroidSdk.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns the best value of the Android SDK location to use, including possibly querying flutter tools for it. */ public static String chooseAndroidHome(@Nullable Project project, boolean askFlutterTools) { if (project == null) { return EnvironmentUtil.getValue("ANDROID_HOME"); } final IntelliJAndroidSdk intelliJAndroidSdk = fromProject(project); if (intelliJAndroidSdk != null) { return intelliJAndroidSdk.getHome().getPath(); } // Ask flutter tools. if (askFlutterTools) { final FlutterSdk flutterSdk = FlutterSdk.getFlutterSdk(project); if (flutterSdk != null) { final String androidSdkLocation = flutterSdk.queryFlutterConfig("android-sdk", true); if (androidSdkLocation != null) { return androidSdkLocation; } } } return EnvironmentUtil.getValue("ANDROID_HOME"); }
Example #6
Source File: IntelliJAndroidSdk.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns the Android SDK that matches the ANDROID_HOME environment variable, provided it exists. */ @Nullable public static IntelliJAndroidSdk fromEnvironment() { final String path = EnvironmentUtil.getValue("ANDROID_HOME"); if (path == null) { return null; } // TODO(skybrian) refresh? final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path); if (file == null) { return null; } return fromHome(file); }
Example #7
Source File: IntelliJAndroidSdk.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns the best value of the Android SDK location to use, including possibly querying flutter tools for it. */ public static String chooseAndroidHome(@Nullable Project project, boolean askFlutterTools) { if (project == null) { return EnvironmentUtil.getValue("ANDROID_HOME"); } final IntelliJAndroidSdk intelliJAndroidSdk = fromProject(project); if (intelliJAndroidSdk != null) { return intelliJAndroidSdk.getHome().getPath(); } // Ask flutter tools. if (askFlutterTools) { final FlutterSdk flutterSdk = FlutterSdk.getFlutterSdk(project); if (flutterSdk != null) { final String androidSdkLocation = flutterSdk.queryFlutterConfig("android-sdk", true); if (androidSdkLocation != null) { return androidSdkLocation; } } } return EnvironmentUtil.getValue("ANDROID_HOME"); }
Example #8
Source File: IntelliJAndroidSdk.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns the Android SDK that matches the ANDROID_HOME environment variable, provided it exists. */ @Nullable public static IntelliJAndroidSdk fromEnvironment() { final String path = EnvironmentUtil.getValue("ANDROID_HOME"); if (path == null) { return null; } // TODO(skybrian) refresh? final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path); if (file == null) { return null; } return fromHome(file); }
Example #9
Source File: FreeRunConfiguration.java From react-native-console with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected GeneralCommandLine createDefaultCommandLine() { // here just run one command: python freeline.py PtyCommandLine commandLine = new PtyCommandLine(); if (!SystemInfo.isWindows) { commandLine.getEnvironment().put("TERM", "xterm-256color"); } // commandLine.withConsoleMode(false); // commandLine.withInitialColumns(120); ExecutionEnvironment environment = getEnvironment(); commandLine.setWorkDirectory(environment.getProject().getBasePath()); String defaultShell = ObjectUtils.notNull(EnvironmentUtil.getValue("SHELL"), "/bin/sh"); commandLine.setExePath(defaultShell); // commandLine.setExePath("npm"); // commandLine.addParameters("run-script"); // commandLine.addParameters("start"); return commandLine; }
Example #10
Source File: NodeFinder.java From vue-for-idea with BSD 3-Clause "New" or "Revised" License | 5 votes |
@NotNull public static List<File> listNodeInterpretersFromNvm(String exeFileName) { String nvmDirPath = EnvironmentUtil.getValue(NVM_DIR); if (StringUtil.isEmpty(nvmDirPath)) { return Collections.emptyList(); } File nvmDir = new File(nvmDirPath); if (nvmDir.isDirectory() && nvmDir.isAbsolute()) { return listNodeInterpretersFromVersionDir(nvmDir, exeFileName); } return Collections.emptyList(); }
Example #11
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 #12
Source File: RNPathUtilTest.java From react-native-console with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testLinuxPathEnv() { System.out.println("System PATH env:" + System.getenv("PATH")); System.out.println("System PATH env by IDEA:" + EnvironmentUtil.getValue("PATH")); System.out.println("JAVA_HOME:" + System.getenv("JAVA_HOME")); System.out.println("adb:" + RNPathUtil.getExecuteFullPathSingle("adb")); }
Example #13
Source File: GeneralCommandLine.java From consulo with Apache License 2.0 | 5 votes |
/** * Returns an environment that will be inherited by a child process. * @see #getEffectiveEnvironment() */ @Nonnull public Map<String, String> getParentEnvironment() { switch (myParentEnvironmentType) { case SYSTEM: return System.getenv(); case CONSOLE: return EnvironmentUtil.getEnvironmentMap(); default: return Collections.emptyMap(); } }
Example #14
Source File: StartupUtil.java From consulo with Apache License 2.0 | 5 votes |
private static void fixProcessEnvironment(Logger log) { System.setProperty("__idea.mac.env.lock", "unlocked"); boolean envReady = EnvironmentUtil.isEnvironmentReady(); // trigger environment loading if (!envReady) { log.info("initializing environment"); } }
Example #15
Source File: SimpleProgramParameters.java From consulo with Apache License 2.0 | 5 votes |
/** * @deprecated Use {@link #setEnv(Map)} and {@link #setPassParentEnvs(boolean)} instead with already preprocessed variables. */ @Deprecated public void setupEnvs(Map<String, String> envs, boolean passDefault) { if (!envs.isEmpty()) { envs = new HashMap<>(envs); EnvironmentUtil.inlineParentOccurrences(envs); } setEnv(envs); setPassParentEnvs(passDefault); }
Example #16
Source File: AttachOSHandler.java From consulo with Apache License 2.0 | 5 votes |
@Nullable protected String getenv(String name) throws Exception { if (myHost instanceof LocalAttachHost) { return EnvironmentUtil.getValue(name); } if (myEnvironment == null) { myEnvironment = EnvironmentUtil.parseEnv(myHost.getProcessOutput(ENV_COMMAND_LINE).getStdout().split("\n")); } return myEnvironment.get(name); }
Example #17
Source File: ExternalTask.java From intellij with Apache License 2.0 | 4 votes |
private static void initializeEnvironment(Map<String, String> envMap) { envMap.clear(); envMap.putAll(EnvironmentUtil.getEnvironmentMap()); }
Example #18
Source File: BuckSettingsUI.java From buck with Apache License 2.0 | 4 votes |
private static ProcessBuilder newProcessBuilder(List<String> cmd) { ProcessBuilder processBuilder = new ProcessBuilder(cmd); processBuilder.environment().putAll(EnvironmentUtil.getEnvironmentMap()); return processBuilder; }