public static void printBallerinaEnvVariables(@NotNull GeneralCommandLine commandLine, @NotNull ProcessHandler handler) { Map<String, String> environment = commandLine.getEnvironment(); // Todo - Add BALLERINA_REPOSITORY // handler.notifyTextAvailable("BALLERINA_REPOSITORY=" + StringUtil.nullize(environment.get // (BallerinaConstants.BALLERINA_REPOSITORY)) + '\n', ProcessOutputTypes.SYSTEM); }
public static void printGoEnvVariables(@NotNull GeneralCommandLine commandLine, @NotNull ProcessHandler handler) { Map<String, String> environment = commandLine.getEnvironment(); handler.notifyTextAvailable("GOROOT=" + StringUtil.nullize(environment.get(GoConstants.GO_ROOT)) + '\n', ProcessOutputTypes.SYSTEM); handler.notifyTextAvailable("GOPATH=" + StringUtil.nullize(environment.get(GoConstants.GO_PATH)) + '\n', ProcessOutputTypes.SYSTEM); } }
@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; }
@NotNull @Override protected ProcessHandler startProcess() throws ExecutionException { String workingDir = BashRunConfigUtil.findWorkingDir(runConfig); GeneralCommandLine cmd = BashRunConfigUtil.createCommandLine(workingDir, runConfig); if (!cmd.getEnvironment().containsKey("TERM")) { cmd.getEnvironment().put("TERM", "xterm-256color"); } OSProcessHandler processHandler = new KillableColoredProcessHandler(cmd); ProcessTerminatedListener.attach(processHandler, getEnvironment().getProject()); //fixme handle path macros return processHandler; } }
@Override protected PtyProcess createProcess(@Nullable String directory) throws ExecutionException { // the env setup must add TERM as in the super implementation Map<String, String> env = Maps.newHashMap(); if (cmd.isPassParentEnvironment()) { env.putAll(cmd.getParentEnvironment()); } env.putAll(cmd.getEnvironment()); env.put("TERM", "xterm-256color"); EncodingEnvironmentUtil.setLocaleEnvironmentIfMac(env, cmd.getCharset()); try { return PtyProcess.exec(getCommand(), env, directory != null ? directory : cmd.getWorkDirectory().getAbsolutePath(), true); } catch (IOException e) { throw new ExecutionException(e); } }