javaintellij-ideadependency-managementintellij-pluginconflicting-libraries

Is always safe to add dependency libraries as compiled in Java?


This is the scenario:
I'm creating a plugin for jIDEA, so my code will run inside another program.
I need to use some libraries, but I'm not sure if that library will be present on runtime inside jIDEA.

If I add the library as "compile", what will happen if that library (or another version of the same library) already exists when executed?
Will my plugin use my compiled library or it will generate some conflict?


Solution

  • IntelliJ IDEA loads each plugin in its own classloader, which depends on the main IntelliJ IDEA classloader. If your plugin uses a library which is also bundled with IntelliJ IDEA, it will use the bundled version. If the library isn't bundled, your version will be used, even if other plugins use different versions of the same library. You can check which libraries are bundled by looking in the "lib" directory of the IntelliJ IDEA installation.