Install jar dependencies with a plugin
I am developing a plugin that has some dependencies. The dependencies are jar files.
The only related question I have found in this forum is here:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360009394340-Include-jar-with-plugin
But it did not help...
The dependencies are defined in build.gradle file under "dependencies", and they are correctly placed in the resulting "zip" file.
To be clear, the resulting ZIP file structure is:
- <plugin_name> (folder)
- lib (folder)
- list of jars (dependencies and my plugin together in the lib folder)
I can install it from disk, or from a repository that I have set up. Unfortunately the dependencies are not properly installed.
To be clear:
- I install it and everything seems working (both form local disk and from repository)
- The file becomes unavailable (because I delete/move the plugin in my local disk, or because I shut down the repository) and the library is missing, causing malfunction in the plugin.
As far as I read, putting the dependencies in the ZIP file should be enough...should I declare them somewhere, in order to let intelliJ install them as well?
Please sign in to leave a comment.
I don't quite understand what this means in detail
> The file becomes unavailable (because I delete/move the plugin in my local disk, or because I shut down the repository) and the library is missing, causing malfunction in the plugin
What exactly is "delete/move plugin"? The IDE needs to keep the local installation of the plugin you performed previously.
Hallo Yann.
Well, that's exactly the problem :)
When I install a plugin, where should be this local installation in my computer (i am using Linux Mint by the way)? How can I verify that all dependencies are correctly installed?
To explain better, suppose I install it from my local disk, so I have the plugin (in a ZIP file) in "~/Documents" and install it using "Install plugin from Disk...".
At this point, is working.
I tried to close and restart IntelliJ, and it is still working.
Once I have installed it, I delete the ZIP file from "~/Documents" (because it should not be necessary anymore).
Now, some malfunctions is clearly visible due to the missing dependency (I also see the error in the log of IntelliJ that the dependency is missing).
(But the general behaviour of the plugin is still working.)
So, somehow IntelliJ did not take my dependency properly.
(The same behaviour is happening if I install the plugin using a local repository.)
Please check installation succeeded by checking "Plugins directory" for correct installation
https://intellij-support.jetbrains.com/hc/en-us/articles/206544519-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs
Hallo Yann.
I confirm:
- the plugin JAR and all the other jars dependencies are correctly copied in the folder "~/.local/share/JetBrains/IntelliJIdea<myversion>/<pluginname>/lib/"
- still, the dependency seems not working properly and the plugin does not work as it should
What libraries are these? Can you link sources of your plugin or provide the final ZIP?
I should ask if I can post the plugin.
Anyway, I can tell I am having trouble with "flexmark" libraries for MarkDown rendering.
This is a piece of my build.gradle file:
```
all the "flexmark-*.jar" libraries are correctly included in the "lib" folder together with my plugin.
Testing with "intellij::runIde" task through Gradle works fine, after installing works fine as well (I can properly see Markdown rendered)
But after restarting the IDE and removing the local ZIP from my "Documents" folder, is not working anymore (I don't see markdown rendered anymore, only plain text).
As I said, I see that all the "flexmark-*.jar" libraries are copied in the right folder "~/.local/share/JetBrains/IntelliJIdea<myversion>/<pluginname>/lib/"
Thanks for your help
Are there any exceptions in idea.log?
mmm Thanks for the question...I did this test, that is confusing me more than before...
I opened IntelliJ, the flexmark is not working (no Mardown rendered, only plain test). But NO exception in the log.
After I manually remove the library from "~/.local/share/JetBrains/IntelliJIdea2020.3/<myplugin>/lib", I see the "java.lang.NoClassDefFoundError: com/vladsch/flexmark/util/data/DataHolder" exception, as expected (since the library was removed)...in this case, the plugin is not working at all (not even plain text), and I can see the error in IntelliJ itself (not need to go to the log).
I am a bit confused...
Any idea what I could check?
No more ideas ATM from my side what to check.
I tested with a fatjar and I had the same problem.
At this point, the problem seems not to be the dependency loading...
I am also getting the same error when I use it fatjar.
Up to this point I think the problem is not in dependency loading but somewhere else in the plug in