HotswapProjects / HotswapAgent

Java unlimited redefinition of classes at runtime.
GNU General Public License v2.0
2.23k stars 480 forks source link

IntelliJ plugin or other easy way to launch from IntelliJ #492

Open Artur- opened 10 months ago

Artur- commented 10 months ago

While HotSwapAgent is super great to use, there is one problem that you can see here in this issue tracker and also when talking to people about it: People find it too difficult to get started. Even if you have IntelliJ which already contains the needed JetBrains Runtime, it is still difficult. You need to

  1. figure out where the bundled jbr is, on Mac it is in a "dangerous" location inside /Application/... or download the correct jbr among a hundred or so versions on a github page
  2. download hotswapagent and place it in the correct folder, /Applications/IntelliJ IDEA CE.app/Contents/jbr/Contents/Home/lib is not very obvious, especially as you then need to create a correctly named folder there
  3. Ensure that you are actually using jbr when launching the application
  4. Define custom VM arguments to your launch: -XX:+AllowEnhancedClassRedefinition -XX:HotswapAgent=fatjar

Now if you did everything correctly you might have hotswapagent up and running. If it does not work, it is really hard to say which step went wrong.

Could this be made trivial by creating a (quite small) IntelliJ plugin? The natural, and only needed, feature would be to have an additional option in the run dialog

image

that would say Debug 'Application.main()' using HotSwapAgent

Presumably a plugin could use the internal JetBrains Runtime, bundle the latest version of HotSwapAgent and then only ensure that launching happens with everything in the correct place. Either place the hotswapagent jar inside jbr or then, probably more safe, launch with hotswapagent outside jbr but using -javaagent or whatever options there might be. If the internal jbr poses problem, the plugin could even bundle jbr

Is this a good or bad idea? Are there other, better options to make it one-click?

skybber commented 10 months ago

Thanks for suggestion, I'll look at it. May be it could work in simillar way how the YourKit buttons is working now.