@Nullable public static String retrieveRepositoryPathFromEnvironment() { String path = EnvironmentUtil.getValue(BallerinaConstants.BALLERINA_REPOSITORY); return path != null ? path : PathMacros.getInstance().getValue(BallerinaConstants.BALLERINA_REPOSITORY); } }
/** * @return unmodifiable map of the parent environment, that will be passed to the process if isPassParentEnvironment() == true */ @NotNull public Map<String, String> getParentEnvironment() { return PlatformUtils.isAppCode() ? System.getenv() // Temporarily fix for OC-8606 : EnvironmentUtil.getEnvironmentMap(); }
@Nullable public static String retrieveGoPathFromEnvironment() { if (ApplicationManager.getApplication().isUnitTestMode()) return null; String path = EnvironmentUtil.getValue(GoConstants.GO_PATH); return path != null ? path : PathMacros.getInstance().getValue(GoConstants.GO_PATH); } }
private Map<String, String> getMacroMap() { if (myMacroMap == null) { // the insertion order is important for later iterations, so LinkedHashMap is used myMacroMap = new LinkedHashMap<String, String>(); // ApplicationManager.getApplication() will return null if executed in ParameterListTest final Application application = ApplicationManager.getApplication(); if (application != null) { final PathMacros pathMacros = PathMacros.getInstance(); if (pathMacros != null) { for (String name : pathMacros.getUserMacroNames()) { final String value = pathMacros.getValue(name); if (value != null) { myMacroMap.put("${" + name + "}", value); } } } final Map<String, String> env = EnvironmentUtil.getEnvironmentMap(); for (String name : env.keySet()) { final String key = "${" + name + "}"; if (!myMacroMap.containsKey(key)) { myMacroMap.put(key, env.get(name)); } } } } return myMacroMap; }
@NotNull public GeneralCommandLine createCommandLine() throws ExecutionException { if (myGoRoot == null) { throw new ExecutionException("Sdk is not set or Sdk home path is empty for module"); } GeneralCommandLine commandLine = !myPtyDisabled && PtyCommandLine.isEnabled() ? new PtyCommandLine() : new GeneralCommandLine(); commandLine.setExePath(ObjectUtils.notNull(myExePath, GoSdkService.getGoExecutablePath(myGoRoot))); commandLine.getEnvironment().putAll(myExtraEnvironment); commandLine.getEnvironment().put(GoConstants.GO_ROOT, StringUtil.notNullize(myGoRoot)); commandLine.getEnvironment().put(GoConstants.GO_PATH, StringUtil.notNullize(myGoPath)); if (myVendoringEnabled != null) { commandLine.getEnvironment().put(GoConstants.GO_VENDORING_EXPERIMENT, myVendoringEnabled ? "1" : "0"); } Collection<String> paths = ContainerUtil.newArrayList(); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(commandLine.getEnvironment().get(GoConstants.PATH), true)); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(EnvironmentUtil.getValue(GoConstants.PATH), true)); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(myEnvPath, true)); commandLine.getEnvironment().put(GoConstants.PATH, StringUtil.join(paths, File.pathSeparator)); commandLine.withWorkDirectory(myWorkDirectory); commandLine.addParameters(myParameterList.getList()); commandLine.withParentEnvironmentType(myParentEnvironmentType); commandLine.withCharset(CharsetToolkit.UTF8_CHARSET); return commandLine; }
@NotNull public GeneralCommandLine createCommandLine() throws ExecutionException { GeneralCommandLine commandLine = !myPtyDisabled && PtyCommandLine.isEnabled() ? new PtyCommandLine() : new GeneralCommandLine(); commandLine.setExePath(ObjectUtils.notNull(myExePath, ObjectUtils.notNull(BallerinaSdkService .getBallerinaExecutablePath(myBallerinaPath)))); commandLine.getEnvironment().putAll(myExtraEnvironment); //Todo - Add BALLERINA_REPOSITORY // commandLine.getEnvironment().put(BallerinaConstants.BALLERINA_REPOSITORY, // StringUtil.notNullize(myBallerinaPath)); Collection<String> paths = ContainerUtil.newArrayList(); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(commandLine.getEnvironment().get( BallerinaConstants.PATH), true)); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(EnvironmentUtil.getValue(BallerinaConstants.PATH), true)); ContainerUtil.addIfNotNull(paths, StringUtil.nullize(myEnvPath, true)); commandLine.getEnvironment().put(BallerinaConstants.PATH, StringUtil.join(paths, File.pathSeparator)); commandLine.withWorkDirectory(myWorkDirectory); commandLine.addParameters(myParameterList.getList()); commandLine.withParentEnvironmentType(myParentEnvironmentType); commandLine.withCharset(CharsetToolkit.UTF8_CHARSET); return commandLine; }