Intellij 2020: java.lang.AssertionError: ID with name <name> requested for <plugin name> plugin but registered with another plugin <plugin name>
I have developed a custom Intellij plugin which depends on another open source plugin already installed in Intellij. My plugin reuses 2 classes/services in runtime initialized for the open source plugin.
It worked correctly in Intellij 2019 and below.
However, in Intellij 2020+, I'm getting the following error:
com.intellij.diagnostic.PluginException: Cannot create class org.zalando.intellij.swagger.index.swagger.SwaggerFileIndex [Plugin: org.zalando.intellij.swagger]
Caused by: java.lang.AssertionError: ID with name 'SwaggerFileIndex' requested for plugin org.zalando.intellij.swagger but registered for custom plugin
Is this a new Assertion rule specified for Intellij 2020, that plugins can't reuse objects initialized for other plugins?
Is there a solution/workaround for this?
Thanks
请先登录再写评论。
Could you please post a snippet of your code accessing "SwaggerFileIndex"?
My plugin depends on the opensource plugin: org.zalando.swagger.
My plugin.xml contains:
I have a class which uses the swaggerIndexService of the opensource plugin: org.zalando.swagger.
My code->
Github link for org.zalando.intellij.swagger.index.swagger.SwaggerIndexService:
https://github.com/zalando/intellij-swagger/blob/master/src/main/java/org/zalando/intellij/swagger/index/swagger/SwaggerIndexService.java
SwaggerIndexService uses the SwaggerFileIndex.
Github link for org.zalando.intellij.swagger.index.swagger.SwaggerFileIndex: https://github.com/zalando/intellij-swagger/blob/master/src/main/java/org/zalando/intellij/swagger/index/swagger/SwaggerFileIndex.java
Please let me know if you need any other information.
Thanks
Thanks for the information. Could you please post your relevant part of Gradle setup that defines dependency on Swagger plugin? Please double-check the version of Swagger plugin you're compiling against is the same at IDE runtime and it is not accidentally packaged within your plugin distribution.
Hi Yann,
In build.gradle:
The Swagger version is correct, 1.0.28
Thanks
Alright, that is most likely the problem.
Dependencies on other plugins must be defined inside "intellij"-block, not as regular Gradle dependency.
Please see https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html#gradle for more details.
The dependancy plugin intellij-swagger plugin resides in at
<custom maven repo>.com.xxx.xxx.intellij-swagger
I followed https://github.com/JetBrains/gradle-intellij-plugin#configuration
When I specify the custom maven repo url directly, it looks for the plugin at
<custom repo url>/com/jetbrains/plugins/intellij-swagger-1.0.28
However I dont want "com/jetbrains/plugins" to get looked at instead as I want to search at <custom repo url>/com/xxx/xxx/swagger-intellij
I tried following configs to no avail
How do I configure a customized maven repo url and com.xxx.xxx.intellij-swagger correctly?
Please see https://plugins.jetbrains.com/docs/marketplace/maven-interface.html
Hi Yann,
Thanks for your response. I went through the link, however it doesn't help me.
I have already configured
You mentioned I need to include this dependency plugin in the intellij{ plugins } section instead of the dependencies section to resolve the issue I was facing at the beginning at this thread.
I want to include the dependency plugin "intellij-swagger" in the intellij { plugins } section to be picked up from a custom repo with a custom groupID (com.xxx.xxx) NOT com.jetbrains.plugins
How can I do the same?
Thanks.
Custom repository refers to Custom Repository for plugins https://plugins.jetbrains.com/docs/intellij/update-plugins-format.html, not Maven repository. Why can't you use regular plugin hosted on Marketplace https://plugins.jetbrains.com/plugin/11115-swagger-zalando-extensions-as dependency directly?
Yes, at the place where I work, we have a Custom repository for plugins. We can not directly access the plugin on the jetbrains marketplace.
Can I include the dependency plugin "intellij-swagger" in the intellij { plugins } section to be picked up from a custom repo with a custom groupID (com.xxx.xxx) NOT com.jetbrains.plugins
The ID specified for custom plugin repository is the same as the plugin's ID. This has nothing to do with Maven coordinates.
Sorry.
This is my configuration.
When I run the build, I get the following error-
Could not find com.jetbrains.plugins:intellij-swagger:1.0.28
Searched in the following locations:
- <custom plugin repo>/com/jetbrains/plugins/intellij-swagger/intellij-swagger-1.0.28.jar
- <custom plugin repo>/com/jetbrains/plugins/intellij-swagger/intellij-swagger-1.0.28.pom
But the intellij swagger is available at <custom plugin repo>/intellij-swagger/intellij-swagger-1.0.28.jar NOT <custom plugin repo>/com/jetbrains/plugins/intellij-swagger/intellij-swagger-1.0.28.jar
How do I change it accordingly?
Hi Yann Cebron. Could you please help me out^
Sorry for delay.
Could you please try with "custom" inside pluginsRepo property?
No, using the custom tag with path to plugin.xml did not work as I had mentioned a couple of comments earlier.
Anyways, we are trying to remove the dependency on the Swagger plugin. So I won't be following up on this issue further.
Thank you for your help, closing this thread.