How to debug a plugin?

Hi,

I went through the guide for plugin development.

What is the approach to debug already existing plugins?

I referred to this gist as it has a section for debugging.

However the approach doesn’t work when the plugin itself has dependencies.

For example: if I try to debug Openfire Meeting plugin with the approach in the plugin development guide,it throws an exception.

What is the ideal way to debug plugin with dependencies in IntelliJ Idea?

1 Like

Hello,

I could debug broadcast plugin very now. Probably, I will avoid turning off my computer in the next weeks. :stuck_out_tongue:

Having Openfire already setup in you editor, I did the following:

  1. Cloned broadcast plugin in a different folder;
  2. Open Module Settings (F4)
  3. Click on the + signal, somewhere on the top of Module Settings Window
  4. Then, click on Import Module
  5. Select the plugin folder (Broadcast in this case)
  6. Click on Maven
  7. And then finish
  8. On command line, build the plugin with mvn verify in the plugin folder
  9. Copy the Jar file to Openfire plugins folder, (My case: cp broadcast/target/broadcast-openfire-plugin-assembly.jar src/distribution/target/distribution-base/plugins/broadcast.jar)
  10. Then put your breakpoints
  11. Run openfire with debug options
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -Dlog4j.configurationFile=/opt/openfire/distribution/target/distribution-base/lib/log4j2.xml -server -DopenfireHome="/opt/openfire/distribution/target/distribution-base" -Dopenfire.lib.dir="/opt/openfire/distribution/target/distribution-base/lib" -classpath "/opt/openfire/distribution/target/distribution-base/lib/startup.jar" -jar "/opt/openfire/distribution/target/distribution-base/lib/startup.jar"

(These paths are related to openfire inside my Docker container, /opt/openfire will be different for you)
12) Click on Debug on IDEA … you might have to setup some options there
13) Access something in Openfire to see if the breakpoint activate

I’m not a Java developer, so these steps might be longer than the desirable. Copying jar each time you change the plugin source might be a nightmare. I hope someone has a better way to do that.