简体   繁体   中英

Change IntelliJ Run Configuration Environment Variables with Plugin

I am trying to build a plugin for IntelliJ that when pressing a button, it will load env vars from the web to the current Run Configuration.

I couldn't find a way to reach the current Run Configuration, let alone to edit the env vars.

When trying to create new Action all I get as a parameter is a AnActionEvent and I couldn't find anything useful there

public class HelloAction extends AnAction {

    public HelloAction() {
        super("Hello");
    }

    @Override
    public void actionPerformed(AnActionEvent event) {
        Project project = event.getProject();
    }
}

I would be happy for any clue here

To get the current run configuration, use RunManager.getInstance(project).getSelectedConfiguration().getConfiguration() . Then check if the returned object implements CommonProgramRunConfigurationParameters , and if it does, call the setEnvs method of this interface to change the environment variables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM