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:

  1. Dependency Configuration: Are there best practices for handling dependency conflicts in plugins, especially concerning libraries like com.intellij.psi?
  2. IntelliJ Plugin Compatibility: Is there an alternative approach to ensure that all plugins and dependencies use the same versions for shared libraries?
  3. 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!

0

Thanks for pointing me to the right documentation, Yann. It helped resolve the issue!

0

请先登录再写评论。