Loader Constraint Violation for com.intellij.psi.PsiElement in Custom Plugin - Compatibility Issue
Hello,
I'm developing a custom IntelliJ plugin, CodeVizor. The purpose is to evaluate method's complexity.
I am encountering a loader constraint violation error when trying to load run the plugin. Here is the error message I receive:
com.intellij.diagnostic.PluginException: Cannot load class com.intellij.psi.PsiElement (
error: loader constraint violation: loader com.intellij.ide.plugins.cl.PluginClassLoader @49dd77fa wants to load interface com.intellij.psi.PsiElement. A different interface with the same name was previously loaded by com.intellij.util.lang.PathClassLoader @d7b1517. (com.intellij.psi.PsiElement is in unnamed module of loader com.intellij.util.lang.PathClassLoader @d7b1517),
classLoader=PluginClassLoader(plugin=PluginDescriptor(name=CodeVizor, id=com.github.hardikm9850.codevizor, descriptorPath=plugin.xml, path=~/Documents/Github/Plugin/ComplexityReducer/build/idea-sandbox/IC-2023.3.8/plugins/CodeVizor, version=0.0.1, package=null, isBundled=false), packagePrefix=null, state=active)
From the error, it seems that the different versions of a library are loaded by separate class loaders in IntelliJ plugins.
My Current Setup:
- IntelliJ Platform: 2024.2.3
- Kotlin Version: 1.9.25
- Kover: 0.8.3
- Qodana: 2024.2.3
- Changelog: 2.2.1
Questions:
-
Dependency Configuration: Are there best practices for handling dependency conflicts in plugins, especially concerning libraries like
com.intellij.psi
? - IntelliJ Plugin Compatibility: Is there an alternative approach to ensure that all plugins and dependencies use the same versions for shared libraries?
-
Gradle Settings: Any additional configurations recommended in
build.gradle.kts
for managing IntelliJ plugin dependencies more effectively?
Repo :
https://github.com/hardikm9850/CodeVizor
Thanks in advance for any guidance on resolving this issue!
请先登录再写评论。
Most likely caused by https://github.com/hardikm9850/CodeVizor/blob/main/build.gradle.kts#L37
If you want to use Kotlin PSI in your plugin, see note Operating on Kotlin code on top of page https://plugins.jetbrains.com/docs/intellij/using-kotlin.html
Also evaluate need of https://github.com/hardikm9850/CodeVizor/blob/main/build.gradle.kts#L36 stdlib inclusion, see https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library
Thanks for pointing me to the right documentation, Yann. It helped resolve the issue!