How do I listen to run events within my own intellij plugin?

Answered

I want to implement my own hot deploy plugin, so I need to listen to the service's `Run` event and `Debugger` event.

I know that debug events need to use XDebuggerManagerListener and i got debugger event. 

now i have implemented RunManagerListener for the run event, but it doesn't work, I can't listen to the service startup message. What should I do?

6 comments
Comment actions Permalink

RunManagerListener seems like a listener for run configuration management events, not execution events.

Please try with subscribing to com.intellij.execution.ExecutionManager#EXECUTION_TOPIC.

0
Comment actions Permalink

Thanks for your help, now I can get running events.

There is another problem that I want to add an agent before running or debugging by adding -javaagent agent.jar. What should I do to get the command when the service starts and add it.

0
Comment actions Permalink

When i use com.intellij.execution.process.BaseProcessHandler#getCommandLine got the java command.

How do I modify it now to achieve the purpose of adding the agent parameter.

 

 
0
Comment actions Permalink

Sorry to bother you again. I have a little problem now.

Ff I have a lib directory in the root directory of the plugin with a jar file in it, I want to get the path of this jar in the -javaagent parameter, this path How should I get it.

The directory structure is as follows

├─.github
│  └─workflows
├─.gradle
├─.idea
│  ├─libraries
│  └─modules
├─.run
├─lib
│  ├─agent.jar
├─build
├─gradle
│  └─wrapper
└─src
    ├─main
    └─test
How can I get the path of agent.jar in lib?
0
Comment actions Permalink

Hi,

Please check PathManager.getPluginsPath() or PluginManagerCore.getPlugin(<your plugin ID>).getPath().

PS
Please keep posts focused on a single topic. It will be easier for other developers to find the answers they are looking for.

0

Please sign in to leave a comment.